qpOASES
3.2.1
An Implementation of the Online Active Set Strategy
|
Manages working sets of constraints. More...
#include <Constraints.hpp>
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 |
This class manages working sets of constraints by storing index sets and other status information.
BEGIN_NAMESPACE_QPOASES Constraints::Constraints | ( | ) |
Default constructor.
Constraints::Constraints | ( | int_t | _n | ) |
Constructor which takes the number of constraints.
_n | Number of constraints. |
References init().
Constraints::Constraints | ( | const Constraints & | rhs | ) |
|
virtual |
Destructor.
References clear().
|
protectedinherited |
Adds the index of a new constraint or bound to index set.
indexlist | Index list to which the new index shall be added. |
newnumber | Number of new constraint or bound. |
newstatus | Status 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 moveActiveToInactive(), Bounds::moveFixedToFree(), Bounds::moveFreeToFixed(), moveInactiveToActive(), Bounds::setupBound(), and setupConstraint().
|
protected |
Frees all allocated memory.
References SUCCESSFUL_RETURN.
Referenced by init(), operator=(), and ~Constraints().
|
protectedinherited |
Copies all members from given rhs object.
rhs | Rhs object. |
References SubjectTo::n, SubjectTo::noLower, SubjectTo::noUpper, SubjectTo::status, SUCCESSFUL_RETURN, and SubjectTo::type.
Referenced by SubjectTo::operator=(), and SubjectTo::SubjectTo().
|
protected |
Copies all members from given rhs object.
rhs | Rhs object. |
References active, inactive, and SUCCESSFUL_RETURN.
Referenced by Constraints(), and operator=().
returnValue Constraints::flipFixed | ( | int_t | number | ) |
Flip fixed constraint.
References SubjectTo::n, RET_INDEX_OUT_OF_BOUNDS, RET_MOVING_CONSTRAINT_FAILED, ST_LOWER, ST_UPPER, SubjectTo::status, SUCCESSFUL_RETURN, and THROWERROR.
Referenced by QProblem::removeConstraint().
|
inline |
Returns a pointer to active constraints index list.
References active.
Referenced by SQProblemSchur::addBound_ensureLI(), QProblem::addBound_ensureLI(), QProblem::addConstraint_checkLI(), SQProblemSchur::addConstraint_checkLISchur(), SQProblemSchur::addConstraint_ensureLI(), QProblem::addConstraint_ensureLI(), QProblem::computeProjectedCholesky(), QProblem::determineDataShift(), QProblem::determineStepDirection(), SQProblemSchur::determineStepDirection2(), QProblem::dropInfeasibles(), QProblem::ensureNonzeroCurvature(), SolutionAnalysis::getVarianceCovariance(), moveActiveToInactive(), moveInactiveToActive(), QProblem::performStep(), print(), QProblem::removeBound(), SQProblemSchur::removeConstraint(), QProblem::removeConstraint(), setupConstraint(), QProblem::solveCurrentEQP(), and QProblem::writeQpWorkspaceIntoMatFile().
|
inline |
Returns a pointer to inactive constraints index list.
References END_NAMESPACE_QPOASES, and inactive.
Referenced by QProblem::addConstraint_checkLI(), SQProblemSchur::addConstraint_checkLISchur(), QProblem::ensureNonzeroCurvature(), moveActiveToInactive(), moveInactiveToActive(), QProblem::performStep(), print(), setupConstraint(), and QProblem::writeQpWorkspaceIntoMatFile().
|
inline |
Returns the number of active constraints.
References active, and Indexlist::getLength().
Referenced by QProblem::getNAC(), print(), and QProblem::shallRefactorise().
|
inline |
Returns the number of constraints.
References SubjectTo::n.
Referenced by SQProblemSchur::addConstraint(), QProblem::addConstraint(), and QProblem::getNC().
|
inline |
Returns the number of implicit equality constraints.
References SubjectTo::getNumberOfType(), and ST_EQUALITY.
Referenced by QProblem::getNEC().
|
inline |
Returns the number of inactive constraints.
References Indexlist::getLength(), and inactive.
Referenced by QProblem::getNIAC(), and print().
|
inline |
Returns the number of "real" inequality constraints.
References SubjectTo::getNumberOfType(), and ST_BOUNDED.
|
inline |
Returns the number of unbounded constraints (i.e. without any bounds).
References SubjectTo::getNumberOfType(), and ST_UNBOUNDED.
Referenced by SQProblemSchur::addConstraint(), and QProblem::addConstraint().
|
inlineinherited |
Returns number of constraints/bounds with given SubjectTo type.
_type | Type of (constraints') bound. |
References SubjectTo::n, and SubjectTo::type.
Referenced by Bounds::getNBV(), getNEC(), Bounds::getNFV(), getNIC(), getNUC(), and Bounds::getNUV().
|
inlineinherited |
Returns status of (constraints') bound.
i | Number of (constraints') bound. |
References SubjectTo::n, ST_UNDEFINED, and SubjectTo::status.
Referenced by SQProblemSchur::addBound(), QProblem::addBound(), SQProblemSchur::addConstraint(), QProblem::addConstraint(), SolutionAnalysis::checkCurvatureOnStronglyActiveConstraints(), QProblem::determineStepDirection(), QProblemB::determineStepDirection(), SQProblemSchur::determineStepDirection2(), QProblem::dropInfeasibles(), QProblem::ensureNonzeroCurvature(), QProblemB::getWorkingSetBounds(), QProblem::getWorkingSetConstraints(), QProblemB::init(), QProblem::init(), QProblemB::obtainAuxiliaryWorkingSet(), QProblem::obtainAuxiliaryWorkingSet(), QProblem::performDriftCorrection(), QProblemB::performDriftCorrection(), QProblemB::performRamping(), QProblem::performRamping(), QProblemB::performRatioTest(), SQProblemSchur::removeBound(), QProblem::removeBound(), QProblemB::removeBound(), SQProblemSchur::removeConstraint(), QProblem::removeConstraint(), rotate(), Bounds::rotate(), QProblem::setupAuxiliaryQP(), QProblemB::setupAuxiliaryQP(), QProblem::setupAuxiliaryQPbounds(), QProblemB::setupAuxiliaryQPbounds(), SQProblemSchur::setupAuxiliaryWorkingSet(), QProblem::setupAuxiliaryWorkingSet(), QProblemB::setupAuxiliaryWorkingSet(), SQProblem::setupNewAuxiliaryQP(), QProblem::shallRefactorise(), QProblemB::shallRefactorise(), shift(), Bounds::shift(), and QProblem::updateActivitiesForHotstart().
|
inlineinherited |
Returns type of (constraints') bound.
i | Number of (constraints') bound. |
References SubjectTo::n, ST_UNKNOWN, and SubjectTo::type.
Referenced by QProblem::dropInfeasibles(), QProblemB::obtainAuxiliaryWorkingSet(), QProblem::obtainAuxiliaryWorkingSet(), QProblem::performDriftCorrection(), QProblemB::performDriftCorrection(), QProblemB::performRamping(), QProblem::performRamping(), QProblemB::performRatioTest(), QProblem::performStep(), rotate(), Bounds::rotate(), setupAll(), Bounds::setupAll(), QProblem::setupAuxiliaryQPbounds(), QProblemB::setupAuxiliaryQPbounds(), QProblem::setupAuxiliaryWorkingSet(), SQProblem::setupNewAuxiliaryQP(), QProblem::setupSubjectToType(), shift(), Bounds::shift(), and QProblem::updateActivitiesForHotstart().
|
inlineinherited |
Returns status of lower (constraints') bounds.
References SubjectTo::noLower.
Referenced by QProblem::performStep(), QProblemB::performStep(), QProblem::printProperties(), and QProblemB::printProperties().
|
inlineinherited |
Returns status of upper bounds.
References END_NAMESPACE_QPOASES, and SubjectTo::noUpper.
Referenced by QProblem::performStep(), QProblemB::performStep(), QProblem::printProperties(), and QProblemB::printProperties().
returnValue Constraints::init | ( | int_t | _n = 0 | ) |
Initialises object with given number of constraints.
_n | Number of constraints. |
References active, clear(), inactive, SubjectTo::init(), Indexlist::init(), RET_INVALID_ARGUMENTS, and THROWERROR.
Referenced by Constraints(), QProblem::QProblem(), QProblem::reset(), QProblem::setupAuxiliaryQP(), and SQProblem::setupNewAuxiliaryQP().
returnValue Constraints::moveActiveToInactive | ( | int_t | number | ) |
Moves index of a constraint from index list of active to that of inactive constraints.
number | Number 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.
Referenced by SQProblemSchur::removeConstraint(), QProblem::removeConstraint(), and SQProblemSchur::setupAuxiliaryWorkingSet().
returnValue Constraints::moveInactiveToActive | ( | int_t | number, |
SubjectToStatus | _status | ||
) |
Moves index of a constraint from index list of inactive to that of active constraints.
number | Number of constraint to become active. |
_status | Status 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.
Referenced by SQProblemSchur::addConstraint(), QProblem::addConstraint(), and SQProblemSchur::setupAuxiliaryWorkingSet().
Constraints & Constraints::operator= | ( | const Constraints & | rhs | ) |
Assignment operator (deep copy).
rhs | Rhs object. |
References clear(), copy(), and SubjectTo::operator=().
returnValue Constraints::print | ( | ) |
Prints information on constraints object (in particular, lists of inactive and active constraints.
References getActive(), getInactive(), getNAC(), getNIAC(), Indexlist::getNumberArray(), MAX_STRING_LENGTH, myPrintf(), SubjectTo::n, REFER_NAMESPACE_QPOASES, and SUCCESSFUL_RETURN.
|
protectedinherited |
Removes the index of a constraint or bound from index set.
indexlist | Index list from which the new index shall be removed. |
removenumber | Number 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 moveActiveToInactive(), Bounds::moveFixedToFree(), Bounds::moveFreeToFixed(), and moveInactiveToActive().
|
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}
offset | Rotation 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.
|
inlineinherited |
Sets status of lower (constraints') bounds.
_status | Status of lower (constraints') bounds. |
References SubjectTo::noLower.
Referenced by QProblemB::setupSubjectToType(), and QProblem::setupSubjectToType().
|
inlineinherited |
Sets status of upper (constraints') bounds.
_status | Status of upper (constraints') bounds. |
References SubjectTo::noUpper.
Referenced by QProblemB::setupSubjectToType(), and QProblem::setupSubjectToType().
|
inlineinherited |
Sets status of (constraints') bound.
i | Number of (constraints') bound. |
value | Status of (constraints') bound. |
References SubjectTo::n, RET_INDEX_OUT_OF_BOUNDS, SubjectTo::status, SUCCESSFUL_RETURN, and THROWERROR.
Referenced by QProblem::dropInfeasibles(), rotate(), Bounds::rotate(), SQProblem::setupNewAuxiliaryQP(), shift(), and Bounds::shift().
|
inlineinherited |
Sets type of (constraints') bound.
i | Number of (constraints') bound. |
value | Type of (constraints') bound. |
References SubjectTo::n, RET_INDEX_OUT_OF_BOUNDS, SUCCESSFUL_RETURN, THROWERROR, and SubjectTo::type.
Referenced by rotate(), Bounds::rotate(), QProblem::setA(), QProblem::setupAuxiliaryWorkingSet(), QProblemB::setupSubjectToType(), QProblem::setupSubjectToType(), shift(), and Bounds::shift().
|
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.
_status | Desired initial status for all bounds. |
References END_NAMESPACE_QPOASES, 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().
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!
References setupAll(), and ST_INACTIVE.
Referenced by QProblem::setupAuxiliaryQP(), SQProblem::setupNewAuxiliaryQP(), and QProblem::solveInitialQP().
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!
References setupAll(), and ST_LOWER.
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!
References setupAll(), and ST_UPPER.
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.
number | Number of new constraint. |
_status | Status 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().
|
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}
offset | Shift 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.
|
protectedinherited |
Swaps the indices of two constraints or bounds within the index set.
indexlist | Index list in which the indices shold be swapped. |
number1 | Number of first constraint or bound. |
number2 | Number of second constraint or bound. |
References END_NAMESPACE_QPOASES, RET_INVALID_ARGUMENTS, RET_NOTHING_TO_DO, RET_SWAPINDEX_FAILED, SubjectTo::status, SUCCESSFUL_RETURN, Indexlist::swapNumbers(), THROWERROR, and THROWWARNING.
Referenced by Bounds::swapFree().
|
protected |
|
protected |
|
protectedinherited |
Total number of constraints/bounds.
Referenced by SubjectTo::copy(), flipFixed(), Bounds::flipFixed(), getNC(), SubjectTo::getNumberOfType(), Bounds::getNV(), SubjectTo::getStatus(), SubjectTo::getType(), SubjectTo::init(), moveActiveToInactive(), Bounds::moveFixedToFree(), Bounds::moveFreeToFixed(), moveInactiveToActive(), print(), Bounds::print(), rotate(), Bounds::rotate(), SubjectTo::setStatus(), SubjectTo::setType(), setupAll(), Bounds::setupAll(), Bounds::setupBound(), setupConstraint(), shift(), Bounds::shift(), and Bounds::swapFree().
|
protectedinherited |
This flag indicates if there is no lower bound on any variable.
Referenced by SubjectTo::copy(), SubjectTo::hasNoLower(), SubjectTo::init(), and SubjectTo::setNoLower().
|
protectedinherited |
This flag indicates if there is no upper bound on any variable.
Referenced by SubjectTo::copy(), SubjectTo::hasNoUpper(), SubjectTo::init(), and SubjectTo::setNoUpper().
|
protectedinherited |
Status of constraints/bounds.
Referenced by SubjectTo::addIndex(), SubjectTo::clear(), SubjectTo::copy(), flipFixed(), Bounds::flipFixed(), SubjectTo::getStatus(), SubjectTo::init(), SubjectTo::removeIndex(), SubjectTo::setStatus(), SubjectTo::SubjectTo(), and SubjectTo::swapIndex().
|
protectedinherited |
Type of constraints/bounds.
Referenced by SubjectTo::clear(), SubjectTo::copy(), SubjectTo::getNumberOfType(), SubjectTo::getType(), SubjectTo::init(), SubjectTo::setType(), and SubjectTo::SubjectTo().