nutopy.ocp

class OCP(f0fun, ffun)[source]

Bases: object

Parameters
  • f0fun (callable) – Function defining the Lagrange cost

  • ffun (callable) – Function defining the dynamics

Returns

An Optimal Control Problem (Lagrange type) object

f0(t, x, u, *args, **kwargs)[source]
Parameters
  • t (float) – Time

  • x (array) – State

  • u (array) – Control

Returns

The value of the Lagrange cost

f(t, x, u, *args, **kwargs)[source]
Parameters
  • t (float) – Time

  • x (array) – State

  • u (array) – Control

Returns

The value of the dynamics

class Hamiltonian(hfun, tvars=None)[source]

Bases: object

Parameters

hfun (callable) – Hamiltonian function (must be tensorized up to order two)

Returns

A Hamiltonian object

property tvars
property tvars_args
classmethod fromOCP(o, ufun, p0=- 1.0)[source]
Parameters
  • o (OCP) – Optimal control problem

  • ufun (callable) – Dynamic feedback control

  • p0 (float) – Value of cost multiplier (default is -1, for normal case)

Returns

Generates a Hamiltonian from OCP and dynamic feedback control

vec(t, x, p, *args, **kwargs)[source]
Parameters
  • t (float) – Time

  • x (array) – State

  • p (array) – Costate

Returns

Symplectic gradient of the Hamiltonian. Tensorized to order 1.

class Flow(h, options=None)[source]

Bases: object

Parameters
  • h (Hamiltonian) – Hamiltonian object defining the flow

  • options (dict) – Dictionary of options for the IVP solver

Returns

The Hamiltonian flow. The optional options are passed to the IVP solver and can be set dynamically.

property h
property options
exception Error[source]

Bases: Exception

Exceptions of the module:

Unimplemented IVPError

exception Unimplemented[source]

Bases: nutopy.ocp.Error

Raised when trying to use a (not yet) implemented feature

exception IVPError(status, message)[source]

Bases: nutopy.ocp.Error

Parameters
  • status (int) – Termination status from IVP

  • message (string) – Explanation from IVP

Returns

An exception raised when IVP integration is not successful