Minotaur 0.4.1
Docs for developers
ParQGHandlerAdvance.h
Go to the documentation of this file.
1//
2// Minotaur -- It's only 1/2 bull
3//
4// (C)opyright 2009 - 2025 The Minotaur Team.
5//
6
15#ifndef MINOTAURPARQGHANDLERADVANCE_H
16#define MINOTAURPARQGHANDLERADVANCE_H
17
18#include <stack>
19
20#include "Handler.h"
21#include "Engine.h"
22#include "Problem.h"
23#include "Function.h"
24#include "Linearizations.h"
25
26namespace Minotaur {
27
28struct ParQGStats {
29 size_t nlpS;
30 size_t nlpF;
31 size_t nlpI;
32 size_t nlpIL;
33 size_t cuts;
34 size_t rcuts;
35 size_t fracCuts;
36};
37
38
48
49private:
51 EnvPtr env_;
52
54 double intTol_;
55
57 LoggerPtr logger_;
58
60 static const std::string me_;
61
63 ProblemPtr minlp_;
64
66 std::vector<ConstraintPtr> nlCons_;
67
69 EnginePtr nlpe_;
70
72 std::stack<Modification *> nlpMods_;
73
75 EngineStatus nlpStatus_;
76
77 double * solC_;
78
84 VariablePtr objVar_;
85
87 bool oNl_;
88
90 RelaxationPtr rel_;
91
93 double relobj_;
94
96 double solAbsTol_;
97
99 double solRelTol_;
100
102 double objAbsTol_;
103
105 double objRelTol_;
106
107 LinearizationsPtr extraLin_;
108
109 double maxVioPer_;
110
111 double objVioMul_;
112
113 UInt nodeDep_;
114
115 std::vector<double > consDual_;
116
117 std::string cutMethod_;
118
119 int lastNodeId_;
120
122 ParQGStats *stats_;
123
124public:
134
137
138
139 //double * getCenter() {return solC_;};
140
141 //void setConsDual(std::vector<double > *consDual) {consDual_ = consDual;}
142
143 //void setNodeDep(UInt * nodeDep) {nodeDep_ = nodeDep;}
144
145
147 Branches getBranches(BrCandPtr, DoubleVector &, RelaxationPtr,
149 {return Branches();};
150
153 const DoubleVector &, ModVector &,
154 BrVarCandSet &, BrCandVector &, bool &) {};
155
159 {return ModificationPtr();};
160
161
162 // Base class method.
163 std::string getName() const;
164
165 // Get statistics
166 ParQGStats* getStats() {return stats_; };
167
168 void nlCons();
169
170 void loadProbToEngine();
171
172 void setRelaxation(RelaxationPtr rel);
173
174 // Base class method. Check if x is feasible. x has to satisfy integrality
175 // and also nonlinear constraints.
176 bool isFeasible(ConstSolutionPtr sol, RelaxationPtr relaxation,
177 bool & should_prune, double &inf_meas);
178
180 SolveStatus presolve(PreModQ *, bool *, Solution **) {return Finished;};
181
184 ModVector &)
185 {return false;};
186
188 void postsolveGetX(const double *, UInt, DoubleVector *) {};
189
191 void relaxInitFull(RelaxationPtr rel, SolutionPool *, bool *is_inf);
192
194 void relaxInitInc(RelaxationPtr rel, SolutionPool *, bool *is_inf);
195
197 void relaxNodeFull(NodePtr node, RelaxationPtr rel, bool *is_inf);
198
200 void relaxNodeInc(NodePtr node, RelaxationPtr rel, bool *is_inf);
201
203 void separate(ConstSolutionPtr sol, NodePtr node, RelaxationPtr rel,
204 CutManager *cutman, SolutionPoolPtr s_pool, ModVector &p_mods,
205 ModVector &r_mods, bool *sol_found, SeparationStatus *status);
206
208 void setObjVar();
209
210
211 void solveCenterNLP_(EnginePtr nlpe);
212
214 void writeStats(std::ostream &out) const;
215
216private:
221 void addInitLinearX_(const double *x);
222
227 void cutIntSol_(const double *lpx, CutManager *cutMan,
228 SolutionPoolPtr s_pool, bool *sol_found,
229 SeparationStatus *status);
230
235 void fixInts_(const double *x);
236
237 void findCenter_();
238
239 bool boundaryPtForCons_(double* xnew, const double *xOut,
240 std::vector<UInt > &vioCons);
241
242 void genLin_(const double *x, std::vector<UInt> vioCons, CutManager *cutMan);
243
244 void ECPTypeCut_(const double *x, CutManager *, ConstraintPtr con, double act);
245
246 void ESHTypeCut_(const double *lpx, CutManager *cutMan);
247
248 void objCutAtLpSol_(const double *lpx, CutManager *,
249 SeparationStatus *status, bool fracNodes);
250
256 void initLinear_(bool *isInf);
257
258 bool isIntFeas_(const double* x);
259
260 void dualBasedCons_(ConstSolutionPtr sol);
261
262 void maxVio_(ConstSolutionPtr sol, NodePtr node,
263 CutManager *cutMan,
264 SeparationStatus *status);
265
270 void linearizeObj_();
271
276 void linearAt_(FunctionPtr f, double fval, const double *x,
277 double *c, LinearFunctionPtr *lf, int *error);
282 void cutToCons_(const double *nlpx, const double *lpx, CutManager *,
283 SeparationStatus *status);
284
286 void addCut_(const double *nlpx, const double *lpx, ConstraintPtr con,
287 CutManager *cutman, SeparationStatus *status);
288
289 void consCutsAtLpSol_(const double *lpx, CutManager *cutman,
290 SeparationStatus *status);
291
292
293
298 void cutToObj_(const double *nlpx, const double *lpx, CutManager *,
299 SeparationStatus *status);
300
305 void relax_(bool *is_inf);
306
308 void solveNLP_();
309
311 void unfixInts_();
312
317 void updateUb_(SolutionPoolPtr s_pool, double nlpval, bool *sol_found);
318
319 };
320
321 typedef ParQGHandlerAdvance* ParQGHandlerAdvancePtr;
322}
323#endif
324
Define the base class Engine.
Get information about a Function.
Define abstract base class for handlers of various kinds.
Declare the base class Modification.
Base class for describing candidates for branching on a node in branch-and-bound.
Definition: BrCand.h:32
The Constraint class is used to manage a constraint.
Definition: Constraint.h:61
Abstract base class to manage cuts in the relaxation.
Definition: CutManager.h:42
Definition: Engine.h:34
Definition: Environment.h:28
Definition: Function.h:37
Base class for handling specific types of constraints or objective.
Definition: Handler.h:49
The base class linear function is of the form c'x.
Definition: LinearFunction.h:31
Definition: Linearizations.h:39
Definition: Logger.h:37
Definition: Modification.h:29
Definition: Node.h:54
Handler for convex constraints, based on quesada-grossmann algorithm.
Definition: ParQGHandlerAdvance.h:47
bool isFeasible(ConstSolutionPtr sol, RelaxationPtr relaxation, bool &should_prune, double &inf_meas)
Check if a solution is feasible.
Definition: ParQGHandlerAdvance.cpp:334
void separate(ConstSolutionPtr sol, NodePtr node, RelaxationPtr rel, CutManager *cutman, SolutionPoolPtr s_pool, ModVector &p_mods, ModVector &r_mods, bool *sol_found, SeparationStatus *status)
Base class method. Find cuts.
Definition: ParQGHandlerAdvance.cpp:986
void writeStats(std::ostream &out) const
Show statistics.
Definition: ParQGHandlerAdvance.cpp:1428
void postsolveGetX(const double *, UInt, DoubleVector *)
Does nothing.
Definition: ParQGHandlerAdvance.h:188
bool presolveNode(RelaxationPtr, NodePtr, SolutionPoolPtr, ModVector &, ModVector &)
Does nothing.
Definition: ParQGHandlerAdvance.h:183
ParQGHandlerAdvance(EnvPtr env, ProblemPtr minlp, EnginePtr nlpe)
Default Constructor.
Definition: ParQGHandlerAdvance.cpp:55
~ParQGHandlerAdvance()
Destroy.
Definition: ParQGHandlerAdvance.cpp:93
void getBranchingCandidates(RelaxationPtr, const DoubleVector &, ModVector &, BrVarCandSet &, BrCandVector &, bool &)
Does nothing.
Definition: ParQGHandlerAdvance.h:152
void relaxNodeFull(NodePtr node, RelaxationPtr rel, bool *is_inf)
Base class method. Does nothing.
Definition: ParQGHandlerAdvance.cpp:683
void relaxNodeInc(NodePtr node, RelaxationPtr rel, bool *is_inf)
Base class method. Does nothing.
Definition: ParQGHandlerAdvance.cpp:689
std::string getName() const
Return the name of the handler.
Definition: ParQGHandlerAdvance.cpp:1450
SolveStatus presolve(PreModQ *, bool *, Solution **)
Does nothing.
Definition: ParQGHandlerAdvance.h:180
void relaxInitFull(RelaxationPtr rel, SolutionPool *, bool *is_inf)
Base class method. calls relax_().
Definition: ParQGHandlerAdvance.cpp:668
void relaxInitInc(RelaxationPtr rel, SolutionPool *, bool *is_inf)
Base class method. calls relax_().
Definition: ParQGHandlerAdvance.cpp:674
void setObjVar()
Set oNl_ to true and objVar_ when problem objective is nonlinear.
Definition: ParQGHandlerAdvance.cpp:377
ModificationPtr getBrMod(BrCandPtr, DoubleVector &, RelaxationPtr, BranchDirection)
Does nothing.
Definition: ParQGHandlerAdvance.h:157
Branches getBranches(BrCandPtr, DoubleVector &, RelaxationPtr, SolutionPoolPtr)
Does nothing.
Definition: ParQGHandlerAdvance.h:147
Definition: Problem.h:74
Definition: Relaxation.h:53
Definition: SolutionPool.h:28
Definition: Solution.h:30
Definition: Variable.h:31
Definition: ActiveNodeStore.h:20
BranchDirection
Two directions for branching.
Definition: Types.h:201
unsigned int UInt
Unsigned integer.
Definition: Types.h:30
SeparationStatus
Status from separation routine:
Definition: Types.h:217
EngineStatus
Different status that an external engine may report.
Definition: Types.h:176
SolveStatus
Different states an algorithm like branch-and-bound can be in.
Definition: Types.h:158
Definition: ParQGHandler.h:27
size_t cuts
Number of nlps hits engine iterations limit.
Definition: ParQGHandler.h:32
size_t nlpF
Number of nlps solved.
Definition: ParQGHandler.h:29
size_t rcuts
Number of cuts added to the LP.
Definition: ParQGHandlerAdvance.h:34
size_t nlpI
Number of nlps feasible.
Definition: ParQGHandler.h:30
size_t fracCuts
Number of extra root cuts.
Definition: ParQGHandlerAdvance.h:35
size_t nlpIL
Number of nlps infeasible.
Definition: ParQGHandler.h:31

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