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 see discount.

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 also stagecost.

  • 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

objective.autonomous

If True, the objective is autonomous.

objective.discount

The discount factor of the objective.

objective.stagecost

Stage cost \(\ell(t,x,u)\).

objective.terminalcost

Terminal cost \(F(t,x)\).

objective.type

Indicating whether the objective is quadratic or nonlinear.

Methods

objective.J

Evaluate objective function of the OCP.

objective.LQP

Initialize a quadratic objective.

objective.add_termianlcost

Add terminal cost to the objective.

objective.endcosts

Evaluate termninal cost of the objective.

objective.load

Loads a nMPyC objective object from a file.

objective.save

Saving the objective to a given file with dill.

objective.stagecosts

Evaluate stage cost of the objective.