Minotaur 0.4.1
Docs for developers
ParQGHandler.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 MINOTAURPARQGHANDLER_H
16#define MINOTAURPARQGHANDLER_H
17
18#include <stack>
19
20#include "Handler.h"
21#include "Engine.h"
22#include "Problem.h"
23#include "Function.h"
24
25namespace Minotaur {
26
27struct ParQGStats {
28 size_t nlpS;
29 size_t nlpF;
30 size_t nlpI;
31 size_t nlpIL;
32 size_t cuts;
33};
34
35
44class ParQGHandler : public Handler {
45
46private:
48 EnvPtr env_;
49
51 double intTol_;
52
54 LoggerPtr logger_;
55
57 static const std::string me_;
58
60 ProblemPtr minlp_;
61
63 std::vector<ConstraintPtr> nlCons_;
64
66 EnginePtr nlpe_;
67
69 std::stack<Modification *> nlpMods_;
70
72 EngineStatus nlpStatus_;
73
79 VariablePtr objVar_;
80
82 bool oNl_;
83
85 RelaxationPtr rel_;
86
88 double relobj_;
89
91 double solAbsTol_;
92
94 double solRelTol_;
95
97 double objATol_;
98
100 double objRTol_;
101
103 bool storeCutsAtNode_;
104
106 NodePtr node_;
107
109 ParQGStats *stats_;
110
111public:
120 ParQGHandler(EnvPtr env, ProblemPtr minlp, EnginePtr nlpe);
121
124
126 Branches getBranches(BrCandPtr, DoubleVector &, RelaxationPtr,
128 {return Branches();};
129
132 const DoubleVector &, ModVector &,
133 BrVarCandSet &, BrCandVector &, bool &) {};
134
138 {return ModificationPtr();};
139
140
141 // Base class method.
142 std::string getName() const;
143
144 // Get statistics
145 ParQGStats* getStats() {return stats_; };
146
147 void nlCons();
148
149 void loadProbToEngine();
150
151 void setRelaxation(RelaxationPtr rel);
152
153 // Base class method. Check if x is feasible. x has to satisfy integrality
154 // and also nonlinear constraints.
155 bool isFeasible(ConstSolutionPtr sol, RelaxationPtr relaxation,
156 bool & should_prune, double &inf_meas);
157
159 SolveStatus presolve(PreModQ *, bool *, Solution **) {return Finished;};
160
163 ModVector &)
164 {return false;};
165
167 void postsolveGetX(const double *, UInt, DoubleVector *) {};
168
170 void relaxInitFull(RelaxationPtr rel, SolutionPool *sp, bool *is_inf);
171
173 void relaxInitInc(RelaxationPtr rel, SolutionPool *sp, bool *is_inf);
174
176 void relaxNodeFull(NodePtr node, RelaxationPtr rel, bool *is_inf);
177
179 void relaxNodeInc(NodePtr node, RelaxationPtr rel, bool *is_inf);
180
182 void separate(ConstSolutionPtr sol, NodePtr node, RelaxationPtr rel,
183 CutManager *cutman, SolutionPoolPtr s_pool, ModVector &p_mods,
184 ModVector &r_mods, bool *sol_found, SeparationStatus *status);
185
187 void setObjVar();
188
190 void writeStats(std::ostream &out) const;
191
192private:
197 void addInitLinearX_(const double *x);
198
203 void cutIntSol_(ConstSolutionPtr sol, CutManager *cutMan,
204 SolutionPoolPtr s_pool, bool *sol_found,
205 SeparationStatus *status);
206
211 void fixInts_(const double *x);
212
218 void initLinear_(bool *isInf);
219
224 void linearizeObj_();
225
230 void linearAt_(FunctionPtr f, double fval, const double *x,
231 double *c, LinearFunctionPtr *lf, int *error);
236 void cutToCons_(const double *nlpx, const double *lpx, CutManager *,
237 SeparationStatus *status);
238
240 void addCut_(const double *nlpx, const double *lpx, ConstraintPtr con,
241 CutManager *cutman, SeparationStatus *status);
242
243 void cutsAtLpSol_(const double *lpx, CutManager *cutman,
244 SeparationStatus *status);
245
250 void cutToObj_(const double *nlpx, const double *lpx, CutManager *,
251 SeparationStatus *status);
252
257 void relax_(bool *is_inf);
258
260 void solveNLP_();
261
263 void unfixInts_();
264
269 void updateUb_(SolutionPoolPtr s_pool, double nlpval, bool *sol_found);
270
271 };
272
273 typedef ParQGHandler* ParQGHandlerPtr;
274}
275#endif
276
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: Logger.h:37
Definition: Modification.h:29
Definition: Node.h:54
Handler for convex constraints, based on quesada-grossmann algorithm.
Definition: ParQGHandler.h:44
ModificationPtr getBrMod(BrCandPtr, DoubleVector &, RelaxationPtr, BranchDirection)
Does nothing.
Definition: ParQGHandler.h:136
void relaxNodeInc(NodePtr node, RelaxationPtr rel, bool *is_inf)
Base class method. Does nothing.
Definition: ParQGHandler.cpp:673
ParQGHandler(EnvPtr env, ProblemPtr minlp, EnginePtr nlpe)
Default Constructor.
Definition: ParQGHandler.cpp:54
bool isFeasible(ConstSolutionPtr sol, RelaxationPtr relaxation, bool &should_prune, double &inf_meas)
Check if a solution is feasible.
Definition: ParQGHandler.cpp:304
void getBranchingCandidates(RelaxationPtr, const DoubleVector &, ModVector &, BrVarCandSet &, BrCandVector &, bool &)
Does nothing.
Definition: ParQGHandler.h:131
void setObjVar()
Set oNl_ to true and objVar_ when problem objective is nonlinear.
Definition: ParQGHandler.cpp:347
Branches getBranches(BrCandPtr, DoubleVector &, RelaxationPtr, SolutionPoolPtr)
Does nothing.
Definition: ParQGHandler.h:126
void relaxInitInc(RelaxationPtr rel, SolutionPool *sp, bool *is_inf)
Base class method. calls relax_().
Definition: ParQGHandler.cpp:659
void writeStats(std::ostream &out) const
Show statistics.
Definition: ParQGHandler.cpp:779
SolveStatus presolve(PreModQ *, bool *, Solution **)
Does nothing.
Definition: ParQGHandler.h:159
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: ParQGHandler.cpp:710
void relaxInitFull(RelaxationPtr rel, SolutionPool *sp, bool *is_inf)
Base class method. calls relax_().
Definition: ParQGHandler.cpp:653
std::string getName() const
Return the name of the handler.
Definition: ParQGHandler.cpp:796
void postsolveGetX(const double *, UInt, DoubleVector *)
Does nothing.
Definition: ParQGHandler.h:167
void relaxNodeFull(NodePtr node, RelaxationPtr rel, bool *is_inf)
Base class method. Does nothing.
Definition: ParQGHandler.cpp:667
bool presolveNode(RelaxationPtr, NodePtr, SolutionPoolPtr, ModVector &, ModVector &)
Does nothing.
Definition: ParQGHandler.h:162
~ParQGHandler()
Destroy.
Definition: ParQGHandler.cpp:83
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 nlpI
Number of nlps feasible.
Definition: ParQGHandler.h:30
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