Utility functions¶
Common utility functions used in PyPDEVS
-
exception
util.
QuickStopException
[source]¶ An exception specifically to stop the simulation and perform a relocation ASAP
-
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.
-
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
-
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
-
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
-
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
-
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