16#ifndef MINOTAURPARMINLPDIVING_H
17#define MINOTAURPARMINLPDIVING_H
30 typedef const Solution* ConstSolutionPtr;
31 typedef VarBoundMod* VarBoundModPtr;
58 struct DivingheurStats {
98 double wallTime)
const;
121 std::stack<Modification *> &nlpMods,
125 void unfixInts(std::stack<Modification *> &nlpMods,
131 if (gettimeofday(&time,NULL)) {
135 return (
double)time.tv_sec + (double)time.tv_usec * .000001;
140 const static std::string me_;
217 UIntVector& violated,
218 std::stack<VarBoundModPtr>& mods,
220 ModVector& lastNodeMods,
222 DoubleVector& avgDual,
223 double* gradientObj);
236 std::stack<VarBoundModPtr>& mods);
253 ModVector& lastNodesMods, DoubleVector& score,
254 DoubleVector& avgDual,
double* gradientObj);
268 double* gradientObj);
283 DoubleVector& avgDual, UIntVector& violated,
285 DoubleVector& score,
double* gradientObj,
309 ModVector& lastNodesMods, DoubleVector& score,
310 DoubleVector& avgDual,
double* gradientObj);
324 ModVector& lastNodesMods, DoubleVector& score,
325 DoubleVector& avgDual,
double* gradientObj);
386 UIntVector& violated);
408 ModVector& lastNodesMods, DoubleVector& score,
409 DoubleVector& avgDual,
double* gradientObj);
Define abstract base class for heuristics of various kinds.
Definition: Environment.h:28
Definition: Heuristic.h:30
Definition: LinearHandler.h:60
Parallel Diving heuristic for MINLPs.
Definition: ParMINLPDiving.h:81
UInt VectorLength_(UInt numfrac, const double *x, Direction d, Order o, ProblemPtr p, UIntVector &violated, std::stack< VarBoundModPtr > &mods, LinearHandler *lh, ModVector &lastNodesMods, DoubleVector &score, DoubleVector &avgDual, double *gradientObj)
Vector Length selection method for fractional variable.
Definition: ParMINLPDiving.cpp:1105
UInt numLevels_
Number of subsets to fix the fractional variables in each round.
Definition: ParMINLPDiving.h:212
UInt ReducedCost_(UInt numfrac, const double *x, Direction d, Order o, ProblemPtr p, UIntVector &violated, std::stack< VarBoundModPtr > &mods, LinearHandler *lh, ModVector &lastNodesMods, DoubleVector &score, DoubleVector &avgDual, double *gradientObj)
Reduced cost diving selection method for fractional variable.
Definition: ParMINLPDiving.cpp:647
double intTol_
Gradient of objective function for vector length diving.
Definition: ParMINLPDiving.h:160
void updateAvgDual_(ConstSolutionPtr sol, DoubleVector &avgDual, DivingheurStats *stats)
Update the average of dual multiplier.
Definition: ParMINLPDiving.cpp:1092
EnginePtr e_
Engine being used to solve the problems during dive.
Definition: ParMINLPDiving.h:147
DivingheurStats * stats_
Violated variable fraction part list.
Definition: ParMINLPDiving.h:200
FuncPtr selectHeur_(int i, Direction &d, Order &o)
Select the method, ordering and direction.
Definition: ParMINLPDiving.cpp:779
double getWallTime()
Get wall clock time.
Definition: ParMINLPDiving.h:129
UInt LexBounds_(UInt numfrac, const double *x, Direction d, Order o, ProblemPtr p, UIntVector &violated, std::stack< VarBoundModPtr > &mods, LinearHandler *lh, ModVector &lastNodesMods, DoubleVector &score, DoubleVector &avgDual, double *gradientObj)
Lexicographic selection method for fractional variable.
Definition: ParMINLPDiving.cpp:560
void sort_(UInt left, UInt right, DoubleVector &score, UIntVector &violated)
Sort the score.
Definition: ParMINLPDiving.cpp:1059
bool vectorFlag_(UInt min_vlength, ProblemPtr p)
Function to decide on vector length diving.
Definition: ParMINLPDiving.cpp:1191
Timer * timer_
Timer for this heuristic.
Definition: ParMINLPDiving.h:203
void writeStats(std::ostream &out) const
writing the statistics to the logger
Definition: ParMINLPDiving.cpp:1257
void writeParStats(std::ostream &out, DivingheurStats *stats, double wallTime) const
writing the statistics to the logger
Definition: ParMINLPDiving.cpp:1215
ParMINLPDiving(EnvPtr env, ProblemPtr p, EnginePtr e)
default constructor
Definition: ParMINLPDiving.cpp:46
void setOrigProb(ProblemPtr minlp)
Set the original problem pointer.
Definition: ParMINLPDiving.h:113
void setAltEngine(EnginePtr nlpe)
Set the alternate (typically NLP) engine pointer.
Definition: ParMINLPDiving.h:110
void restoreBounds_(double *LB_copy, double *UB_copy, UInt vars, ProblemPtr p)
Restore the bounds for the problem.
Definition: ParMINLPDiving.cpp:732
EnginePtr nlpe_
NLP Engine (required only if e_ is LP Engine)
Definition: ParMINLPDiving.h:150
~ParMINLPDiving()
default destructor
Definition: ParMINLPDiving.cpp:95
UInt numThreads_
Number of threads to be used for the heuristic.
Definition: ParMINLPDiving.h:188
UInt isFrac_(const double *x, UIntVector &violated, ProblemPtr p)
The number of fractional variables in current solution.
Definition: ParMINLPDiving.cpp:468
bool shouldDive_()
Function to decide on diving or not.
Definition: ParMINLPDiving.cpp:823
UInt maxSol_
Maximum number of feasible solution required from heuristic.
Definition: ParMINLPDiving.h:176
ProblemPtr minlp_
Original problem (required only if p_ is LP relaxation)
Definition: ParMINLPDiving.h:191
double wallTimeStart_
violated variable index list
Definition: ParMINLPDiving.h:209
virtual std::string getScoreString(UInt i)
Return a string that describes the scoring rule in simple words.
Definition: ParMINLPDiving.cpp:1314
void solve(NodePtr node, RelaxationPtr rel, SolutionPoolPtr s_pool)
call to heuristic
Definition: ParMINLPDiving.cpp:851
void fixInts(const double *x, std::stack< Modification * > &nlpMods, ProblemPtr minlp)
Fix integer variables as in x.
Definition: ParMINLPDiving.cpp:526
EnvPtr env_
Environment.
Definition: ParMINLPDiving.h:153
void solveNLP(ConstSolutionPtr sol, bool *solFound, ProblemPtr minlp, EnginePtr nlpe)
Solve NLP at LP integer feasible solution.
Definition: ParMINLPDiving.cpp:491
virtual std::string getDirectionString(UInt i)
Return a string that describes the rounding direction in simple words.
Definition: ParMINLPDiving.cpp:1287
ProblemPtr p_
Problem to be solved.
Definition: ParMINLPDiving.h:194
void getScore_(const double *x, Scoretype s, DoubleVector &score, ProblemPtr p, DoubleVector &avgDual, double *gradientObj)
Get the score of solution.
Definition: ParMINLPDiving.cpp:241
UInt nSelector_
Number of method for selection of variables.
Definition: ParMINLPDiving.h:185
LoggerPtr logger_
Linear Handler for presolving.
Definition: ParMINLPDiving.h:170
void saveBounds_(double *LB_copy, double *UB_copy, UInt vars)
Save bounds of the problem.
Definition: ParMINLPDiving.cpp:768
double rounding_(double value, Direction d)
Rounding a value in a given direction.
Definition: ParMINLPDiving.cpp:741
virtual std::string getOrderString(UInt i)
Return a string that describes the rounding order in simple words.
Definition: ParMINLPDiving.cpp:1303
void implementDive_(int i, const double *x, SolutionPoolPtr s_pool, ModVector &lastNodesMods, EnginePtr e, ProblemPtr p, DoubleVector &avgDual, UIntVector &violated, std::stack< VarBoundModPtr > &mods, LinearHandler *lh, DoubleVector &score, double *gradientObj, DivingheurStats *stats)
Function to implement diving.
Definition: ParMINLPDiving.cpp:325
UInt maxProbs_
Maximum number of problem-solves allowed for each thread.
Definition: ParMINLPDiving.h:173
UInt FracBounds_(UInt numfrac, const double *x, Direction d, Order o, ProblemPtr p, UIntVector &violated, std::stack< VarBoundModPtr > &mods, LinearHandler *lh, ModVector &lastNodesMods, DoubleVector &score, DoubleVector &avgDual, double *gradientObj)
Fractional selection method for fractional variable.
Definition: ParMINLPDiving.cpp:156
void backtrack_(UInt n_moded, ModVector &lastNodeMods, ProblemPtr p, std::stack< VarBoundModPtr > &mods)
Backtracking method.
Definition: ParMINLPDiving.cpp:110
Definition: Relaxation.h:53
Definition: SolutionPool.h:28
Definition: Solution.h:30
Definition: ActiveNodeStore.h:20
Order
Order of rounding: least fractional or most fractional.
Definition: MINLPDiving.h:42
@ Most
Select the variable with Least fractional part.
Definition: MINLPDiving.h:44
Scoretype
Type of score evaluation for fractional variable.
Definition: MINLPDiving.h:48
@ ReducedCost
Score of variable is the index of the variable.
Definition: MINLPDiving.h:52
@ LexBound
Score of variable is the Vector Length.
Definition: MINLPDiving.h:51
@ VectorLength
Score of variable is the fractional part`.
Definition: MINLPDiving.h:50
Direction
Direction of rounding.
Definition: MINLPDiving.h:34
@ Ceil
Round to the smallest integer.
Definition: MINLPDiving.h:36
@ Farthest
Round to the nearest integer.
Definition: MINLPDiving.h:38
@ Nearest
Round to the largest integer.
Definition: MINLPDiving.h:37
unsigned int UInt
Unsigned integer.
Definition: Types.h:30
A statistic struct for MINLP Diving heuristic.
Definition: MINLPDiving.h:58
UInt totalSol
NLPs solved.
Definition: MINLPDiving.h:66
double time[4]
Solutions obtained.
Definition: MINLPDiving.h:63
UInt iterations[4]
Time for each selection method.
Definition: MINLPDiving.h:64
UInt numSol[4]
NLPs that encountered errors.
Definition: MINLPDiving.h:62
UInt totalProbs
Iterations.
Definition: ParMINLPDiving.h:65
UInt errors[4]
Infeasible NLPs solved.
Definition: MINLPDiving.h:61
double best_obj_value
Local optimal solutions obtained.
Definition: MINLPDiving.h:68
UInt numInfeas[4]
NLPs solved in each selection method.
Definition: MINLPDiving.h:60
UInt numLocal
Solutions found.
Definition: MINLPDiving.h:67
double totalTime
Best objective value of feasible solution.
Definition: MINLPDiving.h:69