Minotaur 0.4.1
Docs for developers
QPDProcessor.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
14#ifndef MINOTAURQPDPROCESSOR_H
15#define MINOTAURQPDPROCESSOR_H
16
17#include "NodeProcessor.h"
18#include "Types.h"
19
20namespace Minotaur {
21
22 class Engine;
23 class NonlinearFunction;
24 class Problem;
25 class Solution;
26 typedef NonlinearFunction* NonlinearFunctionPtr;
27 typedef Solution* SolutionPtr;
28 typedef const Solution* ConstSolutionPtr;
29
30 struct QPDStats {
31 UInt bra;
42 };
43
48 class QPDProcessor : public NodeProcessor {
49
50 public:
53
56 HandlerVector &handlers);
57
60
61 // Add a heuristic.
62 void addHeur(HeurPtr h);
63
64 // True if a new solution was found while processing this node.
65 bool foundNewSolution();
66
67 // Find branches that will be used to branch at this node.
68 Branches getBranches();
69
70 // Get warm-start information.
72
73 // Implement NodeProcessor::process().
74 void process(NodePtr node, RelaxationPtr rel,
75 SolutionPoolPtr s_pool);
76
77 // Process root node.
79 SolutionPoolPtr s_pool);
80
81 // write statistics. Base class method.
82 void writeStats(std::ostream &out) const;
83
84 // write statistics to logger. Base class method.
85 void writeStats() const {};
86
87 private:
89 Branches branches_;
90
92 EnginePtr e_;
93
95 EnvPtr env_;
96
97 VariablePtr eta_;
98
99 VariablePtr etaL_;
100
102 HandlerVector handlers_;
103
105 LoggerPtr logger_;
106
107 /*
108 * If Filter-SQP is used, the duals are negative of what QP from Hessian
109 * evaluation expects. If this flag is on, the duals are negated before
110 * creating QP.
111 */
112 bool negDuals_;
113
115 static const std::string me_;
116
118 std::vector<ConstConstraintPtr> nlCons_;
119
121 UInt numSolutions_;
122
124 ProblemPtr p_;
125
127 RelaxationPtr qp_;
128
130 EnginePtr qpe_;
131
132 const double solAbsTol_;
133
134 const double solRelTol_;
135
141 bool solveQPafNLP_;
142
144 QPDStats stats_;
145
147 ConstraintPtr ubCon_;
148
150 WarmStartPtr ws_;
151
152 bool boundTooFar_(ConstSolutionPtr sol, NodePtr node,
153 double best) ;
154
155 void getLin_(FunctionPtr f, const double *x, UInt n,
156 VariableConstIterator vbeg, VariableConstIterator vend,
157 LinearFunctionPtr &lf, double &val);
158
159 void getObjLin_(NonlinearFunctionPtr nlf, const double *x,
160 UInt n, VariableConstIterator vbeg,
161 VariableConstIterator vend,
162 LinearFunctionPtr &lf, double &val);
163
164 void fixInts_(const double *x, std::stack<Modification *> *nlp_mods);
165
166 void chkObjVio_(double vio, double etaval, bool &large_vio);
167
168 void chkVio_(NodePtr node, double *vio, double &tvio, double &maxvio,
169 bool &large_vio);
170
171 bool isHFeasible_(ConstSolutionPtr sol, bool &should_prune);
172 bool isHFeasible2_(ConstSolutionPtr sol, bool &ishigh,
173 bool &should_prune);
174 void chkObjVio2_(const double *qpx, NodePtr node, double best,
175 bool &hiobjd, bool &hietavio);
176
177 bool isNLPFeasible2_(const double *qpx, double *vio, NodePtr node, bool
178 &hicvio);
179 bool isLargeCVio_(ConstConstraintPtr c, double vio, UInt depth);
180
181 //bool isQPFeasible_(NodePtr node, ConstSolutionPtr sol,
182 // SolutionPoolPtr s_pool, bool &should_prune);
183
184 bool isNLPFeasible_(ConstSolutionPtr sol, double *vio);
185
186 SolutionPtr nlpSol2Qp_(ConstSolutionPtr sol);
187
188 void OAFromPoint_(const double *x, ConstSolutionPtr sol,
189 SeparationStatus *status);
190
191 bool presolveNode_(NodePtr node, SolutionPoolPtr s_pool);
192
193 void processNLP_(NodePtr node, ConstSolutionPtr &sol,
194 ConstSolutionPtr qpsol,
195 SolutionPoolPtr s_pool, bool &should_prune);
196
197 void processQP_(UInt iter, NodePtr node, ConstSolutionPtr &sol,
198 SolutionPoolPtr s_pool, bool &should_prune,
199 bool &should_resolve);
200
201 void processQP2_(UInt iter, NodePtr node, ConstSolutionPtr &sol,
202 SolutionPoolPtr s_pool, bool &should_prune,
203 bool &should_resolve);
204
205 void saveSol_(ConstSolutionPtr sol, SolutionPoolPtr s_pool,
206 NodePtr node);
207 void saveQPSol_(ConstSolutionPtr sol, SolutionPoolPtr s_pool,
208 NodePtr node);
209
210 void separate_(bool is_nec, ConstSolutionPtr sol, const double *vio,
211 ConstSolutionPtr nlp_sol, NodePtr node,
212 SolutionPoolPtr s_pool, SeparationStatus *status);
213
214 void separateB_(ConstSolutionPtr sol, ConstSolutionPtr nlp_sol,
215 double *vio, NodePtr node, SolutionPoolPtr s_pool,
216 SeparationStatus *status);
217
218 void separateC_(ConstSolutionPtr sol, ConstSolutionPtr nlp_sol,
219 double *vio, NodePtr node, SolutionPoolPtr s_pool,
220 SeparationStatus *status);
221
222 void separateO_(ConstSolutionPtr sol, ConstSolutionPtr nlp_sol,
223 double *vio, NodePtr node, SolutionPoolPtr s_pool,
224 SeparationStatus *status);
225
226 void separateECP_(ConstSolutionPtr sol, const double *vio,
228 SeparationStatus *status);
229
230 void separateObj_(ConstSolutionPtr sol, ConstSolutionPtr nlp_sol,
231 double vio, SeparationStatus *status);
232
233 void setupQP_(ConstSolutionPtr sol);
234
239 bool shouldPrune_(NodePtr node, EngineStatus nlp_status,
241
245 bool shouldPruneQP_(NodePtr node, EngineStatus nlp_status,
247
248 bool shouldSep_(bool is_nec, double vio, ConstConstraintPtr c);
249 bool shouldSepObj_(bool is_nec, double vio, double etaval);
250
252 void solveNLP_(ConstSolutionPtr &sol, EngineStatus &nlp_status);
253
254 void solveQP_(ConstSolutionPtr &sol, EngineStatus &qp_status);
255
256 SolutionPtr translateSol_(ConstSolutionPtr sol);
257
258 void unfixInts_(std::stack<Modification *> *nlp_mods);
259
260 void updateObjCons_(ConstSolutionPtr sol);
261
262 void updateUb_(SolutionPoolPtr s_pool, double *nlpval);
263 };
264
265 typedef QPDProcessor* QPDProcessorPtr;
266
267}
268#endif
269
Define the NodeProcessor class for processing nodes in the branch-and-bound algorithm.
Declare important 'types' used in Minotaur.
The Constraint class is used to manage a constraint.
Definition: Constraint.h:61
Definition: Engine.h:34
Definition: Environment.h:28
Definition: Function.h:37
Definition: Heuristic.h:30
The base class linear function is of the form c'x.
Definition: LinearFunction.h:31
Definition: Logger.h:37
Definition: NodeProcessor.h:49
Definition: Node.h:54
Base class for nonlinear functions.
Definition: NonlinearFunction.h:31
Definition: Problem.h:74
Definition: QPDProcessor.h:48
bool foundNewSolution()
Definition: QPDProcessor.cpp:262
~QPDProcessor()
Destroy.
Definition: QPDProcessor.cpp:116
void writeStats() const
Write statistics to our own logger.
Definition: QPDProcessor.h:85
QPDProcessor()
Default constructor.
Definition: QPDProcessor.cpp:45
void processRootNode(NodePtr node, RelaxationPtr rel, SolutionPoolPtr s_pool)
Process the root node.
Definition: QPDProcessor.cpp:837
Branches getBranches()
Find branches that will be used to branch at this node.
Definition: QPDProcessor.cpp:268
WarmStartPtr getWarmStart()
Definition: QPDProcessor.cpp:275
void process(NodePtr node, RelaxationPtr rel, SolutionPoolPtr s_pool)
Definition: QPDProcessor.cpp:924
Definition: Relaxation.h:53
Definition: SolutionPool.h:28
Definition: Solution.h:30
Definition: Variable.h:31
Definition: WarmStart.h:45
Definition: ActiveNodeStore.h:20
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
Definition: QPDProcessor.h:30
UInt ub
Number of times qp-point separated.
Definition: QPDProcessor.h:41
UInt opt
Number of NLP-solves feasible.
Definition: QPDProcessor.h:37
UInt prob
Number of times relaxation gave optimal feasible solution.
Definition: QPDProcessor.h:38
UInt nlp
Number of times relaxation became infeasible.
Definition: QPDProcessor.h:34
UInt proc
Number of times problem ocurred in solving.
Definition: QPDProcessor.h:39
UInt inf
Number of cuts added.
Definition: QPDProcessor.h:33
UInt cuts
Number of times relaxation became infeasible.
Definition: QPDProcessor.h:32
UInt nlpU
Number of NLP-solves infeasible.
Definition: QPDProcessor.h:36
UInt sep
Number of nodes processed.
Definition: QPDProcessor.h:40
UInt nlpI
Number of NLPs solved.
Definition: QPDProcessor.h:35

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