qpOASES 3.2.2
An Implementation of the Online Active Set Strategy
Constraints Class Reference

Manages working sets of constraints. More...

#include <Constraints.hpp>

Inheritance diagram for Constraints:
SubjectTo

Public Member Functions

 Constraints ()
 Constraints (int_t _n)
 Constraints (const Constraints &rhs)
virtual ~Constraints ()
Constraints & operator= (const Constraints &rhs)
returnValue init (int_t _n=0)
returnValue setupConstraint (int_t number, SubjectToStatus _status)
returnValue setupAllInactive ()
returnValue setupAllLower ()
returnValue setupAllUpper ()
returnValue moveActiveToInactive (int_t number)
returnValue moveInactiveToActive (int_t number, SubjectToStatus _status)
returnValue flipFixed (int_t number)
int_t getNC () const
int_t getNEC () const
int_t getNIC () const
int_t getNUC () const
int_t getNAC () const
int_t getNIAC () const
Indexlist * getActive ()
Indexlist * getInactive ()
virtual returnValue shift (int_t offset)
virtual returnValue rotate (int_t offset)
returnValue print ()
int_t getNumberOfType (SubjectToType _type) const
SubjectToType getType (int_t i) const
SubjectToStatus getStatus (int_t i) const
returnValue setType (int_t i, SubjectToType value)
returnValue setStatus (int_t 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 Constraints &rhs)
returnValue setupAll (SubjectToStatus _status)
returnValue copy (const SubjectTo &rhs)
returnValue addIndex (Indexlist *const indexlist, int_t newnumber, SubjectToStatus newstatus)
returnValue removeIndex (Indexlist *const indexlist, int_t removenumber)
returnValue swapIndex (Indexlist *const indexlist, int_t number1, int_t number2)

Protected Attributes

Indexlist active
Indexlist inactive
int_t n
SubjectToType * type
SubjectToStatus * status
BooleanType noLower
BooleanType noUpper

Detailed Description

This class manages working sets of constraints by storing index sets and other status information.

Author
Hans Joachim Ferreau
Version
3.2
Date
2007-2017

Constructor & Destructor Documentation

◆ Constraints() [1/3]

BEGIN_NAMESPACE_QPOASES Constraints::Constraints ( )

Default constructor.

References SubjectTo::SubjectTo().

Referenced by Constraints(), copy(), and operator=().

◆ Constraints() [2/3]

Constraints::Constraints ( int_t _n)

Constructor which takes the number of constraints.

Parameters
_nNumber of constraints.

References init(), and SubjectTo::SubjectTo().

◆ Constraints() [3/3]

Constraints::Constraints ( const Constraints & rhs)

Copy constructor (deep copy).

Parameters
rhsRhs object.

References Constraints(), copy(), and SubjectTo::SubjectTo().

◆ ~Constraints()

Constraints::~Constraints ( )
virtual

Destructor.

References clear().

Member Function Documentation

◆ addIndex()

returnValue SubjectTo::addIndex ( Indexlist *const indexlist,
int_t newnumber,
SubjectToStatus newstatus )
protectedinherited

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, status, SUCCESSFUL_RETURN, and THROWERROR.

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

◆ clear()

returnValue Constraints::clear ( )
protected

Frees all allocated memory.

Returns
SUCCESSFUL_RETURN

References SUCCESSFUL_RETURN.

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

◆ copy() [1/2]

returnValue Constraints::copy ( const Constraints & rhs)
protected

Copies all members from given rhs object.

Returns
SUCCESSFUL_RETURN
Parameters
rhsRhs object.

References active, Constraints(), inactive, and SUCCESSFUL_RETURN.

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

◆ copy() [2/2]

returnValue SubjectTo::copy ( const SubjectTo & rhs)
protectedinherited

Copies all members from given rhs object.

Returns
SUCCESSFUL_RETURN
Parameters
rhsRhs object.

References n, noLower, noUpper, status, SubjectTo(), SUCCESSFUL_RETURN, and type.

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

◆ flipFixed()

returnValue Constraints::flipFixed ( int_t number)

Flip fixed constraint.

Returns
SUCCESSFUL_RETURN
RET_MOVING_CONSTRAINT_FAILED
RET_INDEX_OUT_OF_BOUNDS

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

◆ getActive()

Indexlist * Constraints::getActive ( )
inline

Returns a pointer to active constraints index list.

Returns
Pointer to active constraints index list.

References active.

Referenced by SolutionAnalysis::getVarianceCovariance(), moveActiveToInactive(), moveInactiveToActive(), print(), and setupConstraint().

◆ getInactive()

Indexlist * Constraints::getInactive ( )
inline

Returns a pointer to inactive constraints index list.

Returns
Pointer to inactive constraints index list.

References inactive.

Referenced by moveActiveToInactive(), moveInactiveToActive(), print(), and setupConstraint().

◆ getNAC()

int_t Constraints::getNAC ( ) const
inline

Returns the number of active constraints.

Returns
Number of active constraints.

References active.

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

◆ getNC()

BEGIN_NAMESPACE_QPOASES int_t Constraints::getNC ( ) const
inline

Returns the number of constraints.

Returns
Number of constraints.

References SubjectTo::n.

◆ getNEC()

int_t Constraints::getNEC ( ) const
inline

Returns the number of implicit equality constraints.

Returns
Number of implicit equality constraints.

References SubjectTo::getNumberOfType(), and ST_EQUALITY.

◆ getNIAC()

int_t Constraints::getNIAC ( ) const
inline

Returns the number of inactive constraints.

Returns
Number of inactive constraints.

References inactive.

Referenced by print().

◆ getNIC()

int_t Constraints::getNIC ( ) const
inline

Returns the number of "real" inequality constraints.

Returns
Number of "real" inequality constraints.

References SubjectTo::getNumberOfType(), and ST_BOUNDED.

◆ getNUC()

int_t Constraints::getNUC ( ) const
inline

Returns the number of unbounded constraints (i.e. without any bounds).

Returns
Number of unbounded constraints (i.e. without any bounds).

References SubjectTo::getNumberOfType(), and ST_UNBOUNDED.

◆ getNumberOfType()

BEGIN_NAMESPACE_QPOASES int_t SubjectTo::getNumberOfType ( SubjectToType _type) const
inlineinherited

Returns number of constraints/bounds with given SubjectTo type.

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

References n, and type.

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

◆ getStatus()

◆ getType()

SubjectToType SubjectTo::getType ( int_t i) const
inlineinherited

Returns type of (constraints') bound.

Returns
Type of (constraints') bound
RET_INDEX_OUT_OF_BOUNDS
Parameters
iNumber of (constraints') bound.

References n, ST_UNKNOWN, and type.

Referenced by QProblemB::performRatioTest(), Bounds::rotate(), Constraints::rotate(), Bounds::setupAll(), Constraints::setupAll(), SQProblem::setupNewAuxiliaryQP(), Bounds::shift(), and Constraints::shift().

◆ hasNoLower()

BooleanType SubjectTo::hasNoLower ( ) const
inlineinherited

Returns status of lower (constraints') bounds.

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

References noLower.

◆ hasNoUpper()

BooleanType SubjectTo::hasNoUpper ( ) const
inlineinherited

Returns status of upper bounds.

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

References noUpper.

◆ init()

returnValue Constraints::init ( int_t _n = 0)

Initialises object with given number of constraints.

Returns
SUCCESSFUL_RETURN
RET_INVALID_ARGUMENTS
Parameters
_nNumber of constraints.

References active, clear(), inactive, SubjectTo::init(), RET_INVALID_ARGUMENTS, and THROWERROR.

Referenced by Constraints().

◆ moveActiveToInactive()

returnValue Constraints::moveActiveToInactive ( int_t number)

Moves index of a constraint from index list of active to that of inactive constraints.

Returns
SUCCESSFUL_RETURN
RET_MOVING_CONSTRAINT_FAILED
Parameters
numberNumber of constraint to become inactive.

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

◆ moveInactiveToActive()

returnValue Constraints::moveInactiveToActive ( int_t number,
SubjectToStatus _status )

Moves index of a constraint from index list of inactive to that of active constraints.

Returns
SUCCESSFUL_RETURN
RET_MOVING_CONSTRAINT_FAILED
Parameters
numberNumber of constraint to become active.
_statusStatus of constraint to become active.

References SubjectTo::addIndex(), getActive(), getInactive(), SubjectTo::n, SubjectTo::removeIndex(), RET_INDEX_OUT_OF_BOUNDS, RET_MOVING_BOUND_FAILED, SUCCESSFUL_RETURN, and THROWERROR.

◆ operator=()

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

Assignment operator (deep copy).

Parameters
rhsRhs object.

References clear(), Constraints(), copy(), and SubjectTo::operator=().

◆ print()

returnValue Constraints::print ( )

Prints information on constraints object (in particular, lists of inactive and active constraints.

Returns
SUCCESSFUL_RETURN
RET_INDEXLIST_CORRUPTED

References getActive(), getInactive(), getNAC(), getNIAC(), Indexlist::getNumberArray(), MAX_STRING_LENGTH, myPrintf(), SubjectTo::n, print(), REFER_NAMESPACE_QPOASES, and SUCCESSFUL_RETURN.

Referenced by print().

◆ removeIndex()

returnValue SubjectTo::removeIndex ( Indexlist *const indexlist,
int_t removenumber )
protectedinherited

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, status, SUCCESSFUL_RETURN, and THROWERROR.

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

◆ rotate()

returnValue Constraints::rotate ( int_t offset)
virtual

Rotates forward type and status of all constraints by a given offset. This offset has to lie within the range [0,n]. Example for offset = 2:
rotate( {c1,c2,c3,c4,c5,c6} ) = {c3,c4,c5,c6,c1,c2}

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

Implements SubjectTo.

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

◆ setNoLower()

void SubjectTo::setNoLower ( BooleanType _status)
inlineinherited

Sets status of lower (constraints') bounds.

Parameters
_statusStatus of lower (constraints') bounds.

References noLower.

◆ setNoUpper()

void SubjectTo::setNoUpper ( BooleanType _status)
inlineinherited

Sets status of upper (constraints') bounds.

Parameters
_statusStatus of upper (constraints') bounds.

References noUpper.

◆ setStatus()

returnValue SubjectTo::setStatus ( int_t i,
SubjectToStatus value )
inlineinherited

Sets status of (constraints') bound.

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

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

Referenced by Bounds::rotate(), Constraints::rotate(), SQProblemSchur::setupAuxiliaryQP(), SQProblem::setupNewAuxiliaryQP(), Bounds::shift(), and Constraints::shift().

◆ setType()

returnValue SubjectTo::setType ( int_t i,
SubjectToType value )
inlineinherited

Sets type of (constraints') bound.

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

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

Referenced by Bounds::rotate(), Constraints::rotate(), Bounds::shift(), and Constraints::shift().

◆ setupAll()

returnValue Constraints::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_CONSTRAINT_FAILED
Parameters
_statusDesired initial status for all bounds.

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

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

◆ setupAllInactive()

returnValue Constraints::setupAllInactive ( )

Initially adds all enabled numbers of new (i.e. not yet in the list) constraints to to the index set of inactive constraints; the order depends on the SujectToType of each index. Only disabled constraints are added to index set of disabled constraints!

Returns
SUCCESSFUL_RETURN
RET_SETUP_CONSTRAINT_FAILED

References setupAll(), and ST_INACTIVE.

◆ setupAllLower()

returnValue Constraints::setupAllLower ( )

Initially adds all enabled numbers of new (i.e. not yet in the list) constraints to to the index set of active constraints (on their lower bounds); the order depends on the SujectToType of each index. Only disabled constraints are added to index set of disabled constraints!

Returns
SUCCESSFUL_RETURN
RET_SETUP_CONSTRAINT_FAILED

References setupAll(), and ST_LOWER.

◆ setupAllUpper()

returnValue Constraints::setupAllUpper ( )

Initially adds all enabled numbers of new (i.e. not yet in the list) constraints to to the index set of active constraints (on their upper bounds); the order depends on the SujectToType of each index. Only disabled constraints are added to index set of disabled constraints!

Returns
SUCCESSFUL_RETURN
RET_SETUP_CONSTRAINT_FAILED

References setupAll(), and ST_UPPER.

◆ setupConstraint()

returnValue Constraints::setupConstraint ( int_t number,
SubjectToStatus _status )

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

Returns
SUCCESSFUL_RETURN
RET_SETUP_CONSTRAINT_FAILED
RET_INDEX_OUT_OF_BOUNDS
RET_INVALID_ARGUMENTS
Parameters
numberNumber of new constraint.
_statusStatus of new constraint.

References SubjectTo::addIndex(), getActive(), getInactive(), SubjectTo::n, RET_INDEX_OUT_OF_BOUNDS, RET_INVALID_ARGUMENTS, RET_SETUP_CONSTRAINT_FAILED, ST_INACTIVE, ST_LOWER, ST_UPPER, SUCCESSFUL_RETURN, and THROWERROR.

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

◆ shift()

returnValue Constraints::shift ( int_t offset)
virtual

Shifts forward type and status of all constraints 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 constraints n. Type and status of the first <offset> constraints is thrown away, type and status of the last <offset> constraints is doubled, e.g. for offset = 2:
shift( {c1,c2,c3,c4,c5,c6} ) = {c3,c4,c5,c6,c5,c6}

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 active, Indexlist::addNumber(), SubjectTo::getStatus(), SubjectTo::getType(), inactive, 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.

◆ swapIndex()

returnValue SubjectTo::swapIndex ( Indexlist *const indexlist,
int_t number1,
int_t number2 )
protectedinherited

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, status, SUCCESSFUL_RETURN, Indexlist::swapNumbers(), THROWERROR, and THROWWARNING.

Referenced by Bounds::swapFree().

Member Data Documentation

◆ active

Indexlist Constraints::active
protected

Index list of active constraints.

Referenced by copy(), getActive(), getNAC(), init(), rotate(), and shift().

◆ inactive

Indexlist Constraints::inactive
protected

Index list of inactive constraints.

Referenced by copy(), getInactive(), getNIAC(), init(), rotate(), and shift().

◆ n

◆ noLower

BooleanType SubjectTo::noLower
protectedinherited

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

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

◆ noUpper

BooleanType SubjectTo::noUpper
protectedinherited

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

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

◆ status

SubjectToStatus* SubjectTo::status
protectedinherited

◆ type

SubjectToType* SubjectTo::type
protectedinherited

Type of constraints/bounds.

Referenced by clear(), copy(), getNumberOfType(), getType(), init(), setType(), SubjectTo(), and SubjectTo().


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