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

continuous-event/-time ABM? #950

Open
wangzizhe opened this issue Jan 4, 2024 · 8 comments
Open

continuous-event/-time ABM? #950

wangzizhe opened this issue Jan 4, 2024 · 8 comments
Labels
support Question about usage or clarity of features/documentation

Comments

@wangzizhe
Copy link

Hi,

would like to ask whether Agent.jl plans to support continuous-event/-time agent based modeling in the near future?

Or is it already supported?

Thanks a lot in advance!

@Tortar
Copy link
Member

Tortar commented Jan 4, 2024

Good timing! :D It is already (partially) supported, just a week ago we merged #940 where we implemented a lot of the interface for the EventQueueABM model type, some functions still don't work with it because they require some more development (mainly visualizations and checkpointing). You can try it by using the dev version of the library, which will be soon become Agents.jl version 6. it would be very cool to know what other people think about: there is already a working example of the functionality at https://github.com/JuliaDynamics/Agents.jl/blob/main/examples/event_rock_paper_scissors.jl

@Tortar Tortar added the support Question about usage or clarity of features/documentation label Jan 4, 2024
@manentai
Copy link

manentai commented Jan 5, 2024

hey @Tortar is this aimed at dicrete-event simulations, like for instance the time extension in NetLogo? if this is the case, do you also plan to add examples to show how to represent time explicitly?

@wangzizhe
Copy link
Author

Hi @Tortar, thanks for your flash reply! As far as I read from all the resources, this is more related to time-continuous? Does Agents.jl also supports continuous-events somehow?

Thanks a lot in advance!

@Tortar
Copy link
Member

Tortar commented Jan 5, 2024

@wangzizhe mmh maybe now I understand, I will quote #884 (comment) because I think that comment provides an answer to the question (the example the author is referring to is https://juliadynamics.github.io/Agents.jl/stable/examples/diffeq/ and his library which could be of interest to you is https://github.com/dsb-lab/CellBasedModels.jl). So in short it seems that we can leverage some of the advantages of modeling with differential equations, but not that much at the moment. I cite here @Datseris because probably he can tell you more about this when he sees this issue.

@manentai yes you can use it as the "Discrete Event Scheduler" defined in https://ccl.northwestern.edu/netlogo/docs/time.html, but it has some more enhanced capabilities because EventQueueABM can generate events automatically following some probability distribution (as a default it uses a form of the Gillespie algorithm to generate them).

@Tortar
Copy link
Member

Tortar commented Jan 5, 2024

If by representing time explicitly you mean by dates I guess this could be done by the user by choosing what each time of the model represents in the real world e.g. you could use a function converting abmtime(model) in a date. We don't have plans on demostrating this, but let me know if you have some ideas on what could be an interesting example! Or you mean something different?

@manentai
Copy link

manentai commented Jan 5, 2024

If by representing time explicitly you mean by dates I guess this could be done by the user by choosing what each time of the model represents in the real world e.g. you could use a function converting abmtime(model) in a date. We don't have plans on demostrating this, but let me know if you have some ideas on what could be an interesting example! Or you mean something different?

that's exactly it, connecting simulated time to "real" time units, like days, months or years...
simulating an organization, for instance, you want to run the production function every day, but run the accounting function at the end of the month... I am working on a model in these days and maybe I could suggest some examples..

@Datseris
Copy link
Member

So in short it seems that we can leverage some of the advantages of modeling with differential equations, but not that much at the moment.

Not much is an understatement. You can do plenty of things by integrating diffeq and agents.jl. So I am not sure whether we even need to do anything on our side. @wangzizhe , can you please tell us explicitly what you want to do? "Continuous event" sounds rather generic, and I can imagine already a good 100 things that would qualify as a "continuous event" yet are already possible to do with Agents.jl by including other Julia libraries in your project.


simulating an organization, for instance, you want to run the production function every day, but run the accounting function at the end of the month... I am working on a model in these days and maybe I could suggest some examples..

To the best of my understanding, all of this is already possible within Agents.jl. If you use discrete time simulations you just need to set your quantum of time: how much time is one step of the simulation? The you can use the abmtime function to doe everything else you want, by checking e.g. if its modulo 7 is 0 (one week). Besides, Julia's date time support is robust and plays well with standard numeric types. You can make as a parameter of your model the starting date:

t0 = Date(2022, 2, 1)
time_quantum = Day() # how much time corresponds to one discrete step

# then later:
t_current = model.t0 + model.time_quantum*abmtime(model)

this would give you the time of the model in DateTime format.

@Datseris
Copy link
Member

@manentai it would be fantastic once you have your model set up to make a simplified version of it and contribute it as an example in AgentsExampleZoo.jl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Question about usage or clarity of features/documentation
Projects
None yet
Development

No branches or pull requests

4 participants