|
Minotaur 0.4.1
Docs for developers
|
The Constraint class is used to manage a constraint. More...
#include <Constraint.h>
Public Member Functions | |
| Constraint () | |
| Default constructor. | |
| Constraint (UInt id, UInt index, FunctionPtr f, double lb, double ub, std::string name) | |
| This is the only real constructor. All others should call this constructor. | |
| virtual | ~Constraint () |
| Destroy. | |
| double | getActivity (const double *x, int *error) const |
| Get the value or activity at a given point. | |
| bool | getBFlag () const |
| Get the value of the bool flag. | |
| int | getITemp () const |
| void | setITemp (int i) |
| FunctionPtr | getFunction () const |
| Return a pointer to the function. | |
| FunctionType | getFunctionType () const |
| Get the function type. | |
| UInt | getId () const |
| Return the unique id of the constraint. | |
| UInt | getIndex () const |
| Return the index of the constraint. | |
| double | getLb () const |
| Get the 'l' value. or the lower bound constraint on 'f'. | |
| LinearFunctionPtr | getLinearFunction () const |
| Get the linear part of the constraint function 'f'. | |
| const std::string | getName () const |
| NonlinearFunctionPtr | getNonlinearFunction () const |
| Get the nonlinear part of the constraint function 'f'. | |
| QuadraticFunctionPtr | getQuadraticFunction () const |
| Get the quadratic part of the constraint function 'f'. | |
| ConsState | getState () const |
| Get the current state of the constraint: freed, fixed etc. | |
| ConsSrcType | getSrcType () const |
| Get the src type of the constraint. | |
| ConsType | getType () const |
| double | getUb () const |
| Get the 'u' value. or the upper bound constraint on 'f'. | |
| void | setpId (UInt n) |
| int | getpId () |
| void | setUB (double newub) |
| Convexity | getConvexity () |
| void | setConvexity (Convexity convex) |
| void | incrAct () |
| void | setBFlag (bool b) |
| Set the value of the bool flag. | |
| void | setSrcType (ConsSrcType src) |
| Set src type. | |
| void | setType (ConsType type) |
| void | write (std::ostream &out) const |
| display the constraint | |
Protected Member Functions | |
| void | add_ (double cb) |
| Add a constant to the constraint function. lb - c <= f <= ub - c. | |
| void | changeLf_ (LinearFunctionPtr lf) |
| Change the linear part of constraint. | |
| void | changeNlf_ (NonlinearFunctionPtr nlf) |
| Change the nonlinear part of constraint. | |
| void | delFixedVar_ (VariablePtr v, double val) |
| Delete variables fixed at value val. | |
| void | reverseSense_ () |
| Negate the constraint. | |
| void | setId_ (UInt n) |
| Set the id. | |
| void | setIndex_ (UInt n) |
| Set the index. | |
| void | setLb_ (double newlb) |
| Set a new lower bound. | |
| void | setName_ (std::string name) |
| Set name of the constraint. | |
| void | setState_ (ConsState state) |
| Set state of the constraint. | |
| void | setUb_ (double newub) |
| Set a new upper bound. | |
| void | subst_ (VariablePtr out, VariablePtr in, double rat, bool *instay) |
Substitute a variable ![]() ![]() | |
Friends | |
| class | Problem |
| class | PerspCon |
| class | TransSep |
| class | QGHandler |
The Constraint class is used to manage a constraint.
The general form of a constraint is:
![\[
l \leq f(x) \leq u,
\]](form_6.png)
where 






A constraint should only be constructed through a Problem object. Doing this ensures that constraints have ID's unique for that problem. A constraint can thus be part of only one problem. A function 
The state of a constraint describes whether the constraint is free or deleted etc. It is Fixed if each variable in the constraints has been fixed.
A Constraint also stores a map of variables that occur in that constraint. The map tells whether the variable is in a non-linear, or quadratic etc part of the constraint. A variable that occurs once in linear and thrice in quadratic parts will have four entries in the map, once for each occurrence.
The name of a constraint can be set by the user. There are no checks for duplicate names. The ID of the constraint however is unique in the problem.
| Constraint::Constraint | ( | UInt | id, |
| UInt | index, | ||
| FunctionPtr | f, | ||
| double | lb, | ||
| double | ub, | ||
| std::string | name | ||
| ) |
This is the only real constructor. All others should call this constructor.
Create a constraint with
| [in] | id | the unique id of the constraint (determined by Problem object), |
| [in] | index | the index of the constraint in the problem, |
| [in] | f | the function in the body of the constraint, |
| [in] | lb | the lower bound, can be -INFINITY, |
| [in] | ub | the upper bound, can be INFINITY, |
| [in] | name | The string name of the constraint. |
| [in] | src | The source type of the constraint. |
|
protected |
Negate the constraint.
Convert the constraint to
![\[
-u \leq -f(x) \leq -l
\]](form_12.png)
|
inlineprotected |
Set a new lower bound.
The new lower bound can be -INFINITY. It can change the state of the constraint.
|
inlineprotected |
Set a new upper bound.
The new bound can be INFINITY. It can affect the state of the constraint.
|
friend |
Only Problem class can modify a Constraint. All modification methods are private.