Stores and evaluates the objective function of optimal control problems. More...
#include <objective.hpp>
Protected Attributes | |
LsqExternElements | cgExternLsqElements |
LsqExternElements | cgExternLsqEndTermElements |
LsqElements | cgLsqElements |
LsqElements | cgLsqEndTermElements |
LsqLinearElements | cgLsqLinearElements |
LSQEndTerm ** | lsqEndTerm |
LSQTerm ** | lsqTerm |
MayerTerm ** | mayerTerm |
uint | nEndLSQ |
uint | nLSQ |
uint | nMayer |
Protected Attributes inherited from LagrangeTerm | |
Grid | grid |
Expression ** | lagrangeFcn |
int | nLagrangeTerms |
Stores and evaluates the objective function of optimal control problems.
The class Objective is class is designed to formulate objecive functionals that can be part of an optimal control problem (OCP). Mainly, an objective can have additive terms with different structures that can be added by using various routines that are implemented in this class
Note that a this class is derived from the class LagrangeTerm while it has Mayer and LSQ-Terms as a member. The reason for this assymmetry is that a Lagrange - term will be reformulated as a Mayer term as soon as the function init( ... ) is called. (I.e. the class LagrangeTerm is only used a kind of temporary memory to store Expressions that are added by the user.)
\author Boris Houska, Hans Joachim Ferreau, Milan Vukov
Definition at line 123 of file objective.hpp.
BEGIN_NAMESPACE_ACADO Objective::Objective | ( | ) |
Default constructor.
Definition at line 49 of file objective.cpp.
Objective::Objective | ( | const Grid & | grid_ | ) |
Default constructor.
Definition at line 62 of file objective.cpp.
Objective::Objective | ( | const Objective & | rhs | ) |
Copy constructor (deep copy).
Definition at line 84 of file objective.cpp.
|
virtual |
Destructor.
Definition at line 124 of file objective.cpp.
returnValue Objective::addLSQ | ( | const MatrixVariablesGrid * | S_, |
const Function & | h, | ||
const VariablesGrid * | r_ | ||
) |
Adds an Least Square term of the general form
0.5* sum_i || h(t_i,x(t_i),u(t_i),p(t_i),...) - r_i ||^2_S_i
Here, the matrices S_i and the reference vectors r_i should be given
in MatrixVariablesGrid and VariablesGrid format respectively. If S_ is
a NULL-pointer the matrices S_i will be unit matrices. If r_ is a
a NULL-pointer the reference will be equal to zero by default.
S_ | the weighting matrix |
h | the LSQ function |
r_ | the reference vectors |
Definition at line 155 of file objective.cpp.
returnValue Objective::addLSQ | ( | const DMatrix & | S, |
const Function & | h | ||
) |
Definition at line 644 of file objective.cpp.
returnValue Objective::addLSQ | ( | const DMatrix & | S, |
const std::string & | h | ||
) |
Definition at line 658 of file objective.cpp.
returnValue Objective::addLSQ | ( | const BMatrix & | S, |
const Function & | h | ||
) |
Definition at line 672 of file objective.cpp.
returnValue Objective::addLSQ | ( | const BMatrix & | S, |
const std::string & | h | ||
) |
Definition at line 686 of file objective.cpp.
returnValue Objective::addLSQEndTerm | ( | const DMatrix & | S, |
const Function & | m, | ||
const DVector & | r | ||
) |
Adds an Least Square term that is only evaluated at the end:
0.5* || m(T,x(T),p,...) - r ||^2_S
where S is a weighting matrix, r a reference vector and T the time
at the last objective grid point.
S | a weighting matrix |
m | the LSQ-Function |
r | the reference |
Definition at line 175 of file objective.cpp.
returnValue Objective::addLSQEndTerm | ( | const DMatrix & | S, |
const Function & | h | ||
) |
Definition at line 651 of file objective.cpp.
returnValue Objective::addLSQEndTerm | ( | const DMatrix & | S, |
const std::string & | h | ||
) |
Definition at line 665 of file objective.cpp.
returnValue Objective::addLSQEndTerm | ( | const BMatrix & | S, |
const Function & | h | ||
) |
Definition at line 679 of file objective.cpp.
returnValue Objective::addLSQEndTerm | ( | const BMatrix & | S, |
const std::string & | h | ||
) |
Definition at line 693 of file objective.cpp.
returnValue Objective::addLSQLinearTerms | ( | const DVector & | Slx, |
const DVector & | Slu | ||
) |
Definition at line 700 of file objective.cpp.
returnValue Objective::addLSQLinearTerms | ( | const BVector & | Slx, |
const BVector & | Slu | ||
) |
Definition at line 707 of file objective.cpp.
|
inline |
Adds an expression for the Mayer term.
|
inline |
returnValue Objective::evaluate | ( | const OCPiterate & | x | ) |
Evaluates the objective with all its terms.
Definition at line 254 of file objective.cpp.
returnValue Objective::evaluateSensitivities | ( | ) |
Evaluates the objective gradient. (please use evaluate to specify
the evaluation point)
Definition at line 271 of file objective.cpp.
returnValue Objective::evaluateSensitivities | ( | BlockMatrix & | hessian | ) |
Evaluates the objective gradient and the associated Hessian.
(please use evaluate to specify the evaluation point)
Definition at line 295 of file objective.cpp.
returnValue Objective::evaluateSensitivitiesGN | ( | BlockMatrix & | hessian | ) |
Evaluates the objective gradient. (please use evaluate to specify
the evaluation point)
in addition a Gauss-Newton hessian approximation is provided
Definition at line 319 of file objective.cpp.
|
virtual |
Returns the result for the backward sensitivities in BlockMatrix form.
D | the result for the forward sensitivi- ties |
order | the order |
Definition at line 472 of file objective.cpp.
|
virtual |
Returns the result for the forward sensitivities in BlockMatrix form.
D | the result for the forward sensitivi- ties |
order | the order |
Definition at line 433 of file objective.cpp.
returnValue Objective::getLagrangeTerm | ( | uint | index, |
Function & | lagrangeTerm | ||
) | const |
Definition at line 633 of file objective.cpp.
returnValue Objective::getLSQEndTerms | ( | LsqElements & | _elements | ) | const |
Definition at line 586 of file objective.cpp.
returnValue Objective::getLSQEndTerms | ( | LsqExternElements & | _elements | ) | const |
Definition at line 600 of file objective.cpp.
returnValue Objective::getLSQLinearTerms | ( | LsqLinearElements & | _elements | ) | const |
Definition at line 607 of file objective.cpp.
returnValue Objective::getLSQTerms | ( | LsqElements & | _elements | ) | const |
Definition at line 579 of file objective.cpp.
returnValue Objective::getLSQTerms | ( | LsqExternElements & | _elements | ) | const |
Definition at line 593 of file objective.cpp.
returnValue Objective::getMayerTerm | ( | uint | index, |
Function & | mayerTerm | ||
) | const |
Definition at line 620 of file objective.cpp.
|
inline |
Returns the number of parameters
|
inline |
Returns the number of controls
uint Objective::getNumLagrangeTerms | ( | ) | const |
Definition at line 627 of file objective.cpp.
uint Objective::getNumMayerTerms | ( | ) | const |
Definition at line 614 of file objective.cpp.
|
inline |
Returns the number of disturbances
|
inline |
Returns the number of differential states
|
inline |
Returns the number of algebraic states
|
virtual |
Returns the result for the residuum of the bounds.
Definition at line 402 of file objective.cpp.
|
inline |
Asks the objective whether all terms have Least-Square form. If the
returned answer is "BT_TRUE", the computation of Gauss-Newton hessian
approximation is supported.
returnValue Objective::init | ( | const Grid & | grid_ | ) |
returnValue Objective::init | ( | const int | nStages, |
const int | nTransitions, | ||
DifferentialEquation ** | fcn, | ||
Transition * | transitions, | ||
Constraint * | constraint_ | ||
) |
Initializes the objective and reformulates Lagrange-Terms if
there are any. The RHS function that is passed in the argument
will be augmented by one component if there is a Lagrange term. If
the RHS function is NULL but there is Lagrange term then the
routine will allocate memory for fcn and add one component !!
nStages | the number of stages |
nTransitions | the number of transitions |
fcn | the right-hand side functions |
transitions | the transition functions |
constraint_ | the constraint (to be reformulated) |
Definition at line 511 of file objective.cpp.
|
inline |
returns whether the constraint element is affine.
|
inline |
returns whether the objective is convex.
BooleanType Objective::isEmpty | ( | ) | const |
Returns whether or not the objective is empty.
Definition at line 571 of file objective.cpp.
|
inline |
returns whether the objective is quadratic.
Assignment operator (deep copy).
Definition at line 190 of file objective.cpp.
|
virtual |
Define a backward seed in form of a block matrix.
seed | the seed matrix |
order | the order of the seed. |
Definition at line 370 of file objective.cpp.
|
virtual |
Define a forward seed in form of a block matrix.
xSeed_ | the seed in x -direction |
xaSeed_ | the seed in xa-direction |
pSeed_ | the seed in p -direction |
uSeed_ | the seed in u -direction |
wSeed_ | the seed in w -direction |
order | the order of the seed. |
Definition at line 341 of file objective.cpp.
|
inline |
overwrites the reference (only for LSQ tracking objectives)
|
virtual |
Defines the first order backward seed to be
a unit matrix.
Definition at line 394 of file objective.cpp.
|
protected |
Definition at line 482 of file objective.hpp.
|
protected |
Definition at line 483 of file objective.hpp.
|
protected |
Definition at line 479 of file objective.hpp.
|
protected |
Definition at line 480 of file objective.hpp.
|
protected |
Definition at line 485 of file objective.hpp.
|
protected |
The Least Square End Terms.
Definition at line 472 of file objective.hpp.
|
protected |
The Least Square Terms.
Definition at line 471 of file objective.hpp.
|
protected |
The Mayer Terms.
Definition at line 473 of file objective.hpp.
|
protected |
number of end LSQ terms
Definition at line 476 of file objective.hpp.
|
protected |
number of LSQ terms
Definition at line 475 of file objective.hpp.
|
protected |
number of Mayer terms
Definition at line 477 of file objective.hpp.