:py:mod:`starling_sim.basemodel.schedule.scheduler` =================================================== .. py:module:: starling_sim.basemodel.schedule.scheduler .. autoapi-nested-parse:: This module is dedicated to discrete event scheduling. It allows the representation of a time flow inside the simulation. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: starling_sim.basemodel.schedule.scheduler.Scheduler .. py:class:: 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. .. _SimPy: https://simpy.readthedocs.io/en/latest/index.html .. py:attribute:: interrupt .. py:method:: run(run_time) Update the runtime limit attribute and run the environment. :param run_time: duration of the simulation run .. py:method:: now() Get the current simulation step. :return: Current time of the simulation (arbitrary unit) .. py:method:: timeout(duration='inf') Create a SimPy timeout event with the given duration :param duration: time to pass, in simulation units. Defaults to 'inf', ie end at the simulation time limit. Must be positive and integer-like :return: SimPy timeout event .. py:method:: new_event_object() Create and return a new Event object :return: Event object .. py:method:: new_process(generator) Create a SimPy process from the given generator :param generator: Python generator (function containing the yield keyword) :return: SimPy Process object .. py:method:: interrupt(process, message='') :staticmethod: Interrupt the given SimPy process, e.g. an agent waiting in a queue :param process: simPy Process object :param message: interruption message, to be displayed in the agent's trace