Simulation queue

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Simulation queue

While working on the simulation clock, it occurred to me that most simulations I've worked with over the years maintain a "simulation queue" of actions to be executed in the future. Each action contains a time, and some work to be done. The actions are sorted by time, and every time the simulation clock advances, all the actions that should have been run by that time are run. This is very easy to implement with groovy closures, including actions that repeat themselves indefinitely at some interval. For example, we could easily schedule market clearings every 30 minutes, and tariff evaluations every six hours. This should eliminate the need to distribute events for many cases.

This is implemented in the powertac-common plugin, in org.powertac.common.TimeService, and you can see examples of how to use it in TimeServiceTests.

Cheers -