ACADO Toolkit
1.2.0beta
Toolkit for Automatic Control and Dynamic Optimization
|
Provides variable-specific settings for vector- or matrix-valued optimization variables (for internal use). More...
#include <variable_settings.hpp>
Public Member Functions | |
VariableSettings () | |
Default constructor. | |
VariableSettings (uint _dim, VariableType _type=VT_UNKNOWN, const char **const _names=0, const char **const _units=0, const VectorspaceElement &_scaling=emptyConstVectorspaceElement, const VectorspaceElement &_lb=emptyConstVectorspaceElement, const VectorspaceElement &_ub=emptyConstVectorspaceElement, BooleanType _autoInit=defaultAutoInit) | |
Constructor which takes all settings. | |
VariableSettings (const VariableSettings &rhs) | |
Copy constructor (deep copy). | |
~VariableSettings () | |
Destructor. | |
VariableSettings & | operator= (const VariableSettings &rhs) |
Copy constructor (deep copy). | |
returnValue | init () |
Initializes empty object. | |
returnValue | init (uint _dim, VariableType _type, const char **const _names, const char **const _units, const VectorspaceElement &_scaling=emptyConstVectorspaceElement, const VectorspaceElement &_lb=emptyConstVectorspaceElement, const VectorspaceElement &_ub=emptyConstVectorspaceElement, BooleanType _autoInit=defaultAutoInit) |
Initializes object with given dimension and settings. | |
returnValue | appendSettings (const VariableSettings &rhs) |
Appends given VariableSettings object as additional components to the current one. | |
returnValue | appendSettings (uint _dim, const char **const _names, const char **const _units, const VectorspaceElement &_scaling=emptyConstVectorspaceElement, const VectorspaceElement &_lb=emptyConstVectorspaceElement, const VectorspaceElement &_ub=emptyConstVectorspaceElement) |
Appends given VariableSettings object as additional components to the current one. | |
VariableType | getType () const |
Returns current variable type. | |
returnValue | setType (VariableType _type) |
Assigns new variable type. | |
returnValue | getName (uint idx, char *const _name) const |
Returns current name label of given component. | |
returnValue | setName (uint idx, const char *const _name) |
Assigns new name label to given component. | |
returnValue | getUnit (uint idx, char *const _unit) const |
Returns current unit label of given component. | |
returnValue | setUnit (uint idx, const char *const _unit) |
Assigns new unit label to given component. | |
VectorspaceElement | getScaling () const |
Returns current scaling. | |
returnValue | setScaling (const VectorspaceElement &_scaling) |
Assigns new scaling. | |
double | getScaling (uint idx) const |
Returns current scaling of given component. | |
returnValue | setScaling (uint idx, double _scaling) |
Assigns new scaling to given component. | |
VectorspaceElement | getLowerBounds () const |
Returns current lower bounds. | |
returnValue | setLowerBounds (const VectorspaceElement &_lb) |
Assigns new lower bounds. | |
double | getLowerBound (uint idx) const |
Returns current lower bound of given component. | |
returnValue | setLowerBound (uint idx, double _lb) |
Assigns new lower bound to given component. | |
VectorspaceElement | getUpperBounds () const |
Returns current upper bounds. | |
returnValue | setUpperBounds (const VectorspaceElement &_ub) |
Assigns new upper bounds. | |
double | getUpperBound (uint idx) const |
Returns current upper bound of given component. | |
returnValue | setUpperBound (uint idx, double _ub) |
Assigns new upper bound to given component. | |
BooleanType | getAutoInit () const |
Returns whether automatic initialization is enabled or not. | |
returnValue | setAutoInit (BooleanType _autoInit) |
Assigns new auto initialization flag. | |
BooleanType | hasNames () const |
Returns whether VariableSettings comprises (non-empty) name labels (at at least one of its grid points). | |
BooleanType | hasUnits () const |
Returns whether VariableSettings comprises (non-empty) unit labels (at at least one of its grid points). | |
BooleanType | hasScaling () const |
Returns whether scaling is set (at at least one grid point). | |
BooleanType | hasLowerBounds () const |
Returns whether VariableSettings comprises lower bounds (at at least one of its grid points). | |
BooleanType | hasUpperBounds () const |
Returns whether VariableSettings comprises upper bounds (at at least one of its grid points). | |
Protected Member Functions | |
returnValue | clear () |
Clears all settings. | |
Protected Attributes | |
uint | dim |
Dimension of variable. | |
VariableType | type |
Type of the variable. | |
char ** | names |
Array containing name labels for each component of the variable. | |
char ** | units |
Array containing unit labels for each component of the variable. | |
VectorspaceElement | scaling |
Scaling for each component of the variable. | |
VectorspaceElement | lb |
Lower bounds for each component of the variable. | |
VectorspaceElement | ub |
Upper bounds for each component of the variable. | |
BooleanType | autoInit |
Flag indicating whether variable is to be automatically initialized. |
The class VariableSettings provides variable-specific settings for enhancing a Vector or a Matrix to vector- or matrix-valued optimization variables. It is intended for internal use only.
References autoInit, defaultAutoInit, dim, names, type, units, and VT_UNKNOWN.
VariableSettings::VariableSettings | ( | uint | _dim, |
VariableType | _type = VT_UNKNOWN , |
||
const char **const | _names = 0 , |
||
const char **const | _units = 0 , |
||
const VectorspaceElement & | _scaling = emptyConstVectorspaceElement , |
||
const VectorspaceElement & | _lb = emptyConstVectorspaceElement , |
||
const VectorspaceElement & | _ub = emptyConstVectorspaceElement , |
||
BooleanType | _autoInit = defaultAutoInit |
||
) |
[in] | _dim | Dimension of variable. |
[in] | _type | Type of the variable. |
[in] | _names | Array containing name labels for each component of the variable. |
[in] | _units | Array containing unit labels for each component of the variable. |
[in] | _scaling | Scaling for each component of the variable. |
[in] | _lb | Lower bounds for each component of the variable. |
[in] | _ub | Upper bounds for each component of the variable. |
[in] | _autoInit | Flag indicating whether variable is to be automatically initialized. |
VariableSettings::VariableSettings | ( | const VariableSettings & | rhs | ) |
[in] | rhs | Right-hand side object. |
References autoInit, BT_FALSE, dim, VectorspaceElement::init(), VectorspaceElement::isEmpty(), lb, MAX_LENGTH_NAME, names, scaling, setLowerBounds(), setName(), setScaling(), setUnit(), setUpperBounds(), type, ub, uint, and units.
References clear().
returnValue VariableSettings::appendSettings | ( | const VariableSettings & | rhs | ) |
[in] | rhs | VariableSettings to be appended. |
References dim, lb, names, scaling, ub, and units.
Referenced by VariablesGrid::appendValues(), MatrixVariablesGrid::appendValues(), and init().
returnValue VariableSettings::appendSettings | ( | uint | _dim, |
const char **const | _names, | ||
const char **const | _units, | ||
const VectorspaceElement & | _scaling = emptyConstVectorspaceElement , |
||
const VectorspaceElement & | _lb = emptyConstVectorspaceElement , |
||
const VectorspaceElement & | _ub = emptyConstVectorspaceElement |
||
) |
[in] | _dim | Dimension of variable. |
[in] | _names | Array containing name labels for each component of the variable. |
[in] | _units | Array containing unit labels for each component of the variable. |
[in] | _scaling | Array containing the scaling for each component of the variable. |
[in] | _lb | Array containing lower bounds for each component of the variable. |
[in] | _ub | Array containing upper bounds for each component of the variable. |
References VectorspaceElement::append(), BT_FALSE, defaultLowerBound, defaultName, defaultScaling, defaultUnit, defaultUpperBound, dim, VectorspaceElement::init(), VectorspaceElement::isEmpty(), lb, MAX_LENGTH_NAME, names, scaling, VectorspaceElement::setAll(), setName(), setUnit(), SUCCESSFUL_RETURN, ub, uint, and units.
returnValue VariableSettings::clear | ( | ) | [protected] |
References dim, names, SUCCESSFUL_RETURN, uint, and units.
Referenced by init(), operator=(), and ~VariableSettings().
BooleanType VariableSettings::getAutoInit | ( | ) | const [inline] |
References autoInit.
Referenced by MatrixVariablesGrid::getAutoInit().
double VariableSettings::getLowerBound | ( | uint | idx | ) | const [inline] |
[in] | idx | Index of component. |
References BT_TRUE, defaultLowerBound, dim, INFTY, VectorspaceElement::isEmpty(), and lb.
Referenced by MatrixVariablesGrid::getLowerBound().
VectorspaceElement VariableSettings::getLowerBounds | ( | ) | const [inline] |
References BT_TRUE, defaultLowerBound, dim, VectorspaceElement::isEmpty(), lb, and VectorspaceElement::setAll().
Referenced by MatrixVariablesGrid::getLowerBounds().
returnValue VariableSettings::getName | ( | uint | idx, |
char *const | _name | ||
) | const [inline] |
[in] | idx | Index of component. |
[out] | _name | Name label of given component. |
References ACADOERROR, BT_TRUE, dim, hasNames(), MAX_LENGTH_NAME, names, RET_INDEX_OUT_OF_BOUNDS, RET_MEMBER_NOT_INITIALISED, and SUCCESSFUL_RETURN.
Referenced by MatrixVariablesGrid::getName().
VectorspaceElement VariableSettings::getScaling | ( | ) | const [inline] |
References BT_TRUE, defaultScaling, dim, VectorspaceElement::isEmpty(), scaling, and VectorspaceElement::setAll().
Referenced by MatrixVariablesGrid::getScaling().
double VariableSettings::getScaling | ( | uint | idx | ) | const [inline] |
[in] | idx | Index of component. |
References BT_TRUE, defaultScaling, dim, VectorspaceElement::isEmpty(), and scaling.
BEGIN_NAMESPACE_ACADO VariableType VariableSettings::getType | ( | ) | const [inline] |
returnValue VariableSettings::getUnit | ( | uint | idx, |
char *const | _unit | ||
) | const [inline] |
[in] | idx | Index of component. |
[out] | _unit | Unit label of given component. |
References ACADOERROR, BT_TRUE, dim, hasUnits(), MAX_LENGTH_NAME, RET_INDEX_OUT_OF_BOUNDS, RET_MEMBER_NOT_INITIALISED, SUCCESSFUL_RETURN, and units.
Referenced by MatrixVariablesGrid::getUnit().
double VariableSettings::getUpperBound | ( | uint | idx | ) | const [inline] |
[in] | idx | Index of component. |
References BT_TRUE, defaultUpperBound, dim, INFTY, VectorspaceElement::isEmpty(), and ub.
Referenced by MatrixVariablesGrid::getUpperBound().
VectorspaceElement VariableSettings::getUpperBounds | ( | ) | const [inline] |
References BT_TRUE, defaultUpperBound, dim, VectorspaceElement::isEmpty(), VectorspaceElement::setAll(), and ub.
Referenced by MatrixVariablesGrid::getUpperBounds().
BooleanType VariableSettings::hasLowerBounds | ( | ) | const [inline] |
References BT_FALSE, BT_TRUE, VectorspaceElement::isEmpty(), and lb.
BooleanType VariableSettings::hasNames | ( | ) | const [inline] |
BooleanType VariableSettings::hasScaling | ( | ) | const [inline] |
References BT_FALSE, BT_TRUE, VectorspaceElement::isEmpty(), and scaling.
BooleanType VariableSettings::hasUnits | ( | ) | const [inline] |
BooleanType VariableSettings::hasUpperBounds | ( | ) | const [inline] |
References BT_FALSE, BT_TRUE, VectorspaceElement::isEmpty(), and ub.
References autoInit, clear(), defaultAutoInit, dim, names, SUCCESSFUL_RETURN, type, units, and VT_UNKNOWN.
Referenced by init(), MatrixVariable::init(), and VariableSettings().
returnValue VariableSettings::init | ( | uint | _dim, |
VariableType | _type, | ||
const char **const | _names, | ||
const char **const | _units, | ||
const VectorspaceElement & | _scaling = emptyConstVectorspaceElement , |
||
const VectorspaceElement & | _lb = emptyConstVectorspaceElement , |
||
const VectorspaceElement & | _ub = emptyConstVectorspaceElement , |
||
BooleanType | _autoInit = defaultAutoInit |
||
) |
[in] | _dim | Dimension of variable. |
[in] | _type | Type of the variable. |
[in] | _names | Array containing name labels for each component of the variable. |
[in] | _units | Array containing unit labels for each component of the variable. |
[in] | _scaling | Array containing the scaling for each component of the variable. |
[in] | _lb | Array containing lower bounds for each component of the variable. |
[in] | _ub | Array containing upper bounds for each component of the variable. |
[in] | _autoInit | Array defining if each component of the variable is to be automatically initialized. |
References appendSettings(), autoInit, init(), and type.
VariableSettings & VariableSettings::operator= | ( | const VariableSettings & | rhs | ) |
[in] | rhs | Right-hand side object. |
References autoInit, BT_FALSE, clear(), dim, VectorspaceElement::init(), VectorspaceElement::isEmpty(), lb, MAX_LENGTH_NAME, names, scaling, setLowerBounds(), setName(), setScaling(), setUnit(), setUpperBounds(), type, ub, uint, and units.
returnValue VariableSettings::setAutoInit | ( | BooleanType | _autoInit | ) | [inline] |
[in] | _autoInit | New auto initialization flag. |
References autoInit, and SUCCESSFUL_RETURN.
Referenced by MatrixVariablesGrid::setAutoInit().
returnValue VariableSettings::setLowerBound | ( | uint | idx, |
double | _lb | ||
) | [inline] |
[in] | idx | Index of component. |
[in] | _lb | New lower bound. |
References ACADOERROR, BT_TRUE, defaultLowerBound, dim, VectorspaceElement::init(), VectorspaceElement::isEmpty(), lb, RET_INDEX_OUT_OF_BOUNDS, VectorspaceElement::setAll(), and SUCCESSFUL_RETURN.
Referenced by MatrixVariablesGrid::setLowerBound().
returnValue VariableSettings::setLowerBounds | ( | const VectorspaceElement & | _lb | ) | [inline] |
[in] | _lb | New lower bounds. |
References ACADOERROR, dim, VectorspaceElement::getDim(), lb, RET_VECTOR_DIMENSION_MISMATCH, and SUCCESSFUL_RETURN.
Referenced by operator=(), MatrixVariablesGrid::setLowerBounds(), and VariableSettings().
returnValue VariableSettings::setName | ( | uint | idx, |
const char *const | _name | ||
) | [inline] |
[in] | idx | Index of component. |
[in] | _name | New name label. |
References ACADOERROR, BT_TRUE, defaultName, dim, hasNames(), MAX_LENGTH_NAME, names, RET_INDEX_OUT_OF_BOUNDS, RET_INVALID_ARGUMENTS, SUCCESSFUL_RETURN, and uint.
Referenced by appendSettings(), operator=(), MatrixVariablesGrid::setName(), and VariableSettings().
returnValue VariableSettings::setScaling | ( | const VectorspaceElement & | _scaling | ) | [inline] |
[in] | _scaling | New scaling. |
References ACADOERROR, acadoIsSmaller(), BT_TRUE, dim, VectorspaceElement::getDim(), VectorspaceElement::getMin(), RET_INVALID_ARGUMENTS, RET_VECTOR_DIMENSION_MISMATCH, scaling, and SUCCESSFUL_RETURN.
Referenced by operator=(), MatrixVariablesGrid::setScaling(), and VariableSettings().
returnValue VariableSettings::setScaling | ( | uint | idx, |
double | _scaling | ||
) | [inline] |
[in] | idx | Index of component. |
[in] | _scaling | New scaling. |
References ACADOERROR, acadoIsSmaller(), BT_TRUE, defaultScaling, dim, VectorspaceElement::init(), VectorspaceElement::isEmpty(), RET_INDEX_OUT_OF_BOUNDS, RET_INVALID_ARGUMENTS, scaling, VectorspaceElement::setAll(), and SUCCESSFUL_RETURN.
returnValue VariableSettings::setType | ( | VariableType | _type | ) | [inline] |
[in] | _type | New variable type. |
References SUCCESSFUL_RETURN, and type.
Referenced by MatrixVariablesGrid::setType().
returnValue VariableSettings::setUnit | ( | uint | idx, |
const char *const | _unit | ||
) | [inline] |
[in] | idx | Index of component. |
[in] | _unit | New unit label. |
References ACADOERROR, BT_TRUE, defaultUnit, dim, hasUnits(), MAX_LENGTH_NAME, RET_INDEX_OUT_OF_BOUNDS, RET_INVALID_ARGUMENTS, SUCCESSFUL_RETURN, uint, and units.
Referenced by appendSettings(), operator=(), MatrixVariablesGrid::setUnit(), and VariableSettings().
returnValue VariableSettings::setUpperBound | ( | uint | idx, |
double | _ub | ||
) | [inline] |
[in] | idx | Index of component. |
[in] | _ub | New upper bound. |
References ACADOERROR, BT_TRUE, defaultUpperBound, dim, VectorspaceElement::init(), VectorspaceElement::isEmpty(), RET_INDEX_OUT_OF_BOUNDS, VectorspaceElement::setAll(), SUCCESSFUL_RETURN, and ub.
Referenced by MatrixVariablesGrid::setUpperBound().
returnValue VariableSettings::setUpperBounds | ( | const VectorspaceElement & | _ub | ) | [inline] |
[in] | _ub | New upper bounds. |
References ACADOERROR, dim, VectorspaceElement::getDim(), RET_VECTOR_DIMENSION_MISMATCH, SUCCESSFUL_RETURN, and ub.
Referenced by operator=(), MatrixVariablesGrid::setUpperBounds(), and VariableSettings().
BooleanType VariableSettings::autoInit [protected] |
Referenced by getAutoInit(), init(), operator=(), setAutoInit(), and VariableSettings().
uint VariableSettings::dim [protected] |
VectorspaceElement VariableSettings::lb [protected] |
Referenced by appendSettings(), getLowerBound(), getLowerBounds(), hasLowerBounds(), operator=(), setLowerBound(), setLowerBounds(), and VariableSettings().
char** VariableSettings::names [protected] |
Referenced by appendSettings(), clear(), getName(), hasNames(), init(), operator=(), setName(), and VariableSettings().
VectorspaceElement VariableSettings::scaling [protected] |
Referenced by appendSettings(), getScaling(), hasScaling(), operator=(), setScaling(), and VariableSettings().
VariableType VariableSettings::type [protected] |
Referenced by getType(), init(), operator=(), setType(), and VariableSettings().
VectorspaceElement VariableSettings::ub [protected] |
Referenced by appendSettings(), getUpperBound(), getUpperBounds(), hasUpperBounds(), operator=(), setUpperBound(), setUpperBounds(), and VariableSettings().
char** VariableSettings::units [protected] |
Referenced by appendSettings(), clear(), getUnit(), hasUnits(), init(), operator=(), setUnit(), and VariableSettings().