Minotaur 0.4.1
Docs for developers
|
#include <NlPresHandler.h>
Public Member Functions | |
NlPresHandler () | |
Default constructor. | |
NlPresHandler (EnvPtr env, ProblemPtr p) | |
Constructor. | |
~NlPresHandler () | |
Destroy. | |
void | relaxInitFull (RelaxationPtr, SolutionPool *, bool *) |
Create root relaxation if doing full node relaxations. More... | |
void | relaxInitInc (RelaxationPtr, 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... | |
bool | isFeasible (ConstSolutionPtr, RelaxationPtr, bool &, double &) |
void | separate (ConstSolutionPtr, NodePtr, RelaxationPtr, CutManager *, SolutionPoolPtr, ModVector &, ModVector &, bool *, SeparationStatus *) |
void | getBranchingCandidates (RelaxationPtr, const DoubleVector &, ModVector &, BrVarCandSet &, BrCandVector &, bool &) |
Does nothing. More... | |
ModificationPtr | getBrMod (BrCandPtr, DoubleVector &, RelaxationPtr, BranchDirection) |
Does nothing. More... | |
Branches | getBranches (BrCandPtr, DoubleVector &, RelaxationPtr, SolutionPoolPtr) |
Does nothing. More... | |
SolveStatus | presolve (PreModQ *pre_mods, bool *changed, Solution **sol) |
Initial presolve. More... | |
bool | presolveNode (RelaxationPtr p, NodePtr node, SolutionPoolPtr s_pool, ModVector &p_mods, ModVector &rmods) |
Presolve the problem and its relaxation at a node. More... | |
std::string | getName () const |
Return the name of the handler. More... | |
void | simplePresolve (ProblemPtr p, SolutionPoolPtr s_pool, ModVector &t_mods, SolveStatus &status) |
void | writePreStats (std::ostream &out) const |
Write statistics about presolve. More... | |
void | writeStats (std::ostream &out) const |
Write statistics to ostream out. More... | |
void | x_bound_with_c (double a, double b, double c, double *l, double *u, double *l2) |
void | linear_var_set (VariableSet lfvars, FunctionPtr f, VariableSet *linear_terms) |
void | lin_var_bound (VarBoundModVector lfmod, LinearFunctionPtr lf, QuadraticFunctionPtr qf, VariableSet qfvars, VariableSet linear_terms, double cl, double cu, int &change) |
void | get_other_linear_var_bounds (VariablePtr v, double *lflb, double *lfub, VariableSet linear_tSerms, LinearFunctionPtr lf) |
void | quad_var_bound (VarBoundModVector qfmod, LinearFunctionPtr lf, QuadraticFunctionPtr qf, VariableSet qfvars, VariableSet linear_terms, double cl, double cu, int &change) |
void | get_other_quad_var_bounds (VariablePtr v, double *qflb, double *qfub, VariableSet qfvars, QuadraticFunctionPtr qf, LinearFunctionPtr lf) |
void | bilinear_bounds (VariablePtr v, double *qflb1, double *qfub1, VariableSet qfvars, QuadraticFunctionPtr qf) |
void | quad_bound (VariablePtr v, double a, double b, double *l, double *u) |
void | quad_bound_range (VariablePtr v, double a, double blb, double bub, double *l, double *u) |
![]() | |
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. | |
A NlPresHandler presolves nonlinear constraints. Experimental.
void NlPresHandler::bilinear_bounds | ( | VariablePtr | v, |
double * | qflb1, | ||
double * | qfub1, | ||
VariableSet | qfvars, | ||
QuadraticFunctionPtr | qf | ||
) |
Bounds for bilinear variable terms other than the variable given as input to this function to be used for above function, for getting quad var bound
void NlPresHandler::get_other_linear_var_bounds | ( | VariablePtr | v, |
double * | lflb, | ||
double * | lfub, | ||
VariableSet | linear_tSerms, | ||
LinearFunctionPtr | lf | ||
) |
Bounds for variables with only linear terms in function other than the variable given as input to this function to be used for above function, for getting linear var bound
void NlPresHandler::get_other_quad_var_bounds | ( | VariablePtr | v, |
double * | qflb, | ||
double * | qfub, | ||
VariableSet | qfvars, | ||
QuadraticFunctionPtr | qf, | ||
LinearFunctionPtr | lf | ||
) |
Bounds for quadratic variable terms other than the variable given as input to this function to be used for above function, for getting quad var bound
|
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 |
We assume that nonlinear presolve handler is never called for checking feasibility. Always return true.
Implements Minotaur::Handler.
void NlPresHandler::lin_var_bound | ( | VarBoundModVector | lfmod, |
LinearFunctionPtr | lf, | ||
QuadraticFunctionPtr | qf, | ||
VariableSet | qfvars, | ||
VariableSet | linear_terms, | ||
double | cl, | ||
double | cu, | ||
int & | change | ||
) |
Bounds for variables with only linear terms in function
void NlPresHandler::linear_var_set | ( | VariableSet | lfvars, |
FunctionPtr | f, | ||
VariableSet * | linear_terms | ||
) |
Bounds for unvariate case, x>0, b=[blb,bub], for ax^2 +bx >= c get set of variables having only linear terms in fucntion
|
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.
void NlPresHandler::quad_bound | ( | VariablePtr | v, |
double | a, | ||
double | b, | ||
double * | l, | ||
double * | u | ||
) |
Bounds for a quadratic function : x>0 for ax^2 +bx
void NlPresHandler::quad_bound_range | ( | VariablePtr | v, |
double | a, | ||
double | blb, | ||
double | bub, | ||
double * | l, | ||
double * | u | ||
) |
Bounds for a quadratic function : x>0, b=[blb,bub] for ax^2 +bx
void NlPresHandler::quad_var_bound | ( | VarBoundModVector | qfmod, |
LinearFunctionPtr | lf, | ||
QuadraticFunctionPtr | qf, | ||
VariableSet | qfvars, | ||
VariableSet | linear_terms, | ||
double | cl, | ||
double | cu, | ||
int & | change | ||
) |
Bounds for quadratic variable terms
|
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.
|
inlinevirtual |
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 |
Generate valid cuts using linear constraints.
Implements Minotaur::Handler.
|
virtual |
Do simple presolve. This may involve quick bound inference and other simple tricks. Can be cheaper than node presolve and root presolve.
[in] | p | Problem for which presolving to be done. |
[in] | spool | Solution pool. |
[out] | t_mods | Modification derived from presolve. |
[out] | status | Presolve status. |
Reimplemented from Minotaur::Handler.
void NlPresHandler::writePreStats | ( | std::ostream & | out | ) | const |
Write statistics about presolve.
[in] | out | The output stream to which statistics are printed. |
|
virtual |
Write statistics to ostream out.
Reimplemented from Minotaur::Handler.
void NlPresHandler::x_bound_with_c | ( | double | a, |
double | b, | ||
double | c, | ||
double * | l, | ||
double * | u, | ||
double * | l2 | ||
) |
Bounds for unvariate case, x>0 for ax^2 +bx >= c