-
Notifications
You must be signed in to change notification settings - Fork 883
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
Find single agent in agentset #2316
Comments
Thanks for the write-up. Slightly related, I have a
Directly accessing by One consideration is if we want to access by Maybe the AgentSet should have a boolean attribute called But I think we have to make a choice here if we want to allow accessing by
For reference, this feature would be roughly equivalent to NetLogo's |
Just some questions, trying to understand better what this will solve:
2
A few thoughts. First, tyou can already slice an agentset because it implements
|
From #2317 (comment)
Digression:
|
Yes, using |
It's covered by |
Fair enough, but again: when would a user want to use this? The only use case that has been claimed, but not developed in any clear detail is debugging. |
I do have a specific example: in the past model I wrote, one class of the agents consists of systemically important banks, the other class being other financial institutions. I had to be able to track and analyze the evolution of a particular named bank (e.g. Barclays plc) under an external shock (data collection). (This is a separate point: this also means that each agents attributes was initialized from concrete data, and the removal of explicit unique ID in Mesa 3.0 makes it harder to use the ISIN of the banks as the unique ID.) |
Ok, but then it is about finding 1 specific agent given some selection criterion (which can be def find(self, select_function: Callable) -> Agent:
'''Find the first agent that meets the select function.
Args:
select_function: A callable that is called with an agent and returns a boolean
'''
for agent in self._agents:
if select_function(agent):
return agent
return None # or perhaps even raise an exception? |
What's the problem this feature will solve?
As @rht pointed out in #2314 (comment) There is currently no easy way to retrieve a single agent by it's I'd.
Describe the solution you'd like
I see two ways to solve this
agentset.agents[unique_id]
Of course it would also be possible to add both.
The text was updated successfully, but these errors were encountered: