Minotaur 0.4.1
Docs for developers
|
Diving heuristif for MINLPs. More...
#include <MINLPDiving.h>
Public Member Functions | |
MINLPDiving (EnvPtr env, ProblemPtr p, EnginePtr e) | |
default constructor | |
~MINLPDiving () | |
default destructor | |
void | solve (NodePtr node, RelaxationPtr rel, SolutionPoolPtr s_pool) |
call to heuristic More... | |
void | writeStats (std::ostream &out) const |
writing the statistics to the logger More... | |
![]() | |
Heuristic () | |
Default constructor. | |
virtual | ~Heuristic () |
Destroy. | |
virtual void | solve (NodePtr node, RelaxationPtr rel, SolutionPoolPtr s_pool)=0 |
Use this heuristic. More... | |
virtual void | solveNode (ConstSolutionPtr, NodePtr, RelaxationPtr, SolutionPoolPtr) |
Use this heuristic. More... | |
virtual void | writeStats (std::ostream &out) const =0 |
Write statistics to the logger. More... | |
Protected Types | |
typedef UInt(MINLPDiving::* | FuncPtr) (UInt numfrac, const double *x, Direction d, Order o) |
Protected Member Functions | |
void | backtrack_ (UInt n_flipped) |
Backtracking method. More... | |
UInt | FracBounds_ (UInt numfrac, const double *x, Direction d, Order o) |
Fractional selection method for fractional variable. More... | |
void | getScore_ (const double *x, Scoretype s) |
Get the score of solution. More... | |
void | implementDive_ (int i, const double *x, SolutionPoolPtr s_pool) |
Function to implement diving. More... | |
UInt | isFrac_ (const double *x) |
The number of fractional variables in current solution. More... | |
UInt | LexBounds_ (UInt numfrac, const double *x, Direction d, Order o) |
Lexicographic selection method for fractional variable. More... | |
UInt | ReducedCost_ (UInt numfrac, const double *x, Direction d, Order o) |
Reduced cost diving selection method for fractional variable. More... | |
void | restoreBounds_ (double *LB_copy, double *UB_copy, UInt vars) |
Restore the bounds for the problem. More... | |
double | rounding_ (double value, Direction d) |
Rounding a value in a given direction. More... | |
void | saveBounds_ (double *LB_copy, double *UB_copy, UInt vars) |
Save bounds of the problem. More... | |
FuncPtr | selectHeur_ (int i, Direction &d, Order &o) |
Select the method, ordering and direction. More... | |
bool | shouldDive_ () |
Function to decide on diving or not. More... | |
void | sort_ (UInt left, UInt right) |
Sort the score. More... | |
void | updateAvgDual_ (ConstSolutionPtr sol) |
Update the average of dual multiplier. More... | |
UInt | VectorLength_ (UInt numfrac, const double *x, Direction d, Order o) |
Vector Length selection method for fractional variable. More... | |
bool | vectorFlag_ (UInt min_vlength) |
Function to decide on vector length diving. | |
Protected Attributes | |
DoubleVector | avgDual_ |
EnginePtr | e_ |
Engine being used to solve the problem. | |
EnvPtr | env_ |
Environment. | |
double * | gradientObj_ |
Gradient of objective function for vector length diving. | |
double | intTol_ |
ModVector | lastNodeMods_ |
LinearHandler * | lh_ |
Linear Handler for presolving. | |
LoggerPtr | logger_ |
Logger. | |
UInt | maxNLP_ |
Maximum number of NLPs allowed for diving heuristic. | |
UInt | maxSol_ |
Maximum number of feasible solution required from heuristic. | |
std::stack< VarBoundModPtr > | mods_ |
UInt | nSelector_ |
Number of method for selection of variables. | |
ProblemPtr | p_ |
Problem to be solved. | |
DoubleVector | score_ |
Violated variable fraction part list. | |
DivingheurStats * | stats_ |
Statistics for the heuristic. | |
Timer * | timer_ |
Timer for this heuristic. | |
UIntVector | violated_ |
violated variable index list | |
Static Protected Attributes | |
static const std::string | me_ = "MINLP Diving Heuristic: " |
Diving heuristif for MINLPs.
A Diving Heuristic used to find solutions for Mixed Integer NLPs by solving the Relaxed NLP using an NLP engine. The engine is called once initially to generate a solution which is rounded and used for diving.
|
protected |
Backtracking method.
[in] | n_flipped | Number of bound changes made in previous dive |
All the changes are made by unwinding the modification stack n_flipped number of times
Fractional selection method for fractional variable.
[in] | numfrac | Number of fractional variables in current solution |
[in] | x | Constant pointer to primal solution |
[in] | d | Direction of rounding |
[in] | o | Order for selection of fractional variables |
|
protected |
Get the score of solution.
[in] | x | Const pointer to the primal solution |
[in] | s | Scoretype |
The score of the solution is determined based on one of the predefined scoretypes.
|
protected |
Function to implement diving.
[in] | i | Index of the method number |
[in] | x | Const pointer to the root node primal solution |
[in] | s_pool | Pointer to the solution pool |
Method for selection of fractional variable as candidate for rouding are chosen for diving. Changes made to the problem are stored in the stack of modification.
|
protected |
The number of fractional variables in current solution.
[in] | x | Const pointer to primal solution |
Lexicographic selection method for fractional variable.
[in] | numfrac | Number of fractional variables in current solution |
[in] | x | Constant pointer to primal solution |
[in] | d | Direction of rounding |
[in] | o | Order for selection of fractional variables |
Reduced cost diving selection method for fractional variable.
[in] | numfrac | Number of fractional variables in current solution |
[in] | x | Constant pointer to primal solution |
[in] | d | Direction of rounding |
[in] | o | Order for selection of fractional variables |
|
protected |
Restore the bounds for the problem.
[in] | LB_copy | Pointer to saved bounds |
[in] | UB_copt | Pointer to saved bounds |
[in] | vars | Number of variables in the problem |
|
protected |
Rounding a value in a given direction.
[in] | value | Fractional value to be rounded |
[in] | d | Direction to be used for rounding |
|
protected |
Save bounds of the problem.
[in] | LB_copy | Pointer to bounds, space has to be allocated |
[in] | UB_copt | Pointer to bounds, space has to be allocated |
[in] | vars | Number of variables in the problem |
Select the method, ordering and direction.
[in] | i | Index of the method number |
d | Reference to direction of rouding | |
o | Reference to order for selecting variable |
|
protected |
Function to decide on diving or not.
return true or false
We decide not to dive is the problem size is large and hessian is dense
|
virtual |
call to heuristic
Implements Minotaur::Heuristic.
Sort the score.
[in] | left | Beginning of the container |
[in] | right | End of the container |
If the number of non-zero in hessian or number of bin+int <20 don't dive
|
protected |
Update the average of dual multiplier.
[in] | sol | Constant Pointer to the solution |
Vector Length selection method for fractional variable.
[in] | numfrac | Number of fractional variables in current solution |
[in] | x | Constant pointer to primal solution |
[in] | d | Direction of rounding |
[in] | o | Order for selection of fractional variables |
|
virtual |
writing the statistics to the logger
Implements Minotaur::Heuristic.
|
protected |
Average of dual variables from the previous iterations which is to be used to reduced cost diving
|
protected |
If a value is this far from an integer, it is considered integer.
|
protected |
Mods implied by bound changes in the previous node's presolve. We only store mods of one node only.
|
protected |
A stack of modification pointer. All modification are stored in stack and for backtracking the stack is unwinded to restore feasibility