objective
- class objective(stagecost, terminalcost=None)[source]
A class used to define the objective of the optimal control problem.
The objective depends on the stage cost and optional on terminal cost and has the form
\[J(t,x,u,N) := \sum_{k=0}^{N-1} \ell(t_k,x(t_k),u(t_k)) + F(t_N,x(t_N)).\]The values of the times \(t_k\) are defined by initializing the
nmpyc.system.system
. For the slightly different form of the objective in the discounted case seediscount
.- Parameters:
stagecost (callable) – A function defining the stage cost of the optimal control problem. Has to be of the form \(\ell(t,x,u)\) or \(\ell(x,u)\) in the
autonomous
case. See alsostagecost
.terminalcost (callable, optional) – A function defining the terminal cost of the optimal control problem. Has to be of the form \(F(t,x)\) or \(F(x)\) in the autonomous case. If None, no terminal cost is added. The default is None. See also
terminalcost
.
Attributes
If True, the objective is autonomous.
The discount factor of the objective.
Stage cost \(\ell(t,x,u)\).
Terminal cost \(F(t,x)\).
Indicating whether the objective is quadratic or nonlinear.
Methods
Evaluate objective function of the OCP.
Initialize a quadratic objective.
Add terminal cost to the objective.
Evaluate termninal cost of the objective.
Loads a nMPyC objective object from a file.
Saving the objective to a given file with dill.
Evaluate stage cost of the objective.