RetentionPolicy
- class RetentionPolicy.MessageRetentionParameters(name, retainedVars)[source]
Bases:
objectStore the configuration for retained message fields.
- Parameters:
name (str) – Name of the message recorder.
retainedVars (list) – Message payload fields to retain.
- class RetentionPolicy.RetentionPolicy(rate=10000000000)[source]
Bases:
objectControl which simulation data is retained and how it is stored.
The first column of each retained message or variable array contains the corresponding simulation time in nanoseconds.
- addLogsToSim(simInstance)[source]
Create and schedule the variable loggers required by this policy.
- addRetentionFunction(function)[source]
Add a callback that returns custom data after simulation execution.
The callback receives the completed simulation instance and must return a dictionary. Its entries are merged into the retained
customdata.- Parameters:
function (callable) – Post-simulation data extraction callback.
- static addRetentionPoliciesToSim(simInstance, retentionPolicies)[source]
Add the variable loggers from a list of policies to a simulation.
Compatible duplicate requests share one logger. Requests for the same retained-data key with different rates or component ranges are rejected.
- Parameters:
simInstance – Simulation instance receiving the loggers.
retentionPolicies (list) – Retention policies defining data to log.
- addVariableLog(variableName, startIndex=None, stopIndex=None, varType=None, logRate=None)[source]
Add a module variable to the retained Monte Carlo data.
The variable identifier must use
<ModelTag>.<variableName>format and refer to a direct public or getter-backed variable on a uniquely tagged module that supports the standardlogger()API. The final period separates the model tag from the variable name, so model tags may contain periods. The complete variable is retained by default; multidimensional samples are flattened in row-major order.startIndex,stopIndex, andvarTypeare compatibility arguments for the removed legacy variable-logging API and will be removed after 2027-08-26. New code should select component columns from the retained NumPy array instead.- Parameters:
variableName (str) – Model tag and direct module variable name.
startIndex (int) – Deprecated first retained component index.
stopIndex (int) – Deprecated last retained component index, inclusive.
varType (str) – Deprecated legacy C-array type name; ignored.
logRate (int) – Minimum recording period in nanoseconds. The policy default is used when this argument is
None.
- static getDataForRetention(simInstance, retentionPolicies)[source]
Return the data selected by a list of retention policies.
The returned dictionary contains
messages,variables, andcustomsub-dictionaries. Message and variable arrays have simulation time prepended as their first column. Multidimensional variable samples are flattened in row-major order.- Parameters:
simInstance – Simulation instance containing completed recorders.
retentionPolicies (list) – Policies defining the data to retain.
- Returns:
Retained simulation data grouped by source.
- Return type:
dict
- class RetentionPolicy.VariableRetentionParameters(varName, varRate, startIndex=None, stopIndex=None, varType=None)[source]
Bases:
objectStore the configuration and runtime logger for a retained variable.
- Parameters:
varName (str) – Variable identifier in
<ModelTag>.<variableName>format.varRate (int) – Minimum variable recording period in nanoseconds.
startIndex (int) – Deprecated first retained component index.
stopIndex (int) – Deprecated last retained component index, inclusive.
varType (str) – Deprecated legacy C-array type name.