Minotaur 0.4.1
Docs for developers
|
#include <CxUnivarHandler.h>
Public Member Functions | |
CxUnivarHandler (EnvPtr env, ProblemPtr problem) | |
Default constructor. | |
~CxUnivarHandler () | |
Destroy. | |
void | addConstraint (ConstraintPtr newcon, ConstVariablePtr ivar, ConstVariablePtr ovar, char sense='E') |
void | addConstraint (ConstraintPtr) |
Add constraint to be handled by this handler. More... | |
void | relaxInitFull (RelaxationPtr, SolutionPool *, bool *) |
void | relaxInitInc (RelaxationPtr rel, SolutionPool *, bool *is_inf) |
Create root relaxation if doing incremental node relaxations. More... | |
bool | isFeasible (ConstSolutionPtr sol, RelaxationPtr relaxation, bool &should_prune, double &inf_meas) |
void | separate (ConstSolutionPtr sol, NodePtr node, RelaxationPtr rel, CutManager *cutman, SolutionPoolPtr s_pool, ModVector &p_mods, ModVector &r_mods, bool *sol_found, SeparationStatus *status) |
virtual void | relaxNodeFull (NodePtr, RelaxationPtr, bool *) |
virtual void | relaxNodeInc (NodePtr node, RelaxationPtr rel, bool *isInfeasible) |
virtual void | getBranchingCandidates (RelaxationPtr rel, const DoubleVector &x, ModVector &mods, BrVarCandSet &cands, BrCandVector &gencands, bool &is_inf) |
find branching candidates. More... | |
virtual ModificationPtr | getBrMod (BrCandPtr cand, DoubleVector &x, RelaxationPtr rel, BranchDirection dir) |
Get the modifcation that creates a given (up or down) branch. More... | |
virtual Branches | getBranches (BrCandPtr cand, DoubleVector &x, RelaxationPtr rel, SolutionPoolPtr s_pool) |
Return branches for branching. More... | |
virtual SolveStatus | presolve (PreModQ *pre_mods, bool *changed, Solution **sol) |
Initial presolve. More... | |
virtual bool | presolveNode (RelaxationPtr p, NodePtr node, SolutionPoolPtr s_pool, ModVector &p_mods, ModVector &r_mods) |
Presolve the problem and its relaxation at a node. More... | |
virtual std::string | getName () const |
Return the name of the handler. More... | |
![]() | |
Handler () | |
Default constructor. | |
virtual | ~Handler () |
Destroy. | |
virtual void | addConstraint (ConstraintPtr newcon) |
Add constraint to be handled by this handler. More... | |
virtual ConstraintVector::const_iterator | consBegin () const |
virtual ConstraintVector::const_iterator | consEnd () const |
virtual int | fixNodeErr (RelaxationPtr, ConstSolutionPtr, SolutionPoolPtr, bool &) |
virtual Branches | getBranches (BrCandPtr cand, DoubleVector &x, RelaxationPtr rel, SolutionPoolPtr s_pool)=0 |
Return branches for branching. More... | |
virtual void | getBranchingCandidates (RelaxationPtr rel, const DoubleVector &x, ModVector &mods, BrVarCandSet &cands, BrCandVector &gencands, bool &is_inf)=0 |
find branching candidates. More... | |
virtual ModificationPtr | getBrMod (BrCandPtr cand, DoubleVector &x, RelaxationPtr rel, BranchDirection dir)=0 |
Get the modifcation that creates a given (up or down) branch. More... | |
virtual std::string | getName () const =0 |
Return the name of the handler. More... | |
bool | getStrongerMods (RelaxationPtr rel, NodePtr node, SolutionPoolPtr s_pool, ModVector &p_mods, ModVector &r_mods) |
do node presolve to get mods for stronger branching All params are presolveNode params. | |
virtual bool | isFeasible (ConstSolutionPtr sol, RelaxationPtr rel, bool &should_prune, double &inf_meas)=0 |
Check if a solution is feasible. More... | |
virtual bool | isNeeded () |
Return true if this handler is needed for the problem. More... | |
virtual SolveStatus | presolve (PreModQ *pre_mods, bool *changed, Solution **sol)=0 |
Initial presolve. More... | |
virtual bool | presolveNode (RelaxationPtr rel, NodePtr node, SolutionPoolPtr s_pool, ModVector &p_mods, ModVector &r_mods)=0 |
Presolve the problem and its relaxation at a node. More... | |
virtual bool | postSolveRootNode (RelaxationPtr, SolutionPoolPtr, ConstSolutionPtr, ModVector &, ModVector &) |
At the root node post solve the problem and its relaxation. LP based bound tightening (OBBT) is employed here after filtering variables for which no OBBT is required. More... | |
virtual void | relaxInitFull (RelaxationPtr rel, SolutionPool *sp, bool *is_inf)=0 |
Create root relaxation if doing full node relaxations. More... | |
virtual void | relaxInitInc (RelaxationPtr rel, SolutionPool *sp, bool *is_inf)=0 |
Create root relaxation if doing incremental node relaxations. More... | |
virtual void | relaxNodeFull (NodePtr node, RelaxationPtr rel, bool *is_inf)=0 |
Create a relaxation for a node, building from scratch. More... | |
virtual void | relaxNodeInc (NodePtr node, RelaxationPtr rel, bool *is_inf)=0 |
Create an incremental relaxation for a node. More... | |
virtual void | removeCuts (RelaxationPtr, ConstSolutionPtr) |
virtual void | separate (ConstSolutionPtr sol, NodePtr node, RelaxationPtr rel, CutManager *cutman, SolutionPoolPtr s_pool, ModVector &p_mods, ModVector &r_mods, bool *sol_found, SeparationStatus *status)=0 |
add cuts to separate a given point. More... | |
virtual void | setModFlags (bool mod_prob, bool mod_rel) |
Tell the handler whether the problem will be modified or the relaxation will be modified or both. These modifications will be saved in the tree as well. More... | |
virtual void | simplePresolve (ProblemPtr, SolutionPoolPtr, ModVector &, SolveStatus &status) |
void | undoStrongerMods (ProblemPtr p, RelaxationPtr rel, ModVector &p_mods, ModVector &r_mods) |
Undo Modifications made during stronger branching. More... | |
virtual void | writeStats (std::ostream &) const |
Write statistics to ostream out. More... | |
Protected Attributes | |
double | eTol_ |
Tolerance for constraint violation. | |
double | vTol_ |
Tolerance for when upper and lower bounds considered equal. | |
ProblemPtr | problem_ |
Original problem. | |
LoggerPtr | logger_ |
Logger. | |
CxUnivarConstraintDataVector | cons_data_ |
Internal data associated with each constraint. | |
DoubleVector | tmpX_ |
A temporary vector of zeros, for evaluating functions. | |
DoubleVector | grad_ |
A temporary vector of zeros, for getting gradients. | |
![]() | |
ConstraintVector | cons_ |
bool | modProb_ |
If true, modify the original (or transformed) problem. | |
bool | modRel_ |
If true, modify the relaxation of original (or transformed) problem. | |
Static Protected Attributes | |
static const std::string | me_ = "CxUnivarHandler: " |
For printing. | |
An CxUnivarHandler handles convex univariate functions. The upper relaxation is handled with the single secant inequality, the lower relaxation is handled with linearizations. TODO: This class could easily be extended to handle perspective cuts if a binary varaible is known which turns off the input variable
void CxUnivarHandler::addConstraint | ( | ConstraintPtr | newcon, |
ConstVariablePtr | ivar, | ||
ConstVariablePtr | ovar, | ||
char | sense = 'E' |
||
) |
Adds constraint to list (as all handlers), but also constructs the associated constraint data.
|
inlinevirtual |
Add constraint to be handled by this handler.
[in] | newcon | Constraint to be added. |
Reimplemented from Minotaur::Handler.
|
virtual |
Return branches for branching.
Get branches by branching on the given candidate. In the general scheme for branching, we store only bound changes, though we are also capable of storing other mods.
[in] | cand | Candidate on which the brancher wants to branch. |
[in] | x | The solution of the relaxation at the current node. |
[in] | rel | The relaxation at the current node. |
[in] | s_pool | Best feasible solutions found so far. |
Implements Minotaur::Handler.
|
virtual |
find branching candidates.
A brancher will ask each handler by calling this function to list branching candidates.
[in] | rel | Relaxation being solved at current node. |
[in] | x | Solution of the relaxation. |
[out] | mods | Any modifications that the handler found (Unused). |
[out] | cands | The set of candidates to which branching candidates must be inserted. This set has candidates that want to branch on a single variable only. Other candidates must go into gencands. |
[out] | gencands | The vector of general branching candidates. All candidates that do not want to branch on a variable dichotomy must be added in this vector. |
[out] | is_inf | true if the handler finds that the problem is infeasible and the node can be pruned. |
Implements Minotaur::Handler.
|
virtual |
Get the modifcation that creates a given (up or down) branch.
If one branch is pruned by the brancher (e.g. strong brancher), then we can apply the modifications of other branch to the relaxation without branching. This routine returns such a modification. This function is also called for obtaining modifications for strong branching on a candidate.
[in] | cand | The candidate for which we want the modification. |
[in] | x | The solution of relaxation at current node. |
[in] | rel | The relaxation at current node. |
[in] | dir | The Direction for which we want the modification, Up or Down?. |
Implements Minotaur::Handler.
|
virtual |
Return the name of the handler.
Implements Minotaur::Handler.
|
virtual |
Check feasibility.
Implements Minotaur::Handler.
|
virtual |
Initial presolve.
Do the initial presolve. For now we will assume that presolve modifies the given problem. We do not create a new problem. All modifications that require post-processing for getting the solution back are prepended to 'pre_mods' by the handler.
[in] | pre_mods | A pointer to a queue of PreMod objects. Modifications made by the presolver must be prepended (not appended) to pre_mods. The order is important for post-solve. |
[out] | changed | True if the presolve modified the problem. |
[out] | sol | Optimal solution found by the handler, if any. The status must be SolvedOptimal if and only if sol is created. |
Implements Minotaur::Handler.
|
virtual |
Presolve the problem and its relaxation at a node.
Presolve the problem and its relaxation at a given node. Bound propagation and other simple modifications can be made in this function. It is called after the node relaxation is setup but before it is solved. Both the problem and its relaxation are presolved. Changes to the problem are stored in the tree. Changes to the relaxation are optional and may or may not be stored in the tree.
[in] | rel | Relaxation at the current node. |
[in] | node | Current node. |
[in] | s_pool | Pool of solutions. |
[in] | p_mods | Unused. Modifications to the problem that must be stored in this node so that they are applied to all descendant nodes as well. All modifications must be appended not prepended. |
[out] | r_mods | Modifications to the relaxation that must be stored in this node so that they are applied to all descendant nodes as well. All modifications must be appended not prepended. This may be unnecessary in certain algorithms. |
Implements Minotaur::Handler.
|
inlinevirtual |
For this handler, nothing is different at root or any node when doing full relax
Implements Minotaur::Handler.
|
virtual |
Create root relaxation if doing incremental node relaxations.
This method is used to add all the variables and constraints handled by this handler, with the understanding that nodes will incrementally relaxed. The relaxation is already created, it should not be freed or re-allocated.
[in,out] | rel | The relaxation that is being constructed. |
[in] | Solution | pool for storing any new solutions found. |
[out] | is_inf | is true if the handler finds that the problem is infeasible. |
Implements Minotaur::Handler.
|
inlinevirtual |
Create a relaxation by adding the secant inequality for the upper estimator, and some number of linearization inequalities, at a minimum from the end points
Implements Minotaur::Handler.
|
virtual |
Create a relaxation by updating the secant inequality for the upper estimator, and adding lineariations at the end points, if they are new
Implements Minotaur::Handler.
|
virtual |
Not implemented yet. Eventually, could add violated linearization inequalities for underestimator portion
Implements Minotaur::Handler.