#include <APPSPACK_Constraints_Linear.hpp>
Collaboration diagram for APPSPACK::Constraints::Linear:

We consider the following linearly constrained problem
The bounds in the inequalities are not required to be finite, e.g., it is allowable that
.
Because it can dramatically improves performance, variable scaling is used. The scaling vector is denoted by
. The scaling can be specified by the user; see Linear Constraint Parameters. If all variable bounds are finite, a default scaling vector is provided; namely
In the case where any element of
is unbounded, the user is required to specify
within the Linear Constraint Parameters.
We define the variables in the scaled space as follows:
Here
and
The scaled problem is then given by
Combining the bound and linear inequality constraints, we get
where
With respect to the scaled system, APPSPACK::Constraints::Linear stores the following as member variables:
,
,
,
, and
.
Definition at line 203 of file APPSPACK_Constraints_Linear.hpp.
Public Member Functions | |
| Linear (Parameter::List ¶ms) | |
| Constructor. | |
| ~Linear () | |
| Destructor. | |
| void | print () const |
| Prints the bounds, scaling, and general linear constraint information. | |
Accessors | |
| double | getEpsMach () const |
| Returns machine epsilon value, epsMach. | |
| const Vector & | getScaling () const |
| Returns scaling vector, scaling. | |
| const Vector & | getLower () const |
| Return vector of lower bounds, bLower. | |
| const Vector & | getUpper () const |
| Return vector of upper bounds, bUpper. | |
| const Vector & | getBhatLower () const |
| Return lower bound on scaled inequality constraints, bIneqLower. | |
| const Vector & | getBhatUpper () const |
| Return upper bound on scaled inequality constraints, bIneqUpper. | |
| const Vector & | getBtildeEq () const |
| Return right-hand side vector of scaled equality constraints, bEq. | |
| const Matrix & | getAhat () const |
| Return coefficient matrix for scaled inequality constraints, aIneq. | |
| const Matrix & | getAtildeEq () const |
| Return coefficient matrix for scaled equality constraints, aEq. | |
| void | getNominalX (Vector &x) const |
| Returns a point (x) that is initially feasible with respect to the bound constraints. | |
Projectors. | |
| void | scale (Vector &x) const |
| Maps x to scaled space via affine linear transformation. | |
| void | unscale (Vector &w) const |
| Maps w to unscaled space via affine linear transformation. | |
Feasibility verifiers. | |
| bool | isFeasible (const Vector &x) const |
| Return true if feasible, false otherwise. | |
| void | assertFeasible (const Vector &x) const |
| Throws an error if x is infeasible; see isFeasible(). | |
Constraint analysis. | |
| bool | isBoundsOnly () const |
| Returns true if only variable bounds exists, false otherwise. | |
| double | maxStep (const Vector &x, const Vector &d, double step) const |
| Returns maximum feasible step in interval [0, step] along direction d. | |
| void | getActiveIndex (const Vector &xdist, double epsilon, vector< ActiveType > &index) const |
| Returns a vector indexing bound type with respect to inequality constraints. | |
| void | formDistanceVector (const Vector &x, Vector &xdist) const |
| Returns (nullspace projected) distance from x to each inequality constraints. | |
| void | snapToBoundary (Vector &x, double esnap) const |
| Attempts to find the closest point to x that satisfies all constraints within distance esnap. | |
| void | makeBoundsFeasible (Vector &x) const |
| Makes x feasible with respect to variable bounds. | |
| void | formSnapSystem (const Vector &xtilde, double esnap, Matrix &Asnap, Vector &bsnap) const |
| Forms system Asnap, and bsnap. On exit Asnap has full row rank. | |
Private Member Functions | |
| void | error (const string &fname, const string &msg) const |
| Print an error message and throw an exception. | |
| void | errorCheck () const |
| Error checks on input. | |
Constructor assistance. | |
| void | setup (Parameter::List ¶ms) |
| Used by constructor to fill the parameter list with appropriate defaults and return the scaling. | |
| void | setupBounds (Parameter::List ¶ms) |
| Sets up lower and upper bounds. | |
| void | setupScaling (Parameter::List ¶ms) |
| Sets up scaling vector. | |
| void | setupRhs (Parameter::List ¶ms) |
| Form the corresponding right-hand side vector of the coefficient matrix. | |
| void | setupMatrix (Parameter::List ¶ms) |
| Form the coefficient matrix wrt bound and linear constraints. | |
| void | setupScaledSystem () |
| Form the corresponding scaled right-hand side vector of the coefficient matrix. | |
Constraint categorizers. | |
| StateType | getIneqState (int i, BoundType bType, const Vector &xTilde, double epsilon=-1) const |
| Get state of inequality constraint i with respect to the given point. | |
| StateType | getEqState (int i, const Vector &xTilde, double epsilon=-1) const |
| Get state of equality constraint i with respect to the given point. | |
| bool | isEqualityFeasible (const Vector &xtilde) const |
| Returns true if equality constraints are feasible. | |
| bool | isInequalityFeasible (const Vector &xtilde) const |
| Returns true if inequality constraints are feasible. | |
Private Attributes | |
| const double | epsMach |
| Machine epsilon. | |
| bool | displayMatrix |
| Vector | scaling |
| Scaling. | |
| Vector | bLower |
| Unscaled lower bounds. | |
| Vector | bUpper |
| Unscaled upper bounds. | |
Unscaled-sytem members. | |
| Matrix | aIneq |
| The coefficient matrix of the unscaled general linear inequality constraints. | |
| Matrix | aEq |
| The coefficient matrix of unscaled linear equality constraints. | |
| Vector | bIneqLower |
| The unscaled lower bounds on general linear inequality constraints. | |
| Vector | bIneqUpper |
| The unscaled upper bounds on general linear inequality constraints. | |
| Vector | bEq |
| The right-hand side of unscaled equality constraints. | |
Scaled-sytem members. | |
| Matrix | aHat |
| The scaled coefficient matrix of the linear (bound and general) inequality constraints. | |
| Vector | aHatZNorm |
| Holds two norms of rows of aHat projected into the nullspace of the scaled equality constraints. | |
| Vector | aHatNorm |
| Holds two norms of rows of aHat. | |
| Vector | bHatLower |
| The scaled lower bounds on the linear (bound and general) inequality constraints. | |
| Vector | bHatUpper |
| The scaled upper bounds on the linear (bound and general) inequality constraints. | |
| Matrix | aTildeEq |
| The scaled coefficient matrix of linear equality constraints. | |
| Vector | bTildeEq |
| The scaled right-hand side of equality coefficient matrix. | |
| Vector | lHat |
| Used in transforming x to scaled space. | |
|
|
Constructor.
Definition at line 47 of file APPSPACK_Constraints_Linear.cpp. References errorCheck(), and setup(). |
|
|
Destructor.
Definition at line 55 of file APPSPACK_Constraints_Linear.cpp. |
|
|
Returns machine epsilon value, epsMach.
Definition at line 361 of file APPSPACK_Constraints_Linear.cpp. Referenced by APPSPACK::Directions::addCompassDirections(), APPSPACK::Directions::addNormalDirections(), APPSPACK::Directions::appendNewDirections(), and APPSPACK::Directions::buildWithLapack(). |
|
|
Returns scaling vector, scaling.
Definition at line 366 of file APPSPACK_Constraints_Linear.cpp. Referenced by APPSPACK::Directions::addCompassDirections(), APPSPACK::Directions::addNormalDirections(), APPSPACK::Directions::buildWithCddlib(), APPSPACK::Directions::buildWithLapack(), APPSPACK::Directions::buildWithNothing(), APPSPACK::Directions::generateUnconstrained(), and APPSPACK::Solver::initializeBestPointPtr(). |
|
|
Return vector of lower bounds, bLower.
Definition at line 371 of file APPSPACK_Constraints_Linear.cpp. |
|
|
Return vector of upper bounds, bUpper.
Definition at line 376 of file APPSPACK_Constraints_Linear.cpp. |
|
|
Return lower bound on scaled inequality constraints, bIneqLower.
Definition at line 381 of file APPSPACK_Constraints_Linear.cpp. |
|
|
Return upper bound on scaled inequality constraints, bIneqUpper.
Definition at line 386 of file APPSPACK_Constraints_Linear.cpp. |
|
|
Return right-hand side vector of scaled equality constraints, bEq.
Definition at line 391 of file APPSPACK_Constraints_Linear.cpp. |
|
|
Return coefficient matrix for scaled inequality constraints, aIneq.
Definition at line 396 of file APPSPACK_Constraints_Linear.cpp. Referenced by APPSPACK::Directions::buildNormalCone(). |
|
|
Return coefficient matrix for scaled equality constraints, aEq.
Definition at line 401 of file APPSPACK_Constraints_Linear.cpp. Referenced by APPSPACK::Directions::buildNormalCone(). |
|
|
Returns a point (x) that is initially feasible with respect to the bound constraints.
Definition at line 406 of file APPSPACK_Constraints_Linear.cpp. References bLower, bUpper, APPSPACK::exists(), APPSPACK::Vector::resize(), scaling, and APPSPACK::Vector::size(). Referenced by APPSPACK::Solver::initializeBestPointPtr(). |
|
|
Maps x to scaled space via affine linear transformation.
Replaces Definition at line 422 of file APPSPACK_Constraints_Linear.cpp. References error(), lHat, scaling, and APPSPACK::Vector::size(). Referenced by formDistanceVector(), isFeasible(), maxStep(), and snapToBoundary(). |
|
|
Maps w to unscaled space via affine linear transformation.
Replaces Definition at line 431 of file APPSPACK_Constraints_Linear.cpp. References error(), lHat, scaling, and APPSPACK::Vector::size(). Referenced by snapToBoundary(). |
|
|
Return true if feasible, false otherwise. We consider the point x to be feasible with respect to a given constraint if it is a distance of no more than epsMach away; see getIneqState() and getEqState(). Definition at line 440 of file APPSPACK_Constraints_Linear.cpp. References error(), isEqualityFeasible(), isInequalityFeasible(), scale(), scaling, and APPSPACK::Vector::size(). Referenced by assertFeasible(), APPSPACK::Solver::generateTrialPoints(), and APPSPACK::Solver::initializeBestPointPtr(). |
|
|
Throws an error if x is infeasible; see isFeasible().
Definition at line 461 of file APPSPACK_Constraints_Linear.cpp. References error(), and isFeasible(). Referenced by APPSPACK::Solver::generateTrialPoints(), and APPSPACK::Solver::initializeBestPointPtr(). |
|
|
Returns true if only variable bounds exists, false otherwise.
Definition at line 467 of file APPSPACK_Constraints_Linear.cpp. References aEq, aIneq, and APPSPACK::Matrix::empty(). |
|
||||||||||||||||
|
Returns maximum feasible step in interval [0, step] along direction d.
is returned that gives the maximum feasible step that can be made along direction d. A constraint is said to be a blocking constraint if d points towards its infeasible region. A finite variable lower bound is considered to be a blocking constraint if
Similarly, a finite variable upper bound is considered to be a blocking constraint if
A general linear inequality
If any blocking inequality constraint is deemed active, via a call to APPSPACK::Constraints::Linear::getIneqState, a value of
is returned, where
Definition at line 472 of file APPSPACK_Constraints_Linear.cpp. References APPSPACK::Constraints::Active, aEq, aIneq, bIneqLower, bIneqUpper, bLower, bUpper, APPSPACK::Matrix::empty(), getIneqState(), APPSPACK::Matrix::getNrows(), APPSPACK::Constraints::Inactive, APPSPACK::Constraints::LowerBound, maxStep(), APPSPACK::Matrix::multVec(), scale(), scaling, APPSPACK::Vector::size(), and APPSPACK::Constraints::UpperBound. Referenced by APPSPACK::Solver::generateTrialPoints(), and maxStep(). |
|
||||||||||||||||
|
Returns a vector indexing bound type with respect to inequality constraints.
Definition at line 559 of file APPSPACK_Constraints_Linear.cpp. References aHat, APPSPACK::Matrix::getNrows(), and APPSPACK::Matrix::resize(). Referenced by APPSPACK::Directions::updateConstraintState(). |
|
||||||||||||
|
Returns (nullspace projected) distance from x to each inequality constraints.
In order to differentiate between lower bounds and upper bounds, the inequality constraints are implicitly stacked as follows:
Thus on exit, the length of xdist is necessarily twice the number of rows in
and let
If
If
Definition at line 587 of file APPSPACK_Constraints_Linear.cpp. References aHat, aHatZNorm, bHatLower, bHatUpper, APPSPACK::dne(), APPSPACK::exists(), APPSPACK::Matrix::getNrows(), APPSPACK::Matrix::multVec(), APPSPACK::Vector::resize(), and scale(). Referenced by APPSPACK::Directions::computeNewDirections(). |
|
||||||||||||
|
Attempts to find the closest point to x that satisfies all constraints within distance esnap.
is then formed that consists of the rows followed by the rows of that correspond to nearby constraints. An LQ factorization of is then formed to determine a linearly independent subset of . is then redefined (if necessary) so that has full row rank. The corresponding right-hand side vector is at this time also formed. The solution to the below equality-constrained least-squares problem is then computed:
On exit, x is set equal to Method requires that APPSPACK be configured with LAPACK. Definition at line 631 of file APPSPACK_Constraints_Linear.cpp. References APPSPACK::Matrix::constrainedLSQR(), formSnapSystem(), scale(), and unscale(). Referenced by APPSPACK::Solver::generateTrialPoints(), and APPSPACK::Solver::initializeBestPointPtr(). |
|
|
Makes x feasible with respect to variable bounds. On exit,
Here Definition at line 648 of file APPSPACK_Constraints_Linear.cpp. References bLower, bUpper, APPSPACK::exists(), and APPSPACK::Vector::size(). Referenced by APPSPACK::Solver::initializeBestPointPtr(). |
|
||||||||||||||||||||
|
Forms system Asnap, and bsnap. On exit Asnap has full row rank. Add more comments Definition at line 659 of file APPSPACK_Constraints_Linear.cpp. References APPSPACK::Matrix::addRow(), aHat, aHatNorm, bHatLower, bHatUpper, APPSPACK::Matrix::clear(), APPSPACK::Matrix::empty(), epsMach, APPSPACK::Vector::erase(), APPSPACK::exists(), APPSPACK::Matrix::getNcols(), APPSPACK::Matrix::getNrows(), APPSPACK::Matrix::getRow(), isEqualityFeasible(), APPSPACK::Matrix::multVec(), APPSPACK::Matrix::pruneDependentRows(), APPSPACK::Vector::push_back(), APPSPACK::Vector::resize(), and APPSPACK::Vector::size(). Referenced by snapToBoundary(). |
|
|
Prints the bounds, scaling, and general linear constraint information.
Definition at line 738 of file APPSPACK_Constraints_Linear.cpp. References aEq, aIneq, bEq, bIneqLower, bIneqUpper, bLower, bUpper, APPSPACK::Matrix::empty(), APPSPACK::exists(), scaling, and APPSPACK::Vector::size(). |
|
|
Used by constructor to fill the parameter list with appropriate defaults and return the scaling.
Definition at line 59 of file APPSPACK_Constraints_Linear.cpp. References setupBounds(), setupMatrix(), setupRhs(), setupScaledSystem(), and setupScaling(). Referenced by Linear(). |
|
|
Sets up lower and upper bounds.
Definition at line 68 of file APPSPACK_Constraints_Linear.cpp. References APPSPACK::Vector::assign(), bLower, bUpper, APPSPACK::Vector::copyToBool(), APPSPACK::dne(), APPSPACK::Vector::empty(), error(), APPSPACK::exists(), APPSPACK::Parameter::List::getParameter(), APPSPACK::Parameter::List::getVectorParameter(), APPSPACK::Parameter::List::isParameterVector(), scaling, and APPSPACK::Vector::size(). Referenced by setup(). |
|
|
Sets up scaling vector.
Definition at line 151 of file APPSPACK_Constraints_Linear.cpp. References bLower, bUpper, APPSPACK::Vector::empty(), error(), APPSPACK::exists(), APPSPACK::Parameter::List::getParameter(), APPSPACK::Vector::push_back(), scaling, and APPSPACK::Vector::size(). Referenced by setup(). |
|
|
Form the corresponding right-hand side vector of the coefficient matrix.
Definition at line 195 of file APPSPACK_Constraints_Linear.cpp. References aEq, aIneq, APPSPACK::Vector::assign(), bEq, bIneqLower, bIneqUpper, APPSPACK::dne(), error(), APPSPACK::Matrix::getNrows(), APPSPACK::Parameter::List::getVectorParameter(), APPSPACK::Parameter::List::isParameterVector(), and APPSPACK::Vector::size(). Referenced by setup(). |
|
|
Form the coefficient matrix wrt bound and linear constraints.
Definition at line 172 of file APPSPACK_Constraints_Linear.cpp. References aEq, aIneq, APPSPACK::Matrix::empty(), error(), APPSPACK::Parameter::List::getMatrixParameter(), APPSPACK::Matrix::getNcols(), APPSPACK::Parameter::List::isParameterMatrix(), scaling, and APPSPACK::Vector::size(). Referenced by setup(). |
|
|
Form the corresponding scaled right-hand side vector of the coefficient matrix.
Definition at line 226 of file APPSPACK_Constraints_Linear.cpp. References APPSPACK::Matrix::addMatrix(), aEq, aHat, aHatNorm, aHatZNorm, aIneq, aTildeEq, bEq, bHatLower, bHatUpper, bIneqLower, bIneqUpper, bLower, bTildeEq, bUpper, APPSPACK::dne(), APPSPACK::Matrix::empty(), epsMach, error(), APPSPACK::exists(), APPSPACK::Matrix::getNcols(), APPSPACK::Matrix::getNrows(), APPSPACK::Matrix::getRow(), lHat, APPSPACK::Matrix::multMat(), APPSPACK::Matrix::multVec(), APPSPACK::Vector::norm(), APPSPACK::Matrix::nullSpace(), APPSPACK::Vector::push_back(), APPSPACK::Vector::resize(), APPSPACK::Matrix::scale(), scaling, APPSPACK::Matrix::setToIdentity(), and APPSPACK::Vector::size(). Referenced by setup(). |
|
||||||||||||||||||||
|
Get state of inequality constraint i with respect to the given point.
Computes the state of inequality constraint i with respect to point
Constraint i is deemed active if the (scaled) point is within a distance of
Definition at line 795 of file APPSPACK_Constraints_Linear.cpp. References aHat, aHatNorm, bHatLower, bHatUpper, APPSPACK::Vector::dot(), APPSPACK::exists(), and APPSPACK::Matrix::getRow(). Referenced by isInequalityFeasible(), and maxStep(). |
|
||||||||||||||||
|
Get state of equality constraint i with respect to the given point.
Computes the state of equality constraint i with respect to point
Constraint i is deemed satisfied if the (scaled) point is within a distance of
Definition at line 830 of file APPSPACK_Constraints_Linear.cpp. References aTildeEq, bTildeEq, APPSPACK::Vector::dot(), APPSPACK::Matrix::getRow(), and APPSPACK::Vector::norm(). Referenced by isEqualityFeasible(). |
|
|
Returns true if equality constraints are feasible. see getEqState() Definition at line 855 of file APPSPACK_Constraints_Linear.cpp. References aTildeEq, getEqState(), APPSPACK::Matrix::getNrows(), and APPSPACK::Constraints::Violated. Referenced by formSnapSystem(), and isFeasible(). |
|
|
Returns true if inequality constraints are feasible. see getIneqState() Definition at line 868 of file APPSPACK_Constraints_Linear.cpp. References aHat, getIneqState(), APPSPACK::Matrix::getNrows(), APPSPACK::Constraints::LowerBound, APPSPACK::Constraints::UpperBound, and APPSPACK::Constraints::Violated. Referenced by isFeasible(). |
|
||||||||||||
|
Print an error message and throw an exception.
Definition at line 732 of file APPSPACK_Constraints_Linear.cpp. Referenced by assertFeasible(), errorCheck(), isFeasible(), scale(), setupBounds(), setupMatrix(), setupRhs(), setupScaledSystem(), setupScaling(), and unscale(). |
|
|
Error checks on input.
Definition at line 330 of file APPSPACK_Constraints_Linear.cpp. References aEq, aIneq, bIneqLower, bIneqUpper, bLower, bUpper, APPSPACK::Matrix::empty(), error(), APPSPACK::exists(), APPSPACK::Matrix::getNrows(), scaling, and APPSPACK::Vector::size(). Referenced by Linear(). |
|
|
Machine epsilon.
Definition at line 579 of file APPSPACK_Constraints_Linear.hpp. Referenced by formSnapSystem(), and setupScaledSystem(). |
|
|
If true, equality and inequality constraint information will be printed explicitly for certain debug levels. Definition at line 584 of file APPSPACK_Constraints_Linear.hpp. |
|
|
Scaling.
Definition at line 587 of file APPSPACK_Constraints_Linear.hpp. Referenced by errorCheck(), getNominalX(), isFeasible(), maxStep(), print(), scale(), setupBounds(), setupMatrix(), setupScaledSystem(), setupScaling(), and unscale(). |
|
|
Unscaled lower bounds.
Definition at line 590 of file APPSPACK_Constraints_Linear.hpp. Referenced by errorCheck(), getNominalX(), makeBoundsFeasible(), maxStep(), print(), setupBounds(), setupScaledSystem(), and setupScaling(). |
|
|
Unscaled upper bounds.
Definition at line 593 of file APPSPACK_Constraints_Linear.hpp. Referenced by errorCheck(), getNominalX(), makeBoundsFeasible(), maxStep(), print(), |