Minotaur 0.4.1
Docs for developers
MINLPDiving.h
Go to the documentation of this file.
1//
2// Minotaur -- It's only 1/2 bull
3//
4// (C)opyright 2008 - 2025 The Minotaur Team.
5//
6
15 #ifndef MINOTAURMINLPDIVING_H
16 #define MINOTAURMINLPDIVING_H
17
18 #include "Heuristic.h"
19 #include <vector>
20 #include <stack>
21 #include "Types.h"
22
23 namespace Minotaur {
24 class Engine;
25 class LinearHandler;
26 class Problem;
27 class Solution;
28 class Timer;
29 class VarBoundMod;
30 typedef const Solution* ConstSolutionPtr;
31 typedef VarBoundMod* VarBoundModPtr;
32
34 typedef enum {
35 Floor,
40
42 typedef enum {
43 Least,
44 Most
46
48 typedef enum {
49 Fractional,
54
59 UInt numNLPs[4];
63 double time[4];
69 double totalTime;
70 };
71
81 class MINLPDiving : public Heuristic {
82 public:
83
86
89
91 void solve(NodePtr node, RelaxationPtr rel, SolutionPoolPtr s_pool);
92
94 void writeStats(std::ostream &out) const;
95
96 protected:
97
98 const static std::string me_;
99
102 DoubleVector avgDual_;
103
106
109
112
115 double intTol_;
116
119 ModVector lastNodeMods_;
120
123
126
129
132
137 std::stack<VarBoundModPtr> mods_;
138
141
144
146 DoubleVector score_;
147
150
153
155 UIntVector violated_;
156
157 typedef UInt (MINLPDiving::*FuncPtr) (UInt numfrac,
158 const double* x, Direction d, Order o);
159
169 void backtrack_(UInt n_flipped);
170
180 UInt FracBounds_(UInt numfrac, const double* x,
181 Direction d, Order o);
182
192 void getScore_(const double* x, Scoretype s);
193
205 void implementDive_(int i, const double*x, SolutionPoolPtr s_pool);
206
214 UInt isFrac_(const double* x);
215
225 UInt LexBounds_(UInt numfrac, const double* x,
226 Direction d, Order o);
227
237 UInt ReducedCost_(UInt numfrac, const double* x,
238 Direction d, Order o);
239
247 void restoreBounds_(double* LB_copy, double* UB_copy, UInt vars);
248
257 double rounding_(double value, Direction d);
258
266 void saveBounds_(double* LB_copy, double* UB_copy, UInt vars);
267
277 FuncPtr selectHeur_(int i, Direction &d, Order &o);
278
287 bool shouldDive_();
288
298 void sort_(UInt left, UInt right);
299
306
316 UInt VectorLength_(UInt numfrac, const double* x,
317 Direction d, Order o);
318
320 bool vectorFlag_(UInt min_vlength);
321
322 };
323
325}
326#endif
327
Define abstract base class for heuristics of various kinds.
Declare important 'types' used in Minotaur.
Definition: Engine.h:34
Definition: Environment.h:28
Definition: Heuristic.h:30
Definition: LinearHandler.h:60
Definition: Logger.h:37
Diving heuristif for MINLPs.
Definition: MINLPDiving.h:81
double * gradientObj_
Gradient of objective function for vector length diving.
Definition: MINLPDiving.h:111
Timer * timer_
Timer for this heuristic.
Definition: MINLPDiving.h:152
UInt maxNLP_
Maximum number of NLPs allowed for diving heuristic.
Definition: MINLPDiving.h:128
DivingheurStats * stats_
Statistics for the heuristic.
Definition: MINLPDiving.h:149
UInt LexBounds_(UInt numfrac, const double *x, Direction d, Order o)
Lexicographic selection method for fractional variable.
Definition: MINLPDiving.cpp:400
bool shouldDive_()
Function to decide on diving or not.
Definition: MINLPDiving.cpp:645
void sort_(UInt left, UInt right)
Sort the score.
Definition: MINLPDiving.cpp:753
double rounding_(double value, Direction d)
Rounding a value in a given direction.
Definition: MINLPDiving.cpp:570
UInt isFrac_(const double *x)
The number of fractional variables in current solution.
Definition: MINLPDiving.cpp:376
DoubleVector score_
Violated variable fraction part list.
Definition: MINLPDiving.h:146
void writeStats(std::ostream &out) const
writing the statistics to the logger
Definition: MINLPDiving.cpp:899
std::stack< VarBoundModPtr > mods_
Definition: MINLPDiving.h:137
DoubleVector avgDual_
Definition: MINLPDiving.h:102
double intTol_
Definition: MINLPDiving.h:115
void restoreBounds_(double *LB_copy, double *UB_copy, UInt vars)
Restore the bounds for the problem.
Definition: MINLPDiving.cpp:561
ProblemPtr p_
Problem to be solved.
Definition: MINLPDiving.h:143
UInt nSelector_
Number of method for selection of variables.
Definition: MINLPDiving.h:140
UInt VectorLength_(UInt numfrac, const double *x, Direction d, Order o)
Vector Length selection method for fractional variable.
Definition: MINLPDiving.cpp:797
ModVector lastNodeMods_
Definition: MINLPDiving.h:119
void saveBounds_(double *LB_copy, double *UB_copy, UInt vars)
Save bounds of the problem.
Definition: MINLPDiving.cpp:597
MINLPDiving(EnvPtr env, ProblemPtr p, EnginePtr e)
default constructor
Definition: MINLPDiving.cpp:42
void getScore_(const double *x, Scoretype s)
Get the score of solution.
Definition: MINLPDiving.cpp:217
LinearHandler * lh_
Linear Handler for presolving.
Definition: MINLPDiving.h:122
UInt maxSol_
Maximum number of feasible solution required from heuristic.
Definition: MINLPDiving.h:131
EnginePtr e_
Engine being used to solve the problem.
Definition: MINLPDiving.h:105
UInt FracBounds_(UInt numfrac, const double *x, Direction d, Order o)
Fractional selection method for fractional variable.
Definition: MINLPDiving.cpp:140
bool vectorFlag_(UInt min_vlength)
Function to decide on vector length diving.
Definition: MINLPDiving.cpp:875
UInt ReducedCost_(UInt numfrac, const double *x, Direction d, Order o)
Reduced cost diving selection method for fractional variable.
Definition: MINLPDiving.cpp:482
void implementDive_(int i, const double *x, SolutionPoolPtr s_pool)
Function to implement diving.
Definition: MINLPDiving.cpp:299
void solve(NodePtr node, RelaxationPtr rel, SolutionPoolPtr s_pool)
call to heuristic
Definition: MINLPDiving.cpp:673
UIntVector violated_
violated variable index list
Definition: MINLPDiving.h:155
LoggerPtr logger_
Logger.
Definition: MINLPDiving.h:125
FuncPtr selectHeur_(int i, Direction &d, Order &o)
Select the method, ordering and direction.
Definition: MINLPDiving.cpp:608
void updateAvgDual_(ConstSolutionPtr sol)
Update the average of dual multiplier.
Definition: MINLPDiving.cpp:786
EnvPtr env_
Environment.
Definition: MINLPDiving.h:108
~MINLPDiving()
default destructor
Definition: MINLPDiving.cpp:83
void backtrack_(UInt n_flipped)
Backtracking method.
Definition: MINLPDiving.cpp:99
Definition: Node.h:54
Definition: Problem.h:74
Definition: Relaxation.h:53
Definition: SolutionPool.h:28
Definition: Solution.h:30
Definition: Timer.h:40
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 errors[4]
Infeasible NLPs solved.
Definition: MINLPDiving.h:61
double best_obj_value
Local optimal solutions obtained.
Definition: MINLPDiving.h:68
UInt totalNLPs
NLP iterations.
Definition: MINLPDiving.h:65
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

Minotaur source code documented by Doxygen 1.9.4 on Thu Apr 24 2025