JuliaDynamics / Agents.jl

Agent-based modeling framework in Julia
https://juliadynamics.github.io/Agents.jl/stable/
MIT License
717 stars 115 forks source link

Implement EventQueueABM #917

Closed Tortar closed 7 months ago

Tortar commented 9 months ago

Fixes #902

Still very bad but the new example at least works :-)

codecov-commenter commented 9 months ago

Codecov Report

Attention: 54 lines in your changes are missing coverage. Please review.

Comparison is base (fa03585) 92.26% compared to head (23812ed) 90.51%. Report is 3 commits behind head on main.

:exclamation: Current head 23812ed differs from pull request most recent head cb0519b. Consider uploading reports for the commit cb0519b to get more accurate results

Files Patch % Lines
src/simulations/step.jl 0.00% 26 Missing :warning:
src/core/model_event_queue.jl 34.48% 19 Missing :warning:
src/core/model_validation.jl 89.36% 5 Missing :warning:
src/submodules/schedulers.jl 50.00% 2 Missing :warning:
src/core/model_abstract.jl 0.00% 1 Missing :warning:
src/core/model_accessing_API.jl 95.23% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #917 +/- ## ========================================== - Coverage 92.26% 90.51% -1.75% ========================================== Files 33 36 +3 Lines 2274 2331 +57 ========================================== + Hits 2098 2110 +12 - Misses 176 221 +45 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Datseris commented 8 months ago

I am confused about the existence of model_step and agents_first, as the whole point of this event based system is that there is no model step and there cannot be "before" or "after" the step, as events happen on a continuous time line and hence don't have an end; they go on until exhaustion or hitting a user-provided time limit.

I would argue that if a user wants "agent steps" and "model steps" they should just go ahead and use the StandardABM and hence here we should focus on just the quing system and simplify everything.,

Tortar commented 8 months ago

I agree :+1:

Datseris commented 8 months ago

@Tortar what is remaining for this to be finished? It's the last PR before v6, right?

Tortar commented 8 months ago

Mainly some docstrings need to be finished and we need to add some more tests for the new model type. We agreed with @fbanning to put also #934 in the v6 milestone. I'm a bit overwhelmed by other tasks at the moment, I think I can work on this monday. But if someone else wants to help feel free to add your commits to the branch

jacobusmmsmit commented 8 months ago

Can I ask what happened with the ConcurrentSim implementation? Did anyone try doing a comparison? I looked into CS.jl and it was rather complicated. I think it raises the complexity barrier for contributers even if none of the internals are exposed.

Tortar commented 8 months ago

I think that we can add the CS.jl integration later, I'm not sure that internal with CS.jl will become too complicated, maybe it is so but it is worth trying in my opinion. I don't think it's a priority though

jacobusmmsmit commented 8 months ago

At one point we can make a performance comparison with "from scratch continuous abm", "Agents-v6 continuous abm", and a "CS Agents continuous abm" and see if it's worth it, and if so how much.

Datseris commented 8 months ago

I can take over this PR. I realized there are some things we need to improve. For example, if an agent is added to the model via e.g., replicate!, this agent will never get an event assigned to it. My proposal is that when an agent gets added to the model, we immediatelly trigger the event generatrion function for it. This also solves the "what's the starting event" problem. Because as soon as we populate the model with agents, there is also an event que.

I also want to do two more improvements: using the concept of probability mass to decide how events are chosen, and simplifying significantly the events. I will add a generic type AgentEvent that takes in an event function and the type of agent it applies over. In this way an event may be applicable to many agents by providing the AbstractAgent as the agent type, which will also be the deafult value.

Datseris commented 8 months ago

I have had great progress in the eventqueuv2 branch, but I am not finished yet. I take a break now but I will finish this soon!

The new code gives more power to the user (more possible configurations and flexibility) while requiring the user to input less information due to two default options!

Tortar commented 7 months ago

Closing in favor of #940