qpOASES  3.0.1
Public Member Functions | Protected Member Functions | Protected Attributes
Bounds Class Reference

Manages working sets of bounds (= box constraints). More...

#include <Bounds.hpp>

Inheritance diagram for Bounds:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Bounds ()
 Bounds (int _n)
 Bounds (const Bounds &rhs)
virtual ~Bounds ()
Boundsoperator= (const Bounds &rhs)
returnValue init (int _n=0)
returnValue setupBound (int number, SubjectToStatus _status)
returnValue setupAllFree ()
returnValue setupAllLower ()
returnValue setupAllUpper ()
returnValue moveFixedToFree (int number)
returnValue moveFreeToFixed (int number, SubjectToStatus _status)
returnValue flipFixed (int number)
returnValue swapFree (int number1, int number2)
int getNV () const
int getNFV () const
int getNBV () const
int getNUV () const
int getNFR () const
int getNFX () const
IndexlistgetFree ()
IndexlistgetFixed ()
virtual returnValue shift (int offset)
virtual returnValue rotate (int offset)
returnValue print ()
int getNumberOfType (SubjectToType _type) const
SubjectToType getType (int i) const
SubjectToStatus getStatus (int i) const
returnValue setType (int i, SubjectToType value)
returnValue setStatus (int i, SubjectToStatus value)
void setNoLower (BooleanType _status)
void setNoUpper (BooleanType _status)
BooleanType hasNoLower () const
BooleanType hasNoUpper () const

Protected Member Functions

returnValue clear ()
returnValue copy (const Bounds &rhs)
returnValue setupAll (SubjectToStatus _status)
returnValue copy (const SubjectTo &rhs)
returnValue addIndex (Indexlist *const indexlist, int newnumber, SubjectToStatus newstatus)
returnValue removeIndex (Indexlist *const indexlist, int removenumber)
returnValue swapIndex (Indexlist *const indexlist, int number1, int number2)

Protected Attributes

Indexlist freee
Indexlist fixed
int n
SubjectToTypetype
SubjectToStatusstatus
BooleanType noLower
BooleanType noUpper

Detailed Description

This class manages working sets of bounds (= box constraints) by storing index sets and other status information.

Author:
Hans Joachim Ferreau
Version:
3.0
Date:
2007-2014

Constructor & Destructor Documentation

Default constructor.

Bounds::Bounds ( int  _n)

Constructor which takes the number of bounds.

Parameters:
_nNumber of bounds.

References init().

Bounds::Bounds ( const Bounds rhs)

Copy constructor (deep copy).

Parameters:
rhsRhs object.

References copy().

Bounds::~Bounds ( ) [virtual]

Destructor.

References clear().


Member Function Documentation

returnValue SubjectTo::addIndex ( Indexlist *const  indexlist,
int  newnumber,
SubjectToStatus  newstatus 
) [protected, inherited]

Adds the index of a new constraint or bound to index set.

Returns:
SUCCESSFUL_RETURN
RET_ADDINDEX_FAILED
RET_INVALID_ARGUMENTS
Parameters:
indexlistIndex list to which the new index shall be added.
newnumberNumber of new constraint or bound.
newstatusStatus of new constraint or bound.

References Indexlist::addNumber(), RET_ADDINDEX_FAILED, RET_INDEX_ALREADY_OF_DESIRED_STATUS, RET_INDEXLIST_EXCEEDS_MAX_LENGTH, RET_INVALID_ARGUMENTS, SubjectTo::status, SUCCESSFUL_RETURN, and THROWERROR.

Referenced by Constraints::moveActiveToInactive(), moveFixedToFree(), moveFreeToFixed(), Constraints::moveInactiveToActive(), setupBound(), and Constraints::setupConstraint().

returnValue Bounds::clear ( ) [protected]

Frees all allocated memory.

Returns:
SUCCESSFUL_RETURN

Reimplemented from SubjectTo.

References SUCCESSFUL_RETURN.

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

returnValue SubjectTo::copy ( const SubjectTo rhs) [protected, inherited]

Copies all members from given rhs object.

Returns:
SUCCESSFUL_RETURN
Parameters:
rhsRhs object.

References SubjectTo::n, SubjectTo::noLower, SubjectTo::noUpper, SubjectTo::status, SUCCESSFUL_RETURN, and SubjectTo::type.

Referenced by SubjectTo::operator=(), and SubjectTo::SubjectTo().

returnValue Bounds::copy ( const Bounds rhs) [protected]

Copies all members from given rhs object.

Returns:
SUCCESSFUL_RETURN
Parameters:
rhsRhs object.

References fixed, freee, and SUCCESSFUL_RETURN.

Referenced by Bounds(), and operator=().

returnValue Bounds::flipFixed ( int  number)

Flip fixed bound.

Returns:
SUCCESSFUL_RETURN
RET_MOVING_BOUND_FAILED
RET_INDEX_OUT_OF_BOUNDS

References SubjectTo::n, RET_INDEX_OUT_OF_BOUNDS, RET_MOVING_BOUND_FAILED, ST_LOWER, ST_UPPER, SubjectTo::status, SUCCESSFUL_RETURN, and THROWERROR.

Referenced by QProblem::removeBound(), and QProblemB::removeBound().

Indexlist * Bounds::getFixed ( ) [inline]
Indexlist * Bounds::getFree ( ) [inline]
int Bounds::getNBV ( ) const [inline]

Returns number of bounded (but possibly free) variables.

Returns:
Number of bounded (but possibly free) variables.

References SubjectTo::getNumberOfType(), and ST_BOUNDED.

int Bounds::getNFR ( ) const [inline]

Returns number of free variables.

Returns:
Number of free variables.

References freee, and Indexlist::getLength().

Referenced by QProblemB::getNFR(), and print().

int Bounds::getNFV ( ) const [inline]

Returns number of implicitly fixed variables.

Returns:
Number of implicitly fixed variables.

References SubjectTo::getNumberOfType(), and ST_EQUALITY.

Referenced by QProblemB::getNFV().

int Bounds::getNFX ( ) const [inline]

Returns number of fixed variables.

Returns:
Number of fixed variables.

References fixed, and Indexlist::getLength().

Referenced by QProblemB::getNFX(), print(), QProblem::shallRefactorise(), and QProblemB::shallRefactorise().

BEGIN_NAMESPACE_QPOASES int SubjectTo::getNumberOfType ( SubjectToType  _type) const [inline, inherited]

Returns number of constraints/bounds with given SubjectTo type.

Returns:
Number of constraints/bounds with given type.
Parameters:
_typeType of (constraints') bound.

References SubjectTo::n, and SubjectTo::type.

Referenced by getNBV(), Constraints::getNEC(), getNFV(), Constraints::getNIC(), Constraints::getNUC(), and getNUV().

int Bounds::getNUV ( ) const [inline]

Returns number of unbounded variables.

Returns:
Number of unbounded variables.

References SubjectTo::getNumberOfType(), and ST_UNBOUNDED.

Referenced by QProblem::addBound().

BEGIN_NAMESPACE_QPOASES int Bounds::getNV ( ) const [inline]

Returns number of variables.

Returns:
Number of variables.

References SubjectTo::n.

Referenced by QProblemB::getNV().

SubjectToStatus SubjectTo::getStatus ( int  i) const [inline, inherited]
SubjectToType SubjectTo::getType ( int  i) const [inline, inherited]
BooleanType SubjectTo::hasNoLower ( ) const [inline, inherited]

Returns status of lower (constraints') bounds.

Returns:
BT_TRUE if there is no lower (constraints') bound on any variable.

References SubjectTo::noLower.

Referenced by QProblem::performStep(), QProblemB::performStep(), QProblemB::printProperties(), and QProblem::printProperties().

BooleanType SubjectTo::hasNoUpper ( ) const [inline, inherited]

Returns status of upper bounds.

Returns:
BT_TRUE if there is no upper (constraints') bound on any variable.

References SubjectTo::noUpper.

Referenced by QProblem::performStep(), QProblemB::performStep(), QProblemB::printProperties(), and QProblem::printProperties().

returnValue Bounds::init ( int  _n = 0)

Initialises object with given number of bounds.

Returns:
SUCCESSFUL_RETURN
RET_INVALID_ARGUMENTS
Parameters:
_nNumber of bounds.

Reimplemented from SubjectTo.

References clear(), fixed, freee, Indexlist::init(), RET_INVALID_ARGUMENTS, and THROWERROR.

Referenced by Bounds(), QProblemB::QProblemB(), QProblemB::reset(), SQProblem::setupAuxiliaryQP(), QProblem::setupAuxiliaryQP(), and QProblemB::setupAuxiliaryQP().

Moves index of a bound from index list of fixed to that of free bounds.

Returns:
SUCCESSFUL_RETURN
RET_MOVING_BOUND_FAILED
RET_INDEX_OUT_OF_BOUNDS
Parameters:
numberNumber of bound to be freed.

References SubjectTo::addIndex(), getFixed(), getFree(), SubjectTo::n, SubjectTo::removeIndex(), RET_INDEX_OUT_OF_BOUNDS, RET_MOVING_BOUND_FAILED, ST_INACTIVE, SUCCESSFUL_RETURN, and THROWERROR.

Referenced by QProblem::removeBound(), and QProblemB::removeBound().

returnValue Bounds::moveFreeToFixed ( int  number,
SubjectToStatus  _status 
)

Moves index of a bound from index list of free to that of fixed bounds.

Returns:
SUCCESSFUL_RETURN
RET_MOVING_BOUND_FAILED
RET_INDEX_OUT_OF_BOUNDS
Parameters:
numberNumber of bound to be fixed.
_statusStatus of bound to be fixed.

References SubjectTo::addIndex(), getFixed(), getFree(), SubjectTo::n, SubjectTo::removeIndex(), RET_INDEX_OUT_OF_BOUNDS, RET_MOVING_BOUND_FAILED, SUCCESSFUL_RETURN, and THROWERROR.

Referenced by QProblem::addBound(), QProblemB::addBound(), and QProblem::setupAuxiliaryWorkingSet().

Bounds & Bounds::operator= ( const Bounds rhs)

Assignment operator (deep copy).

Parameters:
rhsRhs object.

References clear(), and copy().

Prints information on bounds object (in particular, lists of free and fixed bounds.

Returns:
SUCCESSFUL_RETURN
RET_INDEXLIST_CORRUPTED

References getFixed(), getFree(), getNFR(), getNFX(), Indexlist::getNumberArray(), MAX_STRING_LENGTH, myPrintf(), SubjectTo::n, REFER_NAMESPACE_QPOASES, and SUCCESSFUL_RETURN.

returnValue SubjectTo::removeIndex ( Indexlist *const  indexlist,
int  removenumber 
) [protected, inherited]

Removes the index of a constraint or bound from index set.

Returns:
SUCCESSFUL_RETURN
RET_REMOVEINDEX_FAILED
RET_INVALID_ARGUMENTS
Parameters:
indexlistIndex list from which the new index shall be removed.
removenumberNumber of constraint or bound to be removed.

References Indexlist::removeNumber(), RET_INVALID_ARGUMENTS, RET_REMOVEINDEX_FAILED, ST_UNDEFINED, SubjectTo::status, SUCCESSFUL_RETURN, and THROWERROR.

Referenced by Constraints::moveActiveToInactive(), moveFixedToFree(), moveFreeToFixed(), and Constraints::moveInactiveToActive().

returnValue Bounds::rotate ( int  offset) [virtual]

Rotates forward type and status of all bounds by a given offset. This offset has to lie within the range [0,n]. Example for offset = 2:
rotate( {b1,b2,b3,b4,b5,b6} ) = {b3,b4,b5,b6,b1,b2}

Returns:
SUCCESSFUL_RETURN
RET_INDEX_OUT_OF_BOUNDS
RET_ROTATING_FAILED
Parameters:
offsetRotation offset within the range [0,n].

Implements SubjectTo.

References Indexlist::addNumber(), fixed, freee, SubjectTo::getStatus(), SubjectTo::getType(), SubjectTo::n, RET_INDEX_OUT_OF_BOUNDS, RET_ROTATING_FAILED, SubjectTo::setStatus(), SubjectTo::setType(), ST_INACTIVE, ST_LOWER, ST_UPPER, SUCCESSFUL_RETURN, and THROWERROR.

void SubjectTo::setNoLower ( BooleanType  _status) [inline, inherited]

Sets status of lower (constraints') bounds.

Parameters:
_statusStatus of lower (constraints') bounds.

References SubjectTo::noLower.

Referenced by QProblemB::setupSubjectToType(), and QProblem::setupSubjectToType().

void SubjectTo::setNoUpper ( BooleanType  _status) [inline, inherited]

Sets status of upper (constraints') bounds.

Parameters:
_statusStatus of upper (constraints') bounds.

References SubjectTo::noUpper.

Referenced by QProblemB::setupSubjectToType(), and QProblem::setupSubjectToType().

returnValue SubjectTo::setStatus ( int  i,
SubjectToStatus  value 
) [inline, inherited]

Sets status of (constraints') bound.

Returns:
SUCCESSFUL_RETURN
RET_INDEX_OUT_OF_BOUNDS
Parameters:
iNumber of (constraints') bound.
valueStatus of (constraints') bound.

References SubjectTo::n, RET_INDEX_OUT_OF_BOUNDS, SubjectTo::status, SUCCESSFUL_RETURN, and THROWERROR.

Referenced by QProblem::dropInfeasibles(), Constraints::rotate(), rotate(), SQProblem::setupAuxiliaryQP(), Constraints::shift(), and shift().

returnValue SubjectTo::setType ( int  i,
SubjectToType  value 
) [inline, inherited]

Sets type of (constraints') bound.

Returns:
SUCCESSFUL_RETURN
RET_INDEX_OUT_OF_BOUNDS
Parameters:
iNumber of (constraints') bound.
valueType of (constraints') bound.

References SubjectTo::n, RET_INDEX_OUT_OF_BOUNDS, SUCCESSFUL_RETURN, THROWERROR, and SubjectTo::type.

Referenced by Constraints::rotate(), rotate(), QProblem::setA(), QProblem::setupAuxiliaryWorkingSet(), QProblemB::setupSubjectToType(), QProblem::setupSubjectToType(), Constraints::shift(), and shift().

returnValue Bounds::setupAll ( SubjectToStatus  _status) [protected]

Initially adds all numbers of new (i.e. not yet in the list) bounds to to the index set corresponding to the desired status; the order depends on the SujectToType of each index.

Returns:
SUCCESSFUL_RETURN
RET_SETUP_BOUND_FAILED
Parameters:
_statusDesired initial status for all bounds.

References SubjectTo::getType(), SubjectTo::n, RET_SETUP_BOUND_FAILED, setupBound(), ST_BOUNDED, ST_DISABLED, ST_EQUALITY, ST_UNBOUNDED, ST_UNKNOWN, SUCCESSFUL_RETURN, and THROWERROR.

Referenced by setupAllFree(), setupAllLower(), and setupAllUpper().

Initially adds all numbers of new (i.e. not yet in the list) bounds to to the index set of free bounds; the order depends on the SujectToType of each index.

Returns:
SUCCESSFUL_RETURN
RET_SETUP_BOUND_FAILED

References setupAll(), and ST_INACTIVE.

Referenced by QProblemB::hotstart(), QProblem::hotstart(), SQProblem::setupAuxiliaryQP(), QProblem::setupAuxiliaryQP(), QProblemB::setupAuxiliaryQP(), QProblem::solveInitialQP(), and QProblemB::solveInitialQP().

Initially adds all numbers of new (i.e. not yet in the list) bounds to to the index set of fixed bounds (on their lower bounds); the order depends on the SujectToType of each index.

Returns:
SUCCESSFUL_RETURN
RET_SETUP_BOUND_FAILED

References setupAll(), and ST_LOWER.

Initially adds all numbers of new (i.e. not yet in the list) bounds to to the index set of fixed bounds (on their upper bounds); the order depends on the SujectToType of each index.

Returns:
SUCCESSFUL_RETURN
RET_SETUP_BOUND_FAILED

References setupAll(), and ST_UPPER.

returnValue Bounds::setupBound ( int  number,
SubjectToStatus  _status 
)

Initially adds number of a new (i.e. not yet in the list) bound to given index set.

Returns:
SUCCESSFUL_RETURN
RET_SETUP_BOUND_FAILED
RET_INDEX_OUT_OF_BOUNDS
RET_INVALID_ARGUMENTS
Parameters:
numberNumber of new bound.
_statusStatus of new bound.

References SubjectTo::addIndex(), getFixed(), getFree(), SubjectTo::n, RET_INDEX_OUT_OF_BOUNDS, RET_INVALID_ARGUMENTS, RET_SETUP_BOUND_FAILED, ST_INACTIVE, ST_LOWER, ST_UPPER, SUCCESSFUL_RETURN, and THROWERROR.

Referenced by QProblemB::obtainAuxiliaryWorkingSet(), and setupAll().

returnValue Bounds::shift ( int  offset) [virtual]

Shifts forward type and status of all bounds by a given offset. This offset has to lie within the range [0,n/2] and has to be an integer divisor of the total number of bounds n. Type and status of the first <offset> bounds is thrown away, type and status of the last <offset> bounds is doubled, e.g. for offset = 2:
shift( {b1,b2,b3,b4,b5,b6} ) = {b3,b4,b5,b6,b5,b6}

Returns:
SUCCESSFUL_RETURN
RET_INDEX_OUT_OF_BOUNDS
RET_INVALID_ARGUMENTS
RET_SHIFTING_FAILED
Parameters:
offsetShift offset within the range [0,n/2] and integer divisor of n.

Implements SubjectTo.

References Indexlist::addNumber(), fixed, freee, SubjectTo::getStatus(), SubjectTo::getType(), SubjectTo::n, RET_INDEX_OUT_OF_BOUNDS, RET_INVALID_ARGUMENTS, RET_SHIFTING_FAILED, SubjectTo::setStatus(), SubjectTo::setType(), ST_INACTIVE, ST_LOWER, ST_UPPER, SUCCESSFUL_RETURN, and THROWERROR.

returnValue Bounds::swapFree ( int  number1,
int  number2 
)

Swaps the indices of two free bounds within the index set.

Returns:
SUCCESSFUL_RETURN
RET_SWAPINDEX_FAILED
Parameters:
number1Number of first constraint or bound.
number2Number of second constraint or bound.

References getFree(), SubjectTo::n, RET_INDEX_OUT_OF_BOUNDS, SubjectTo::swapIndex(), and THROWERROR.

Referenced by QProblem::addBound().

returnValue SubjectTo::swapIndex ( Indexlist *const  indexlist,
int  number1,
int  number2 
) [protected, inherited]

Swaps the indices of two constraints or bounds within the index set.

Returns:
SUCCESSFUL_RETURN
RET_SWAPINDEX_FAILED
RET_INVALID_ARGUMENTS
Parameters:
indexlistIndex list in which the indices shold be swapped.
number1Number of first constraint or bound.
number2Number of second constraint or bound.

References RET_INVALID_ARGUMENTS, RET_NOTHING_TO_DO, RET_SWAPINDEX_FAILED, SubjectTo::status, SUCCESSFUL_RETURN, Indexlist::swapNumbers(), THROWERROR, and THROWWARNING.

Referenced by swapFree().


Member Data Documentation

Indexlist Bounds::fixed [protected]

Index list of fixed variables.

Referenced by copy(), getFixed(), getNFX(), init(), rotate(), and shift().

Indexlist Bounds::freee [protected]

Index list of free variables.

Referenced by copy(), getFree(), getNFR(), init(), rotate(), and shift().

int SubjectTo::n [protected, inherited]
BooleanType SubjectTo::noLower [protected, inherited]

This flag indicates if there is no lower bound on any variable.

Referenced by SubjectTo::copy(), SubjectTo::hasNoLower(), SubjectTo::init(), and SubjectTo::setNoLower().

BooleanType SubjectTo::noUpper [protected, inherited]

This flag indicates if there is no upper bound on any variable.

Referenced by SubjectTo::copy(), SubjectTo::hasNoUpper(), SubjectTo::init(), and SubjectTo::setNoUpper().

SubjectToStatus* SubjectTo::status [protected, inherited]
SubjectToType* SubjectTo::type [protected, inherited]

The documentation for this class was generated from the following files: