CoupledDEVS User Interface

class pypdevs.DEVS.CoupledDEVS(name=None)[source]

Abstract base class for all coupled-DEVS descriptive classes.

__init__(name=None)[source]

Constructor.

Parameters

name – the name of the coupled model, can be None for 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

addSubModel(model, location=None)[source]

Adds a specified model to the current coupled model as its child. This is the function that must be used to make distributed simulation possible.

Parameters
  • model – the model to be added as a child

  • location – the location at which the child must run

Returns

model – the model that was created as a child

Changed in version 2.1.3: model can no longer be a string, this was previously a lot more efficient in partial distribution, though this functionality was removed together with the partial distribution functionality.

connectPorts(p1, p2, z=None)[source]

Connects two ports together. The coupling is to begin at p1 and to end at p2.

Parameters
  • p1 – the port at the start of the new connection

  • p2 – the port at the end of the new connection

  • z – the translation function for the events either input-to-input, output-to-input or output-to-output.

disconnectPorts(p1, p2)[source]

Disconnect two ports

Note

If these ports are connected multiple times, only one of them will be removed.

Parameters
  • p1 – the port at the start of the connection

  • p2 – the port at the end of the connection

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

removePort(port)

Remove a port (either input or output) from the model, disconnecting all of its connections.

Parameters

port – the port to remove

removeSubModel(model)[source]

Remove a specified model from the current coupled model, only callable while in a simulation.

Parameters

model – the model to remove as a child

select(imm_children)[source]

DEFAULT select function, only used when using Classic DEVS simulation

Parameters

imm_children – list of all children that want to transition

Returns

child – a single child that is allowed to transition

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