pypdevsbbl.tracers.FootprintTracer module

This file contains a tracer that can can gather the execution cost of a simulation.

The execution cost is either measured at the input port(s) or the output port(s) of a block. For readability, choose one and keep it consistent whenever possible.

class pypdevsbbl.tracers.FootprintTracer.FootprintTracer(uid, server, filename, name, mapping, full=True, cpi=False)[source]

Bases: pypdevsbbl.tracers.BaseTracer

Gathers cost information of the simulation.

The provided cost can be whatever is required in the current simulation. It can be the carbon footprint, the pricetag or even the amount of electricity. For this reason, multiple FootprintTracer may be registered to the simulation. Give each FootprintTracer a name to correctly associate the traced cost with the real-life consequences.

Parameters:
  • uid – A unique identifier for distributed simulation. Will be set automatically.
  • server – The server that runs the distributed simulation. Will be set automatically.
  • filename (str) – The name of the file to write the results to. When None, all results will be written to the standard output.
  • name (str) – The name of the FootprintTracer. Used to differentiate the results of different instances.
  • mapping (dict) – A mapping from a port of a building block to a number or a function that returns a number. This number represents the cost for each item that is inputted or outputted on that port. The function takes the item as an argument. E.g. an object with a weight of 60 kilograms might be more expensive when compared to an object that weighs 10 kilograms.
  • full (bool) – When True, output the full trace. Otherwise, only output the results.
  • cpi (bool) – Whether or not to print the cost per item at the end. These costs will be sorted with the largest cost first. Defaults to False.
startTracer(recover)[source]
stopTracer()[source]
traceExternal(aDEVS)[source]

Traces all items arriving on input ports.

traceInternal(aDEVS)[source]

Traces all items arriving on output ports.

total()[source]

Obtain the total footprint of the simulation.