Utility functions¶
Common utility functions used in PyPDEVS
- exception pypdevs.util.DEVSException(message='not specified in source')[source]¶
DEVS specific exceptions
- exception pypdevs.util.QuickStopException[source]¶
An exception specifically to stop the simulation and perform a relocation ASAP
- pypdevs.util.addDict(destination, source)[source]¶
Adds 2 dicts together in the first dictionary
- Parameters
destination – the destination dictionary to merge the source into
source – the dictionary to merge in
Note
the destination parameter will be modified and no return value is provided. The source parameter is not modified.
- pypdevs.util.allZeroDict(source)[source]¶
Checks whether or not a dictionary contains only 0 items
- Parameters
source – a dictionary to test
- Returns
bool – whether or not all entries in the dictionary are equal to zero
- pypdevs.util.broadcastCancel()[source]¶
Cancel the broadcast receiving in a nice way, to prevent MPI errors
- pypdevs.util.broadcastModel(data, proxies, allow_reinit, scheduler_locations)[source]¶
Broadcast the model to simulate to the provided proxies
- Parameters
data – data to be broadcasted to everywhere
proxies – iterable containing all proxies
allowReinit – should reinitialisation be allowed
- pypdevs.util.constructGraph(models)[source]¶
Construct a graph from the model, containing the weight (= number of messages) on a connection between two components.
- Parameters
models – the root model to use for graph construction
- Returns
dict – all from-to edges with their number of events
- pypdevs.util.easyCommand(function, args)[source]¶
Easy wrapper to create a string representation of function calls
- Parameters
function – the function should be called
args – list of all the arguments for the function
- Returns
str – string representation to be passed to exec
- pypdevs.util.runTraceAtController(server, uid, model, args)[source]¶
Run a trace command on our version that is running at the constroller
- Parameters
server – the server to ask the proxy from
uid – the UID of the tracer (identical throughout the simulation)
model – the model that transitions
args – the arguments for the trace function