set_tvp_fun¶
Class method.

do_mpc.simulator.Simulator.
set_tvp_fun
(self, tvp_fun)¶ Method to set the function which returns the values of the timevarying parameters. This function must return a CasADi structure which can be obtained with
get_tvp_template()
.In the
do_mpc.model.Model
we have defined the following parameters:a = model.set_variable('_tvp', 'a')
The integrate the ODE or evaluate the discrete dynamics, the simulator needs to obtain the numerical values of these parameters at each timestep. In the most general case, these values can change, which is why a function must be supplied that can be evaluted at each timestep to obtain the current values.
dompc requires this function to have a specific return structure which we obtain first by calling:
tvp_template = simulator.get_tvp_template()
The timevarying parameter function can look something like this:
def tvp_fun(t_now): tvp_template['a'] = 3 return tvp_template simulator.set_tvp_fun(tvp_fun)
which results in constant parameters.
Note
From the perspective of the simulator there is no difference between timevarying parameters and regular parameters. The difference is important only for the MPC controller and MHE estimator. These methods consider a finite sequence of future / past information, e.g. the weather, which can change over time. Parameters, on the other hand, are constant over the entire horizon.
Parameters: tvp_fun (function) – Function which gives the values of the timevarying parameters
Raises:  assertion – tvp_fun has incorrect return type.
 assertion – Incorrect output of tvp_fun. Use get_tvp_template to obtain the required structure.
Returns: None
Return type: None
This page is autogenerated. Page source is not available on Github.