Discrete Event Simulator

This module contains the definition of a discrete-event simulator. It has the definition of the DiscreteEventSimulationEngine, that allows simulations with inputs and time over a discrete-event dynamic system.

Example

Creating a discrete-event simulator:

...
dynamic_system = some_discrete_event_dynamic_system
simulator = DiscreteEventSimulationEngine(dynamic_system, DefaultReport())

Running a discrete-event simulation:

simulator.compute_next_state(time=simulator.get_time_of_next_event())
class gsf.simulation.simulation_engines.discrete_event_simulation_engine.DiscreteEventSimulationEngine(dynamic_system: DiscreteEventDynamicSystem, base_generator: BaseReport, event_bus: EventBus = None)

Bases: gsf.simulation.core.base_simulator.BaseSimulator

Simulation engine for discrete-event simulation

_dynamic_system

Dynamic system to be simulated.

Type

BaseDynamicSystem

_is_output_up_to_update

Indicates if the output was computed for that iteration.

Type

bool

_last_event_time

Time of the last event recorded.

Type

Time

compute_next_state(inputs: DynamicSystemInput = None, time: Time = Decimal('0'))

Compute the next state of the dynamic system

Parameters
  • inputs (DynamicSystemInput) – Input for the dynamic system.

  • time (Time) – Time of the event.

compute_output()

Compute the output of the dynamic system if it has not computed yet

get_time_of_next_event()decimal.Decimal

Get time of the next event

init()

Initializes the simulator properties