Data¶
-
class
do_mpc.data.Data(model)[source]¶ do-mpc data container. An instance of this class is created for the active do-mpc classes, e.g.
do_mpc.simulator.Simulator,do_mpc.estimator.MHE.The class is initialized with an instance of the
do_mpc.model.Modelwhich contains all information about variables (e.g. states, inputs etc.).The
Dataclass has a public API but is mostly used by other do-mpc classes, e.g. updated in the.make_stepcalls.-
__getitem__(ind)[source]¶ Query data fields. This method can be used to obtain the stored results in the
Datainstance.The full list of available fields can be inspected with:
print(data.data_fields)
The dict also denotes the dimension of each field.
The method allows for power indexing the results for the fields
_x,_u,_z,_tvp,_p,_aux,_ywhere further indices refer to the configured variables in thedo_mpc.model.Modelinstance.Example:
# Assume the following model was used (excerpt): model = do_mpc.model.Model('continuous') model.set_variable('_x', 'Temperature', shape=(5,1)) # Vector model.set_variable('_p', 'disturbance', shape=(3,3)) # Matrix model.set_variable('_u', 'heating') # scalar ... # the model was used (among others) for the MPC controller mpc = do_mpc.controller.MPC(model) ... # Query the mpc.data instance: mpc.data['_x'] # Return all states mpc.data['_x', 'Temperature'] # Return the 5 temp states mpc.data['_x', 'Temperature', :2] # Return the first 2 temp. states mpc.data['_p', 'disturbance', 0, 2] # Matrix allows for further indices # Other fields can also be queried, e.g.: mpc.data['_time'] # current time mpc.data['t_wall_S'] # optimizer runtime # These do not allow further indices.
Returns: Returns the queried data field (for all time instances) Return type: numpy.ndarray
Methods
Data.exportThe export method returns a dictionary of the stored data. Data.init_storageCreate new (empty) arrays for all variables. Data.set_metaSet meta data for the current instance of the data object. Data.updateUpdate value(s) of the data structure with key word arguments. -
This page is auto-generated. Page source is not available on Github.