ACADO Toolkit  1.2.0beta
Toolkit for Automatic Control and Dynamic Optimization
Public Member Functions | Protected Member Functions | Protected Attributes

Provides variable-specific settings for vector- or matrix-valued optimization variables (for internal use). More...

#include <variable_settings.hpp>

Inheritance diagram for VariableSettings:
Inheritance graph
[legend]

List of all members.

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.
VariableSettingsoperator= (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.

Detailed Description

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.

Author:
Hans Joachim Ferreau, Boris Houska

Constructor & Destructor Documentation

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 
)
Parameters:
[in]_dimDimension of variable.
[in]_typeType of the variable.
[in]_namesArray containing name labels for each component of the variable.
[in]_unitsArray containing unit labels for each component of the variable.
[in]_scalingScaling for each component of the variable.
[in]_lbLower bounds for each component of the variable.
[in]_ubUpper bounds for each component of the variable.
[in]_autoInitFlag indicating whether variable is to be automatically initialized.

References init(), names, and units.

References clear().


Member Function Documentation

Parameters:
[in]rhsVariableSettings to be appended.
Returns:
SUCCESSFUL_RETURN

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 
)
Parameters:
[in]_dimDimension of variable.
[in]_namesArray containing name labels for each component of the variable.
[in]_unitsArray containing unit labels for each component of the variable.
[in]_scalingArray containing the scaling for each component of the variable.
[in]_lbArray containing lower bounds for each component of the variable.
[in]_ubArray containing upper bounds for each component of the variable.
Returns:
SUCCESSFUL_RETURN

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.

Returns:
SUCCESSFUL_RETURN

References dim, names, SUCCESSFUL_RETURN, uint, and units.

Referenced by init(), operator=(), and ~VariableSettings().

Returns:
BT_TRUE iff automatic initialization is enabled,
BT_FALSE otherwise

References autoInit.

Referenced by MatrixVariablesGrid::getAutoInit().

double VariableSettings::getLowerBound ( uint  idx) const [inline]
Parameters:
[in]idxIndex of component.
Returns:
Current lower bound of given component

References BT_TRUE, defaultLowerBound, dim, INFTY, VectorspaceElement::isEmpty(), and lb.

Referenced by MatrixVariablesGrid::getLowerBound().

returnValue VariableSettings::getName ( uint  idx,
char *const  _name 
) const [inline]
Parameters:
[in]idxIndex of component.
[out]_nameName label of given component.
Returns:
SUCCESSFUL_RETURN,
RET_INDEX_OUT_OF_BOUNDS,
RET_MEMBER_NOT_INITIALISED

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().

double VariableSettings::getScaling ( uint  idx) const [inline]
Parameters:
[in]idxIndex of component.
Returns:
Current scaling of given component

References BT_TRUE, defaultScaling, dim, VectorspaceElement::isEmpty(), and scaling.

Returns:
Current variable type

References type.

Referenced by MatrixVariablesGrid::getType().

returnValue VariableSettings::getUnit ( uint  idx,
char *const  _unit 
) const [inline]
Parameters:
[in]idxIndex of component.
[out]_unitUnit label of given component.
Returns:
SUCCESSFUL_RETURN,
RET_INDEX_OUT_OF_BOUNDS,
RET_MEMBER_NOT_INITIALISED

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]
Parameters:
[in]idxIndex of component.
Returns:
Current upper bound of given component

References BT_TRUE, defaultUpperBound, dim, INFTY, VectorspaceElement::isEmpty(), and ub.

Referenced by MatrixVariablesGrid::getUpperBound().

Returns:
BT_TRUE iff VariableSettings comprises lower bounds,
BT_FALSE otherwise

References BT_FALSE, BT_TRUE, VectorspaceElement::isEmpty(), and lb.

Returns:
BT_TRUE iff VariableSettings comprises name labels,
BT_FALSE otherwise

References BT_FALSE, BT_TRUE, and names.

Referenced by getName(), and setName().

Returns:
BT_TRUE iff scaling is set,
BT_FALSE otherwise

References BT_FALSE, BT_TRUE, VectorspaceElement::isEmpty(), and scaling.

Returns:
BT_TRUE iff VariableSettings comprises unit labels,
BT_FALSE otherwise

References BT_FALSE, BT_TRUE, and units.

Referenced by getUnit(), and setUnit().

Returns:
BT_TRUE iff VariableSettings comprises upper bounds,
BT_FALSE otherwise

References BT_FALSE, BT_TRUE, VectorspaceElement::isEmpty(), and ub.

Returns:
SUCCESSFUL_RETURN

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 
)
Parameters:
[in]_dimDimension of variable.
[in]_typeType of the variable.
[in]_namesArray containing name labels for each component of the variable.
[in]_unitsArray containing unit labels for each component of the variable.
[in]_scalingArray containing the scaling for each component of the variable.
[in]_lbArray containing lower bounds for each component of the variable.
[in]_ubArray containing upper bounds for each component of the variable.
[in]_autoInitArray defining if each component of the variable is to be automatically initialized.
Returns:
SUCCESSFUL_RETURN

References appendSettings(), autoInit, init(), and type.

VariableSettings & VariableSettings::operator= ( const VariableSettings rhs)
Parameters:
[in]_autoInitNew auto initialization flag.
Returns:
SUCCESSFUL_RETURN

References autoInit, and SUCCESSFUL_RETURN.

Referenced by MatrixVariablesGrid::setAutoInit().

returnValue VariableSettings::setLowerBound ( uint  idx,
double  _lb 
) [inline]
Parameters:
[in]idxIndex of component.
[in]_lbNew lower bound.
Returns:
SUCCESSFUL_RETURN,
RET_INDEX_OUT_OF_BOUNDS

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().

Parameters:
[in]_lbNew lower bounds.
Returns:
SUCCESSFUL_RETURN,
RET_VECTOR_DIMENSION_MISMATCH

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]
Parameters:
[in]idxIndex of component.
[in]_nameNew name label.
Returns:
SUCCESSFUL_RETURN,
RET_INDEX_OUT_OF_BOUNDS,
RET_MEMBER_NOT_INITIALISED

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().

Parameters:
[in]_scalingNew scaling.
Note:
Scaling factors need to be positive.
Returns:
SUCCESSFUL_RETURN,
RET_VECTOR_DIMENSION_MISMATCH,
RET_INVALID_ARGUMENTS

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]
Parameters:
[in]idxIndex of component.
[in]_scalingNew scaling.
Note:
Scaling factor needs to be positive.
Returns:
SUCCESSFUL_RETURN,
RET_INDEX_OUT_OF_BOUNDS,
RET_INVALID_ARGUMENTS

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.

Parameters:
[in]_typeNew variable type.
Returns:
SUCCESSFUL_RETURN

References SUCCESSFUL_RETURN, and type.

Referenced by MatrixVariablesGrid::setType().

returnValue VariableSettings::setUnit ( uint  idx,
const char *const  _unit 
) [inline]
Parameters:
[in]idxIndex of component.
[in]_unitNew unit label.
Returns:
SUCCESSFUL_RETURN,
RET_INDEX_OUT_OF_BOUNDS,
RET_MEMBER_NOT_INITIALISED

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]
Parameters:
[in]idxIndex of component.
[in]_ubNew upper bound.
Returns:
SUCCESSFUL_RETURN,
RET_INDEX_OUT_OF_BOUNDS

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().

Parameters:
[in]_ubNew upper bounds.
Returns:
SUCCESSFUL_RETURN,
RET_VECTOR_DIMENSION_MISMATCH

References ACADOERROR, dim, VectorspaceElement::getDim(), RET_VECTOR_DIMENSION_MISMATCH, SUCCESSFUL_RETURN, and ub.

Referenced by operator=(), MatrixVariablesGrid::setUpperBounds(), and VariableSettings().


Member Data Documentation

char** VariableSettings::names [protected]
char** VariableSettings::units [protected]

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines