AtomicDEVS User Interface¶
- class pypdevs.DEVS.AtomicDEVS(name=None)[source]
Abstract base class for all atomic-DEVS descriptive classes.
- __init__(name=None)[source]
Constructor for an AtomicDEVS model
- Parameters
name – name of the model, can be None to have an automatically generated name
- addInPort(name=None)
Add an input port to the DEVS model.
addInPort is the only proper way to add input ports to a DEVS model. As for the CoupledDEVS.addSubModel method, calls to addInPort and addOutPort can appear in any DEVS’ descriptive class constructor, or the methods can be used with an instantiated object.
The methods add a reference to the new port in the DEVS’ IPorts attributes and set the port’s hostDEVS attribute. The modeler should typically save the returned reference somewhere.
- Parameters
name – the name of the port. A unique ID will be generated in case None is passed
- Returns
port – the generated port
- addOutPort(name=None)
Add an output port to the DEVS model.
addOutPort is the only proper way to add output ports to DEVS. As for the CoupledDEVS.addSubModel method, calls to addInPort and addOutPort can appear in any DEVS’ descriptive class constructor, or the methods can be used with an instantiated object.
The methods add a reference to the new port in the DEVS’ OPorts attributes and set the port’s hostDEVS attribute. The modeler should typically save the returned reference somewhere.
- Parameters
name – the name of the port. A unique ID will be generated in case None is passed
- Returns
port – the generated port
- confTransition(inputs)[source]
DEFAULT Confluent Transition Function.
Accesses state and elapsed attributes, as well as inputs through the passed dictionary. Returns the new state.
Note
Should only write to the state attribute.
- Parameters
inputs – dictionary containing all ports and their corresponding outputs
- Returns
state – the new state of the model
- extTransition(inputs)[source]
DEFAULT External Transition Function.
Accesses state and elapsed attributes, as well as inputs through the passed dictionary. Returns the new state. The elapsed time is accessible as an attribute (i.e., self.elapsed), see Elapsed time for a detailed explanation.
Note
Should only write to the state attribute.
- Parameters
inputs – dictionary containing all ports and their corresponding outputs
- Returns
state – the new state of the model
- intTransition()[source]
DEFAULT Internal Transition Function.
Note
Should only write to the state attribute.
- Returns
state – the new state of the model
Changed in version 2.1: The elapsed attribute is no longer guaranteed to be correct as this isn’t required by the DEVS formalism.
- modelTransition(state)
DEFAULT function for Dynamic Structure DEVS, always returning False (thus indicating that no structural change is needed)
- Parameters
state – a dict that can be used to save some kind of state, this object is maintained by the kernel and will be passed each time
- Returns
bool – whether or not a structural change is necessary
- outputFnc()[source]
DEFAULT Output Function.
Accesses only state attribute. Returns the output on the different ports as a dictionary.
Note
Should not write to any attribute.
- Returns
dictionary containing output ports as keys and lists of output on that port as value
Changed in version 2.1: The elapsed attribute is no longer guaranteed to be correct as this isn’t required by the DEVS formalism.
- postActivityCalculation(prevalue)[source]
DEFAULT post-transition activity fetcher. The returned value will be passed on to the relocator and MUST be an addable (e.g. integer, float, …)
- Parameters
prevalue – the value returned from the preActivityCalculation method
- Returns
addable (float, integer, …) – passed to the relocator
- preActivityCalculation()[source]
DEFAULT pre-transition activity fetcher. The returned value is passed to the postActivityCalculation function
- Returns
something – passed to the postActivityCalculation
- removePort(port)
Remove a port (either input or output) from the model, disconnecting all of its connections.
- Parameters
port – the port to remove
- simSettings(simulator)
Modifies the simulation settings from within the model.
This function is called _before_ direct connection and distribution is performed, so the user can still access the complete hierarchy.
Note
This function is only called on the root model of the simulation, thus the model passed to the constructor of the Simulator object.
- Parameters
simulator – the simulator object on which settings can be configured
- timeAdvance()[source]
DEFAULT Time Advance Function.
Note
Should ideally be deterministic, though this is not mandatory for simulation.
- Returns
the time advance of the model
Changed in version 2.1: The elapsed attribute is no longer guaranteed to be correct as this isn’t required by the DEVS formalism.