-
Notifications
You must be signed in to change notification settings - Fork 936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Agent selection method #1905
Comments
In the future, a very similar API could be constructed for the PropertyGrid (#1898) to select grid cells. Keeps is nice and consistent. |
For some more context, aside from NetLogo's |
Love the idea. For the implementation we can do this in small steps if more manageable. I mean we don't need to implement all the functions directly |
@jackiekazil @tpike3 I would like to discuss and potentially implement this before moving on the PropertyLayer (#1898), since this is a more generalized solution for a problem that I specifically solve in that PR. So if we can implement this, it would make especially the _PropertyGrid in #1898 a lot simpler. So my specific questions are:
One thing I'm thinking of is merging the sort and direction parameters and using a list of tuples. So instead of: select_agents(n=5, sort=['wealth', 'age'], direction=['highest', 'lowest']) It would be: select_agents(n=5, sort=[('wealth', 'highest'), ('age', 'lowest')]) What would you prefer? |
This would be great!
|
Shall we allow both?
I see it as as long as you don't change the default ( |
Closing this as solved!
|
A built-in method for agent selection and filtering could help in many situations to select an appropriate subset of agents. This feature request proposes the introduction of a versatile
Model
method, namedselect_agents
. This function will allow users to select agents based on a combination of attributes, agent types, and functional filters, with the flexibility of specifying the number of agents to select.This proposal is inspired by the various variants of the
n-of
functions in NetLogo and @rht smart idea in #1894 (comment).Functionality Overview:
The
select_agents
function is designed to be highly flexible and adaptable to various modeling scenarios. Its key features include:Optional Quantity of Agents (
n
):n
(Optional): An integer specifying the desired number of agents to select. If not specified, all agents meeting the criteria will be selected.Criteria-Based Sorting (
sort
anddirection
):sort
(Optional): A list of attribute names to sort agents. It defines the criteria for selection.direction
(Optional): Accompanyingsort
, this list specifies the sorting direction ('lowest' or 'highest') for each criterion.Agent Filtering (
filter
):filter
(Optional): A lambda function or callable that applies additional conditions to filter agents. It allows for complex logical expressions to refine the selection.Type-Based Filtering (
agent_type
):agent_type
(Optional): A class or list of classes specifying the type(s) of agents to be included in the selection. This ensures that only agents of certain types or subclasses are considered.Flexible Size Handling (
up_to
):up_to
(Optional): A boolean that, when True, allows the function to return up ton
agents, preventing errors ifn
exceeds the available agent count. It defaults to True for convenience.Usage Scenarios:
Selecting a Specific Number of Agents:
Complex Multi-Criteria Selection:
Selection with Functional Filtering:
Type-Specific Selection:
SpecificAgentClass
:The text was updated successfully, but these errors were encountered: