ACADO Toolkit
1.2.0beta
Toolkit for Automatic Control and Dynamic Optimization
|
Stores and evaluates LSQ mayer terms within optimal control problems. More...
#include <lsq_end_term.hpp>
Public Member Functions | |
LSQEndTerm () | |
Default constructor. | |
LSQEndTerm (const Grid &grid_, const Matrix &S_, const Function &m_, const Vector &r_) | |
Default constructor. | |
LSQEndTerm (const LSQEndTerm &rhs) | |
Copy constructor (deep copy). | |
virtual | ~LSQEndTerm () |
Destructor. | |
LSQEndTerm & | operator= (const LSQEndTerm &rhs) |
Assignment operator (deep copy). | |
returnValue | init (const Grid &grid_, const Matrix &S_, const Function &m_, const Vector &r_) |
returnValue | evaluate (const OCPiterate &x) |
returnValue | evaluateSensitivities (BlockMatrix *hessian) |
Evaluates the objective gradient contribution from this term and computes the corresponding exact hessian. | |
returnValue | evaluateSensitivitiesGN (BlockMatrix *GNhessian) |
Evaluates the objective gradient contribution from this term and computes the corresponding GN hessian approximation for the case that GNhessian != 0. | |
BooleanType | isAffine () |
returns whether the constraint element is affine. | |
BooleanType | isQuadratic () |
returns whether the constraint element is convex. | |
BooleanType | isConvex () |
returns whether the constraint element is convex. | |
returnValue | setReference (const Vector &ref) |
overwrites the reference vector r | |
returnValue | setGrid (const Grid &grid_) |
Sets the discretization grid. | |
returnValue | init (const OCPiterate &x) |
Initializes the Objective Element: The dimensions and index lists. | |
virtual returnValue | setForwardSeed (BlockMatrix *xSeed_, BlockMatrix *xaSeed_, BlockMatrix *pSeed_, BlockMatrix *uSeed_, BlockMatrix *wSeed_, int order) |
Define a forward seed in form of a block matrix. | |
virtual returnValue | setBackwardSeed (BlockMatrix *seed, int order) |
Define a backward seed in form of a block matrix. | |
virtual returnValue | getObjectiveValue (double &objectiveValue) |
Returns the result for the residuum. | |
virtual returnValue | getForwardSensitivities (BlockMatrix *D, int order) |
Returns the result for the forward sensitivities in BlockMatrix form. | |
virtual returnValue | getBackwardSensitivities (BlockMatrix *D, int order) |
Returns the result for the backward sensitivities in BlockMatrix form. | |
int | getNX () const |
Returns the number of differential states . | |
int | getNXA () const |
Returns the number of algebraic states . | |
int | getNP () const |
Returns the number of parameters . | |
int | getNU () const |
Returns the number of controls . | |
int | getNW () const |
Returns the number of disturbances . | |
returnValue | getFunction (Function &_function) |
Returns the element's function . | |
Protected Member Functions | |
Grid | getGrid () const |
returns the constraint grid | |
Protected Attributes | |
Matrix | S |
a symmetric weighting matrix | |
Vector | r |
a tracking reference | |
double * | S_h_res |
specific intermediate results to be stored for backward differentiation | |
Grid | grid |
the objective grid | |
Function | fcn |
the function | |
EvaluationPoint | z |
the evaluation point | |
EvaluationPoint | JJ |
int * | y_index |
index lists | |
int | t_index |
time index | |
int | nx |
number of diff. | |
int | na |
number of alg. | |
int | nu |
number of controls | |
int | np |
number of parameters | |
int | nw |
number of disturbances | |
int | ny |
:= nx+na+nu+np+nw | |
BlockMatrix * | xSeed |
the 1st order forward seed in x-direction | |
BlockMatrix * | xaSeed |
the 1st order forward seed in x-direction | |
BlockMatrix * | pSeed |
the 1st order forward seed in p-direction | |
BlockMatrix * | uSeed |
the 1st order forward seed in u-direction | |
BlockMatrix * | wSeed |
the 1st order forward seed in w-direction | |
BlockMatrix * | bSeed |
the 1st order backward seed | |
BlockMatrix * | xSeed2 |
the 2nd order forward seed in x-direction | |
BlockMatrix * | xaSeed2 |
the 2nd order forward seed in x-direction | |
BlockMatrix * | pSeed2 |
the 2nd order forward seed in p-direction | |
BlockMatrix * | uSeed2 |
the 2nd order forward seed in u-direction | |
BlockMatrix * | wSeed2 |
the 2nd order forward seed in w-direction | |
BlockMatrix * | bSeed2 |
the 2nd order backward seed | |
double | obj |
the objective value | |
BlockMatrix | dForward |
the first order forward derivatives | |
BlockMatrix | dBackward |
the first order backward derivatives |
The class LSQEndTerm allows to manage and evaluate least square objective mayer terms
of the general form:
0.5* || S * ( m(T,x(T),p(T),...) - r ) ||^2_2
Here the T is the time at the last grid point of the objective grid.
References S_h_res.
LSQEndTerm::LSQEndTerm | ( | const Grid & | grid_, |
const Matrix & | S_, | ||
const Function & | m_, | ||
const Vector & | r_ | ||
) |
grid_ | the objective grid |
S_ | the weighting matrix |
m_ | the LSQ function |
r_ | the reference vector |
References ObjectiveElement::fcn, Function::getDim(), r, S, and S_h_res.
LSQEndTerm::LSQEndTerm | ( | const LSQEndTerm & | rhs | ) |
References ObjectiveElement::fcn, Function::getDim(), r, S, and S_h_res.
LSQEndTerm::~LSQEndTerm | ( | ) | [virtual] |
References S_h_res.
returnValue LSQEndTerm::evaluate | ( | const OCPiterate & | x | ) |
returnValue LSQEndTerm::evaluateSensitivities | ( | BlockMatrix * | hessian | ) |
References ACADOERROR, evaluateSensitivitiesGN(), and RET_NOT_IMPLEMENTED_YET.
Referenced by Objective::evaluateSensitivities().
returnValue LSQEndTerm::evaluateSensitivitiesGN | ( | BlockMatrix * | GNhessian | ) |
References ACADOERROR, ACADOWARNING, Function::AD_backward(), BlockMatrix::addDense(), ObjectiveElement::bSeed, ObjectiveElement::dBackward, ObjectiveElement::fcn, Function::getDim(), VectorspaceElement::getDim(), Function::getNumberOfVariables(), Grid::getNumPoints(), BlockMatrix::getNumRows(), BlockMatrix::getSubBlock(), ObjectiveElement::grid, BlockMatrix::init(), Matrix::init(), ObjectiveElement::na, ObjectiveElement::np, ObjectiveElement::nu, ObjectiveElement::nw, ObjectiveElement::nx, ObjectiveElement::pSeed, ObjectiveElement::pSeed2, RET_NOT_IMPLEMENTED_YET, RET_WRONG_DEFINITION_OF_SEEDS, S, S_h_res, BlockMatrix::setDense(), VectorspaceElement::setZero(), SUCCESSFUL_RETURN, ObjectiveElement::uSeed, ObjectiveElement::uSeed2, ObjectiveElement::wSeed, ObjectiveElement::wSeed2, ObjectiveElement::xSeed, ObjectiveElement::xSeed2, and ObjectiveElement::y_index.
Referenced by evaluateSensitivities(), and Objective::evaluateSensitivitiesGN().
returnValue ObjectiveElement::getBackwardSensitivities | ( | BlockMatrix * | D, |
int | order | ||
) | [virtual, inherited] |
D | the result for the forward sensitivi- ties |
order | the order |
References ACADOERROR, ACADOWARNING, ASSERT, ObjectiveElement::dBackward, RET_INPUT_OUT_OF_RANGE, RET_NOT_IMPLEMENTED_YET, and SUCCESSFUL_RETURN.
Referenced by Objective::getBackwardSensitivities().
returnValue ObjectiveElement::getForwardSensitivities | ( | BlockMatrix * | D, |
int | order | ||
) | [virtual, inherited] |
D | the result for the forward sensitivi- ties |
order | the order |
References ACADOERROR, ACADOWARNING, ASSERT, ObjectiveElement::dForward, RET_INPUT_OUT_OF_RANGE, RET_NOT_IMPLEMENTED_YET, and SUCCESSFUL_RETURN.
Referenced by Objective::getForwardSensitivities().
returnValue ObjectiveElement::getFunction | ( | Function & | _function | ) | [inline, inherited] |
References ObjectiveElement::fcn, and SUCCESSFUL_RETURN.
Grid ObjectiveElement::getGrid | ( | ) | const [inline, protected, inherited] |
References ObjectiveElement::grid.
int ObjectiveElement::getNP | ( | ) | const [inline, inherited] |
References ObjectiveElement::fcn, and Function::getNP().
int ObjectiveElement::getNU | ( | ) | const [inline, inherited] |
References ObjectiveElement::fcn, and Function::getNU().
int ObjectiveElement::getNW | ( | ) | const [inline, inherited] |
References ObjectiveElement::fcn, and Function::getNW().
int ObjectiveElement::getNX | ( | ) | const [inline, inherited] |
References ObjectiveElement::fcn, and Function::getNX().
int ObjectiveElement::getNXA | ( | ) | const [inline, inherited] |
References ObjectiveElement::fcn, and Function::getNXA().
returnValue ObjectiveElement::getObjectiveValue | ( | double & | objectiveValue | ) | [virtual, inherited] |
objectiveValue | the objective value |
References ObjectiveElement::obj, and SUCCESSFUL_RETURN.
Referenced by Objective::getObjectiveValue().
BEGIN_NAMESPACE_ACADO returnValue LSQEndTerm::init | ( | const Grid & | grid_, |
const Matrix & | S_, | ||
const Function & | m_, | ||
const Vector & | r_ | ||
) | [inline] |
grid_ | the objective grid |
S_ | the weighting matrix |
m_ | the LSQ function |
r_ | the reference vectors |
References ObjectiveElement::fcn, ObjectiveElement::grid, r, S, and SUCCESSFUL_RETURN.
Referenced by evaluate().
returnValue ObjectiveElement::init | ( | const OCPiterate & | x | ) | [inherited] |
References ObjectiveElement::fcn, MatrixVariablesGrid::getNumValues(), Function::index(), EvaluationPoint::init(), ObjectiveElement::JJ, ObjectiveElement::na, ObjectiveElement::np, ObjectiveElement::nu, ObjectiveElement::nw, ObjectiveElement::nx, ObjectiveElement::ny, OCPiterate::p, SUCCESSFUL_RETURN, ObjectiveElement::t_index, OCPiterate::u, VT_ALGEBRAIC_STATE, VT_CONTROL, VT_DIFFERENTIAL_STATE, VT_DISTURBANCE, VT_PARAMETER, VT_TIME, OCPiterate::w, OCPiterate::x, OCPiterate::xa, ObjectiveElement::y_index, and ObjectiveElement::z.
Referenced by LSQTerm::evaluate().
BooleanType LSQEndTerm::isAffine | ( | ) | [inline] |
BooleanType LSQEndTerm::isConvex | ( | ) | [inline] |
BooleanType LSQEndTerm::isQuadratic | ( | ) | [inline] |
References BT_FALSE, ObjectiveElement::fcn, and Function::isAffine().
LSQEndTerm & LSQEndTerm::operator= | ( | const LSQEndTerm & | rhs | ) |
References ObjectiveElement::fcn, Function::getDim(), r, S, and S_h_res.
returnValue ObjectiveElement::setBackwardSeed | ( | BlockMatrix * | seed, |
int | order | ||
) | [virtual, inherited] |
seed | the seed matrix |
order | the order of the seed. |
References ACADOWARNING, ObjectiveElement::bSeed, ObjectiveElement::bSeed2, RET_INPUT_OUT_OF_RANGE, and SUCCESSFUL_RETURN.
Referenced by Objective::setBackwardSeed().
returnValue ObjectiveElement::setForwardSeed | ( | BlockMatrix * | xSeed_, |
BlockMatrix * | xaSeed_, | ||
BlockMatrix * | pSeed_, | ||
BlockMatrix * | uSeed_, | ||
BlockMatrix * | wSeed_, | ||
int | order | ||
) | [virtual, inherited] |
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. |
References ACADOWARNING, ObjectiveElement::pSeed, ObjectiveElement::pSeed2, RET_INPUT_OUT_OF_RANGE, SUCCESSFUL_RETURN, ObjectiveElement::uSeed, ObjectiveElement::uSeed2, ObjectiveElement::wSeed, ObjectiveElement::wSeed2, ObjectiveElement::xaSeed, ObjectiveElement::xaSeed2, ObjectiveElement::xSeed, and ObjectiveElement::xSeed2.
Referenced by Objective::setForwardSeed().
BEGIN_NAMESPACE_ACADO returnValue ObjectiveElement::setGrid | ( | const Grid & | grid_ | ) | [inline, inherited] |
Reimplemented in LSQTerm.
References ObjectiveElement::grid, and SUCCESSFUL_RETURN.
Referenced by Objective::addLSQEndTerm().
returnValue LSQEndTerm::setReference | ( | const Vector & | ref | ) | [inline] |
References r, and SUCCESSFUL_RETURN.
BlockMatrix* ObjectiveElement::bSeed [protected, inherited] |
BlockMatrix* ObjectiveElement::bSeed2 [protected, inherited] |
BlockMatrix ObjectiveElement::dBackward [protected, inherited] |
BlockMatrix ObjectiveElement::dForward [protected, inherited] |
Function ObjectiveElement::fcn [protected, inherited] |
Referenced by MayerTerm::evaluate(), LSQTerm::evaluate(), evaluate(), MayerTerm::evaluateSensitivities(), LSQTerm::evaluateSensitivities(), LSQTerm::evaluateSensitivitiesGN(), evaluateSensitivitiesGN(), ObjectiveElement::getFunction(), ObjectiveElement::getNP(), ObjectiveElement::getNU(), ObjectiveElement::getNW(), ObjectiveElement::getNX(), ObjectiveElement::getNXA(), MayerTerm::init(), init(), ObjectiveElement::init(), LSQTerm::isQuadratic(), isQuadratic(), LSQEndTerm(), LSQTerm::LSQTerm(), MayerTerm::MayerTerm(), ObjectiveElement::ObjectiveElement(), ObjectiveElement::operator=(), LSQTerm::operator=(), operator=(), and LSQTerm::setGrid().
Grid ObjectiveElement::grid [protected, inherited] |
Referenced by MayerTerm::evaluate(), LSQTerm::evaluate(), evaluate(), MayerTerm::evaluateSensitivities(), LSQTerm::evaluateSensitivities(), LSQTerm::evaluateSensitivitiesGN(), evaluateSensitivitiesGN(), ObjectiveElement::getGrid(), MayerTerm::init(), init(), LSQTerm::LSQTerm(), ObjectiveElement::ObjectiveElement(), ObjectiveElement::operator=(), LSQTerm::operator=(), ObjectiveElement::setGrid(), LSQTerm::setGrid(), LSQTerm::setReference(), and LSQTerm::~LSQTerm().
EvaluationPoint ObjectiveElement::JJ [protected, inherited] |
Referenced by MayerTerm::evaluateSensitivities(), and ObjectiveElement::init().
int ObjectiveElement::na [protected, inherited] |
int ObjectiveElement::np [protected, inherited] |
int ObjectiveElement::nu [protected, inherited] |
int ObjectiveElement::nw [protected, inherited] |
int ObjectiveElement::nx [protected, inherited] |
int ObjectiveElement::ny [protected, inherited] |
Referenced by ObjectiveElement::init(), ObjectiveElement::ObjectiveElement(), and ObjectiveElement::operator=().
double ObjectiveElement::obj [protected, inherited] |
BlockMatrix* ObjectiveElement::pSeed [protected, inherited] |
BlockMatrix* ObjectiveElement::pSeed2 [protected, inherited] |
Vector LSQEndTerm::r [protected] |
Referenced by evaluate(), init(), LSQEndTerm(), operator=(), and setReference().
Matrix LSQEndTerm::S [protected] |
Referenced by evaluate(), evaluateSensitivitiesGN(), init(), LSQEndTerm(), and operator=().
double* LSQEndTerm::S_h_res [protected] |
Referenced by evaluate(), evaluateSensitivitiesGN(), LSQEndTerm(), operator=(), and ~LSQEndTerm().
int ObjectiveElement::t_index [protected, inherited] |
Referenced by ObjectiveElement::init(), ObjectiveElement::ObjectiveElement(), and ObjectiveElement::operator=().
BlockMatrix* ObjectiveElement::uSeed [protected, inherited] |
BlockMatrix* ObjectiveElement::uSeed2 [protected, inherited] |
BlockMatrix* ObjectiveElement::wSeed [protected, inherited] |
BlockMatrix* ObjectiveElement::wSeed2 [protected, inherited] |
BlockMatrix* ObjectiveElement::xaSeed [protected, inherited] |
BlockMatrix* ObjectiveElement::xaSeed2 [protected, inherited] |
BlockMatrix* ObjectiveElement::xSeed [protected, inherited] |
BlockMatrix* ObjectiveElement::xSeed2 [protected, inherited] |
int* ObjectiveElement::y_index [protected, inherited] |
EvaluationPoint ObjectiveElement::z [protected, inherited] |
Referenced by MayerTerm::evaluate(), LSQTerm::evaluate(), evaluate(), and ObjectiveElement::init().