AtomicDEVS

class 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
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.

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
fetchActivity(time, activities)[source]

Fetch the activity of the model up to a certain time

Parameters:
  • time – the time up to which the activity should be calculated
  • activities – dictionary containing all activities for the models
finalize(name, model_counter, model_ids, locations, select_hierarchy)[source]

Finalize the model hierarchy by doing all pre-simulation configuration

Note

Parameters model_ids and locations are updated by reference.

Parameters:
  • name – the name of the hierarchy above
  • model_counter – the model ID counter
  • model_ids – a list with all model_ids and their model
  • locations – dictionary of locations and where every model runs
  • select_hierarchy – hierarchy to perform selections in Classic DEVS
Returns:

int – the new model ID counter

flattenConnections()[source]

Flattens the pickling graph, by removing backreference from the ports.

getModelLoad(lst)[source]

Add this atomic model to the load of its location

Parameters:lst – list containing all locations and their current load
Returns:int – number of children in this subtree
getState(request_time, first_call=True)[source]

For the distributed termination condition: fetch the state of the model at a certain time

Parameters:
  • request_time – the time (including age!) for which the state should be fetched
  • first_call – whether or not this is the first call of a possible recursive call
Returns:

state – the state at that time

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.

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
revert(time, memorize)[source]

Revert the model to the specified time. All necessary cleanup for this model will be done (fossil collection).

Parameters:
  • time – the time up to which should be reverted
  • memorize – whether or not the saved states should still be kept for memoization
setGVT(gvt, activities, last_state_only)[source]

Set the GVT of the model, cleaning up the states vector as required for the time warp algorithm

Parameters:
  • gvt – the new value of the GVT
  • activities – dictionary containing all activities for the models
  • last_state_only – whether or not to only use a single state for activity
setLocation(location, force=False)[source]

Sets the location of the atomic DEVS model if it was not already set

Parameters:
  • location – the location to set
  • force – whether or not to force this location, even if another is already defined
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.

unflattenConnections()[source]

Unflattens the picking graph, by reconstructing backreferences from the ports.