Minotaur 0.4.1
Docs for developers
|
Handler for convex constraints, based on quesada-grossmann algorithm. More...
#include <STOAHandler.h>
Public Member Functions | |
STOAHandler (EnvPtr env, ProblemPtr minlp, EnginePtr nlpe, MILPEnginePtr milpe, SolutionPoolPtr solPool) | |
Default Constructor. More... | |
~STOAHandler () | |
Destroy. | |
Branches | getBranches (BrCandPtr, DoubleVector &, RelaxationPtr, SolutionPoolPtr) |
Does nothing. More... | |
UInt | getNumCalls () |
Return number of callbacks till now. | |
double | getCbTime () |
Return the time taken in callbacks till now. | |
void | setCbTime (double timeval) |
Set the time taken in callbacks till now. | |
void | getBranchingCandidates (RelaxationPtr, const DoubleVector &, ModVector &, BrVarCandSet &, BrCandVector &, bool &) |
Does nothing. More... | |
ModificationPtr | getBrMod (BrCandPtr, DoubleVector &, RelaxationPtr, BranchDirection) |
Does nothing. More... | |
std::string | getName () const |
Return the name of the handler. More... | |
bool | isFeasible (ConstSolutionPtr, RelaxationPtr, bool &, double &) |
Check if a solution is feasible. More... | |
SolveStatus | presolve (PreModQ *, bool *, Solution **) |
Does nothing. More... | |
bool | presolveNode (RelaxationPtr, NodePtr, SolutionPoolPtr, ModVector &, ModVector &) |
Does nothing. More... | |
void | postsolveGetX (const double *, UInt, DoubleVector *) |
Does nothing. | |
void | relaxInitFull (RelaxationPtr, SolutionPool *, bool *) |
Create root relaxation if doing full node relaxations. More... | |
void | relaxInitInc (RelaxationPtr rel, SolutionPool *, bool *) |
Create root relaxation if doing incremental node relaxations. More... | |
void | relaxNodeFull (NodePtr, RelaxationPtr, bool *) |
Create a relaxation for a node, building from scratch. More... | |
void | relaxNodeInc (NodePtr, RelaxationPtr, bool *) |
Create an incremental relaxation for a node. More... | |
void | separate (ConstSolutionPtr, NodePtr, RelaxationPtr, CutManager *, SolutionPoolPtr, ModVector &, ModVector &, bool *, SeparationStatus *) |
add cuts to separate a given point. More... | |
void | solveMILP (double *objfLb, ConstSolutionPtr *sol, SolutionPoolPtr solPool, CutManager *cutMan) |
void | writeStats (std::ostream &out) const |
Write statistics to ostream out. More... | |
RelaxationPtr | getRel () |
bool | fixedNLP (const double *lpx, EnginePtr &nlpe, ProblemPtr &minlp) |
double | newUb (std::vector< UInt > *varIdx, std::vector< double > *varCoeff) |
ConstraintConstIterator | consBegin () const |
Iterate over constraints. Returns the 'begin' iterator. More... | |
ConstraintConstIterator | consEnd () const |
Iterate over constraints. Returns the 'end' iterator. More... | |
void | OACutToCons (const double *lpx, ConstraintPtr con, double *rhs, std::vector< UInt > *varIdx, std::vector< double > *varCoeff, EnginePtr nlpe) |
void | OACutToObj (const double *lpx, double *rhs, std::vector< UInt > *varIdx, std::vector< double > *varCoeff, double ub, EnginePtr nlpe) |
![]() | |
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... | |
Additional Inherited Members | |
![]() | |
ConstraintVector | cons_ |
bool | modProb_ |
If true, modify the original (or transformed) problem. | |
bool | modRel_ |
If true, modify the relaxation of original (or transformed) problem. | |
Handler for convex constraints, based on quesada-grossmann algorithm.
STOAHandler is a derived class of Handler. It adds cuts generated by solving an NLP whenever an integer (but infeasible) solution of LP relaxation is found.
STOAHandler::STOAHandler | ( | EnvPtr | env, |
ProblemPtr | minlp, | ||
EnginePtr | nlpe, | ||
MILPEnginePtr | milpe, | ||
SolutionPoolPtr | solPool | ||
) |
Default Constructor.
[in] | env | Environment pointer. |
[in] | minlp | The minlp for which cuts are generated (Not the relaxation.) |
[in] | nlpe | The engine to solve nonlinear continuous problem. |
|
inlinevirtual |
Iterate over constraints. Returns the 'begin' iterator.
Reimplemented from Minotaur::Handler.
|
inlinevirtual |
Iterate over constraints. Returns the 'end' iterator.
Reimplemented from Minotaur::Handler.
|
inlinevirtual |
Does nothing.
Implements Minotaur::Handler.
|
inlinevirtual |
Does nothing.
Implements Minotaur::Handler.
|
inlinevirtual |
Does nothing.
Implements Minotaur::Handler.
|
virtual |
Return the name of the handler.
Implements Minotaur::Handler.
|
inlinevirtual |
Check if a solution is feasible.
Check if a given solution is feasible for the constraints that are handled by this handler. should_prune is true if the handler finds that the problem itself is infeasible and the current node can be pruned (which is different from a solution not being feasible).
[in] | sol | The solution of the relaxation whose feasibility we want to test. |
[in] | rel | The relaxation. |
[out] | should_prune | True if the relaxation is infeasible and we can prune the node associated. |
[out] | inf_meas | A measure of infeasibility. It may be used by heuristics and other code to make the tree-search faster. Computing this value is optional. |
Implements Minotaur::Handler.
|
inlinevirtual |
Does nothing.
Implements Minotaur::Handler.
|
inlinevirtual |
Does nothing.
Implements Minotaur::Handler.
|
inlinevirtual |
Create root relaxation if doing full node relaxations.
This method is used to add all the variables and constraints handled by this handler, with the understanding that nodes will also be fully rebuilt. 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.
|
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 for a node, building from scratch.
Create a relaxation of the constraints. Either this method, or relaxNodeInc should be called at each node. Here, we only make minor modifications to the same relaxation.
[in] | node | is the node for which relaxation is to be created. |
[in] | rel | is the relaxation that is being constructed. Do not allocate or re-allocate space for it. Just add new variables or constraints to it. |
[out] | is_inf | is true if the node can be pruned. |
Implements Minotaur::Handler.
|
inlinevirtual |
Create an incremental relaxation for a node.
Create a relaxation of the constraints. Either this method, or nodeRelaxFull relax should be called at root node. Usually we only make minor modifications to the same relaxation.
[in] | node | is the node for which relaxation is to be created. |
[in] | rel | is the relaxation that is being constructed. Do not allocate or re-allocate space for it. Just add new variables or constraints to it. |
[out] | is_inf | is true if the node can be pruned. |
Implements Minotaur::Handler.
|
inlinevirtual |
add cuts to separate a given point.
Add cuts to the relaxation to cutoff a solution. We assume that all cuts are globally valid.
[in] | sol | The solution that needs to be cut off |
[in] | node | The node that we are currently solving. |
[in] | rel | The relaxation at this node. |
[in] | cutman | The CutManager where cuts should be sent. |
[in] | s_pool | The SolutionPool containing solutions found so far. |
[out] | sol_found | True if a new solution has been found while separating |
[out] | status | SeparationStatus returned by this routine. |
Implements Minotaur::Handler.
|
virtual |
Write statistics to ostream out.
Reimplemented from Minotaur::Handler.