opensistemas-hub / osbrain

osBrain - A general-purpose multi-agent system module written in Python
https://osbrain.readthedocs.io/en/stable/
Apache License 2.0
175 stars 43 forks source link

Using osBrain for virtual time simulation #355

Open shahab-valaei opened 4 years ago

shahab-valaei commented 4 years ago

Hello, I am considering to use osBrain for my simulation but I need a virtual time simulation, not real-time. Is it possible to add a virtual time for agents in osBrain like discrete event simulation?

Thanks

Peque commented 4 years ago

osBrain is meant for real-time applications. You could implement some kind of synchronization mechanism between the agents for a "virtual time simulation", but that is not built-in. Depending on your application, that could end up resulting slow, but I cannot tell without more information about the application. :wink:

shahab-valaei commented 4 years ago

I want to create a simulation to model the organizations involved in disaster management. Each organization is considered as an agent. In this simulation, communication and collaboration between organizations is particularly important as it determines the quality of the disaster management process. Number of agents may be in order of 1000 or more. Do you think osBrain is a good choice? Thanks for your consideration.

Peque commented 4 years ago

Maybe. Currently agents are based on system processes, which are heavy to spawn, specially on Windows systems. If you have lots of RAM then that may not be a huge deal though.

Another important factor is how they communicate. Do you have an idea on how many messages will be passed during the whole simulation? And the expected duration of the simulation? Knowing whether you need frequent synchronization (i.e.: for "fake time simulation") and whether you will be using 1-to-1 or 1-to-many communication patterns can greatly affect your performance too.

You can always do a quick test yourself and see how it goes. Don't forget to report back! :wink:

shahab-valaei commented 4 years ago

In this simulation agents are in two main clusters. Some of them have 1-to-1 and others have 1-to-many communication patterns. The number of message may be around 10000 for whole simulation in each run and total time of simulation is around 6 month (4320 hours). I want to do a test but I don't know how to use frequent synchronization for virtual time simulation. I would appreciate it if you could show me some guidelines or introduce some resources to help me doing that. Thanks a lot

Peque commented 4 years ago

Initially, as a very dirty approximation, you could simply launch a step and see how much it takes to run (measure a couple of times). Measure until you see no CPU/communication activity. Then run a whole simulation by simply running one step after another leaving enough "sleep" time (i.e.: take the highest time you measured and multiply by some factor). That is no real synchronization method, but could help you setting up a proof of concept to see if osBrain fits your needs.

If you want real synchronization, you need to find the last agent(s) that are expected to perform any actions during one step. Make sure those agents report back to the one deciding when a new step needs to be run.

Peque commented 4 years ago

@shahab7494 Maybe you will be interested in this discussion: https://github.com/opensistemas-hub/osbrain/issues/356