starling_sim.basemodel.schedule.scheduler
This module is dedicated to discrete event scheduling. It allows the representation of a time flow inside the simulation.
Module Contents
Classes
This class manages a discrete event schedule using the SimPy library. |
- class starling_sim.basemodel.schedule.scheduler.Scheduler
This class manages a discrete event schedule using the SimPy library.
Along with containing a SimPy environment, this class also provides methods for the generation of SimPy Event objects (Process objects are events too). Yielding these events will suspend the current activity (e.g agent loop), which will resume once the event occurs (or before if the process is interrupted).
This way, agents can yield processes corresponding to an action (move, wait, etc) and resume to their loop after the action has finished.
- interrupt
- run(run_time)
Update the runtime limit attribute and run the environment.
- Parameters:
run_time – duration of the simulation run
- now()
Get the current simulation step.
- Returns:
Current time of the simulation (arbitrary unit)
- timeout(duration='inf')
Create a SimPy timeout event with the given duration
- Parameters:
duration – time to pass, in simulation units. Defaults to ‘inf’, ie end at the simulation time limit. Must be positive and integer-like
- Returns:
SimPy timeout event
- new_event_object()
Create and return a new Event object
- Returns:
Event object
- new_process(generator)
Create a SimPy process from the given generator
- Parameters:
generator – Python generator (function containing the yield keyword)
- Returns:
SimPy Process object
- static interrupt(process, message='')
Interrupt the given SimPy process, e.g. an agent waiting in a queue
- Parameters:
process – simPy Process object
message – interruption message, to be displayed in the agent’s trace