MPC¶
-
class
do_mpc.controller.MPC(model)[source]¶ Model predictive controller.
For general information on model predictive control, please read our background article.
The MPC controller extends the
do_mpc.optimizer.Optimizerbase class (which is also used for thedo_mpc.estimator.MHEestimator).Use this class to configure and run the MPC controller based on a previously configured
do_mpc.model.Modelinstance.Configuration and setup:
Configuring and setting up the MPC controller involves the following steps:
- Use
set_param()to configure theMPCinstance. - Set the objective of the control problem with
set_objective()andset_rterm() - Set upper and lower bounds with
bounds(optional). - Set further (non-linear) constraints with
set_nl_cons()(optional). - Use the low-level API (
get_p_template()andset_p_fun()) or high level API (set_uncertainty_values()) to create scenarios for robust MPC (optional). - Finally, call
setup().
Warning
Before running the controller, make sure to supply a valid initial guess for all optimized variables (states, algebraic states and inputs). Simply set the initial values of
x0,z0andu0and then callset_initial_guess().To take full control over the initial guess, modify the values of
opt_x_num.During runtime call
make_step()with the current state \(x\) to obtain the optimal control input \(u\).Attributes
MPC.boundsQuery and set bounds of the optimization variables. MPC.opt_p_numFull MPC parameter vector. MPC.opt_x_numFull MPC solution and initial guess. MPC.scalingQuery and set scaling of the optimization variables. MPC.t0Current time marker of the class. MPC.terminal_boundsQuery and set the terminal bounds for the states. MPC.u0Initial input and current iterate. MPC.x0Initial state and current iterate. MPC.z0Initial algebraic state and current iterate. Methods
MPC.get_p_templateObtain output template for set_p_fun().MPC.get_tvp_templateObtain output template for set_tvp_fun().MPC.make_stepMain method of the class during runtime. MPC.reset_historyReset the history of the optimizer. MPC.set_initial_guessInitial guess for optimization variables. MPC.set_nl_consIntroduce new constraint to the class. MPC.set_objectiveSets the objective of the optimal control problem (OCP). MPC.set_p_funSet function which returns parameters. MPC.set_paramSet the parameters of the MPCclass.MPC.set_rtermSet the penality factor for the inputs. MPC.set_tvp_funSet function which returns time-varying parameters. MPC.set_uncertainty_valuesDefine scenarios for the uncertain parameters. MPC.setupSetup the MPC class. MPC.solveSolves the optmization problem. - Use
This page is auto-generated. Page source is not available on Github.