MPCData¶
-
class
do_mpc.data.
MPCData
(model)[source]¶ do-mpc data container for the
do_mpc.controller.MPC
instance. This method inherits fromData
and extends it to query the MPC predictions.-
__getitem__
(ind)¶ Query data fields. This method can be used to obtain the stored results in the
Data
instance.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
,_y
where further indices refer to the configured variables in thedo_mpc.model.Model
instance.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
MPCData.export
The export method returns a dictionary of the stored data. MPCData.init_storage
Create new (empty) arrays for all variables. MPCData.prediction
Query the MPC trajectories. MPCData.set_meta
Set meta data for the current instance of the data object. MPCData.update
Update value(s) of the data structure with key word arguments. -
This page is auto-generated. Page source is not available on Github.