Skip to content
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

feat: adding abstraction of optimal agent movement #108

Open
adamamer20 opened this issue Oct 28, 2024 · 2 comments
Open

feat: adding abstraction of optimal agent movement #108

adamamer20 opened this issue Oct 28, 2024 · 2 comments
Labels
feature New functionality added to the project.

Comments

@adamamer20
Copy link
Collaborator

It would be beneficial to have a function in the DiscreteSpaceDF (and AgentContainer) for moving agents based on attributes:

move_to(agents: AgentLike, attr_names: str | list[str], rank_order: ['max' | 'min'] | list['max' | 'min'])

For example: move_to('sugar', 'max'). This would abstract the code for handling sequential conflicts, making it easier than handling them from scratch each time.

@adamamer20 adamamer20 added the feature New functionality added to the project. label Oct 28, 2024
@suryanshgargbpgc
Copy link

hi @adamamer20, I tried to understand this issue, if I am correct this feature aims to write a function which upon calling would solve the issue of multiple agents trying to move on the same grid at the same time which will prevent us from dealing with those edge cases everytime.
Can you please share me necessary resources which can help me address this issue ?
Also could you please elaborate on any points i missed.

@adamamer20
Copy link
Collaborator Author

@suryanshgargbpgc You're correct in your understanding! I recommend checking out the sugarscape example for polars to get a clear picture of these concurrency conditions. You can see it here:

https://github.com/projectmesa/mesa-frames/blob/1d7b3ed11a61130cbee12fe0c9222d233b234669/examples/sugarscape_ig/ss_polars/agents.py#L174C1-L225C73

In this example, the best move might be the same for multiple agents at the same time. Since we're moving all ants simultaneously in a vectorized way, it's important to address this issue. I handled it this way in sugarscape, and I believe the same reasoning can be generalized to accommodate various agent attribute objectives, removing the burden of the implementation on the user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality added to the project.
Projects
None yet
Development

No branches or pull requests

2 participants