control.optimal.create_mpc_iosystem
- control.optimal.create_mpc_iosystem(sys, timepts, integral_cost=None, trajectory_constraints=None, terminal_cost=None, terminal_constraints=None, log=False, **kwargs)[source]
Create a model predictive I/O control system.
This function creates an input/output system that implements a model predictive control for a system given the time points, cost function and constraints that define the finite-horizon optimization that should be carried out at each state.
- Parameters
- sys
InputOutputSystem
I/O system for which the optimal input will be computed.
- timepts1D array_like
List of times at which the optimal input should be computed.
- integral_cost (or cost)callable
Function that returns the integral cost given the current state and input. Called as
integral_cost(x, u)
.- trajectory_constraints (or constraints)list of tuples, optional
List of constraints that should hold at each point in the time vector. See
solve_optimal_trajectory
for more details.- terminal_costcallable, optional
Function that returns the terminal cost given the final state and input. Called as terminal_cost(x, u).
- terminal_constraintslist of tuples, optional
List of constraints that should hold at the end of the trajectory. Same format as
constraints
.- **kwargs
Additional parameters, passed to
scipy.optimize.minimize
andNonlinearIOSystem
.
- sys
- Returns
- ctrl
InputOutputSystem
An I/O system taking the current state of the model system and returning the current input to be applied that minimizes the cost function while satisfying the constraints.
- ctrl
- Other Parameters
- inputs, outputs, statesint or list of str, optional
Set the names of the inputs, outputs, and states, as described in
InputOutputSystem
.- logbool, optional
If True, turn on logging messages (using Python logging module). Use
logging.basicConfig
to enable logging output (e.g., to a file).- namestring, optional
System name (used for specifying signals). If unspecified, a generic name ‘sys[id]’ is generated with a unique integer id.
Notes
Additional keyword parameters can be used to fine-tune the behavior of the underlying optimization and integration functions. See
OptimalControlProblem
for more information.