Skip to content

monitor

Record(time, name, value, description) dataclass

Stores information about a simulation event.

Parameters:

Name Type Description Default
time float | datetime

simulation time.

required
name str

The name of the record.

required
value Any

the event value to record

required
description str | None

optional description of the recorded event

required

Monitor(sim, trace)

The Monitor is simply a convenient class to record different events or moments during the simulation. Simulation without data analytics is useless.

The Monitor is used internally by the Simulator and is not ment to be used outside this context.

To record an event you simply have to call the record method o the simulator and pass 2 required parameters and optionally a third one.

from pydes.process import Component, Simulator

class Process(Component):
    def __init__(self, sim: Simulator):
        self.sim = sim

    def main(self):
        for _ in range(10):
            self.sim.record(self,"start waiting")
            self.sim.sleep(2)
            self.sim.record(self,"end waiting","this is an aditional description")

When the simulation runs, you'll see all you recorded events printed out. Besides, these records can be retreived for further analysis using the records from the Simulator.

To turn off the printing of the records during simulation, you can pass 'trace=False' to the Simulator constructor.

Parameters:

Name Type Description Default
sim Simulator

The simulator instance.

required
trace bool

Indicates whether tracing is enabled or not.

required

record(name, value, description)

Record a simulation event.

Parameters:

Name Type Description Default
name str

The name associated with the event.

required
value Any

Value associated with the event.

required
description str | None

Description of the event.

required

values()

Get recorded simulation events.

Returns:

Type Description
list[Record]

list of Record objects.