-
Notifications
You must be signed in to change notification settings - Fork 6
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
examples: Adding Sugarscape IG - polars with numba vectorized loop #91
examples: Adding Sugarscape IG - polars with numba vectorized loop #91
Conversation
for more information, see https://pre-commit.ci
Codecov ReportAll modified and coverable lines are covered by tests ✅ |
…oves aren't duplicated
…o 67-sugarscape-instantaneous-growback-polars-with-numba
…hborhood. For both numba and completely vectorized it's easier to reason this way then update the current sugar and "best moves" ranking when agents move
…ght make the same move and haven't found the optimal move yet). This avoids race conditions.
…ssary since we prepare the neighborhood looking at potential/max sugar anyway)
…ing in the future)
This is ready. |
|
||
# Filter impossible moves | ||
# Filter only possible moves (agent is in his cell, blocking agent has moved before him or there is no blocking agent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the previous one, although more concise, not considered favorable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the previous implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pl.col("blocking_agent_order").is_null()
is to allow agents to move if there is no blocking agent.
I changed the title for clarity
Approved because my comments are questions instead of blocking requests. |
This PR introduces a Numba implementation for the loop in SugarscapePolars to optimize agent move calculations. Key points:
Implementation: Added a Numba-accelerated function to determine the best moves for agents, replacing the more complex DataFrame-based logic.
Validation: Implemented equality checks across different Polars implementations to ensure consistent results.
Performance Comparison:
Numba Considerations:
Performance Bottlenecks:
Future Optimizations: