Minotaur 0.4.1
Docs for developers
BqpdEngine.h
Go to the documentation of this file.
1//
2// Minotaur -- It's only 1/2 bull
3//
4// (C)opyright 2010 - 2025 The Minotaur Team.
5//
6
10
11
12#ifndef MINOTAURBQPDENGINE_H
13#define MINOTAURBQPDENGINE_H
14
15#include "QPEngine.h"
16
17namespace Minotaur {
18
19 class Timer;
20 class Environment;
21 class Problem;
22 class Solution;
23 typedef Environment* EnvPtr;
24 typedef Problem* ProblemPtr;
25 typedef Solution* SolutionPtr;
26
27 struct BqpdStats {
28 UInt calls;
30 double time;
31 double strTime;
32 double cTime;
35 };
36
37 class BqpdData;
53 class BqpdEngine : public QPEngine {
54 public:
55 friend class Problem;
56
58 BqpdEngine(EnvPtr env);
59
62
63 // Implement Engine::addConstraint() */
65
66 // Change bound on a constraint.
67 void changeBound(ConstraintPtr cons, BoundType lu, double new_val);
68
69 // Change bound on a variable.
70 void changeBound(VariablePtr var, BoundType lu, double new_val);
71
72 // Implement Engine::changeBound(VariablePtr, double, double).
73 void changeBound(VariablePtr var, double new_lb, double new_ub);
74
75 // Implement Engine::changeConstraint().
77 double lb, double ub);
78
79 // base class method
81
82 // change objective.
83 void changeObj(FunctionPtr f, double cb);
84
86 void clear();
87
88 // Implement Engine::disableStrBrSetup()
89 void disableStrBrSetup();
90
93
94 // Implement Engine::enableStrBrSetup()
95 void enableStrBrSetup();
96
97 // get name.
98 std::string getName() const;
99
102
104 double getSolutionValue();
105
108
109 // Implement Engine::getWarmStart(). // NULL for now.
111
112 // Implement Engine::getWarmStartCopy(). // NULL for now.
114
116 void load(ProblemPtr problem);
117
118 // Implement Engine::loadFromWarmStart().
120
121 // Convert 'min f' to 'min -f'.
122 void negateObj();
123
124 // delete constraints.
125 void removeCons(std::vector<ConstraintPtr> &delcons);
126
127 // Implement Engine::resetIterationLimit().
128 void resetIterationLimit();
129
130 // Implement Engine::setIterationLimit().
131 void setIterationLimit(int limit);
132
133 // Implement Engine::setDualObjLimit().
134 int setDualObjLimit(double) {return 1;};
135
138
139 // Write statistics.
140 void writeStats(std::ostream &out) const;
141
142 private:
144 UInt bndChanges_;
145
150 bool bndRelaxed_;
151
152 const double bTol_;
153
155 BqpdData *chkPt_;
156
158 bool consModed_;
159
161 double *dualCons_;
162
164 double *dualX_;
165
167 EnvPtr env_;
168
170 BqpdData *fStart_;
171
173 const double infty_;
174
176 int iterLimit_;
177
179 const int maxIterLimit_;
180
182 static const std::string me_;
183
185 double objOff_;
186
188 bool prevStrBr_;
189
191 ProblemPtr problem_;
192
197 bool resolveError_;
198
200 SolutionPtr sol_;
201
203 BqpdStats *stats_;
204
206 bool strBr_;
207
209 Timer *timer_;
210
212 int wsMode_;
213
215 void freeProb_();
216
218 void load_();
219
221 void setConsBounds_();
222
224 void setGradient_();
225
227 void setHessian_();
228
230 void setInitialPoint_();
231
233 void setVarBounds_();
234
239 void solve_(int mode, double &f);
240
242 void storeSol_(double f);
243
244 };
245
246
248 class BqpdData {
249 public:
251 BqpdData(UInt n_t, UInt m_t, int kmax_t, UInt maxa_t, UInt lh1_t,
252 UInt nJac, bool zero=true);
253
255 ~BqpdData();
256
258 BqpdData *clone();
259
261 void copyFrom(const BqpdData* rhs);
262
264 void write(std::ostream &out) const;
265
268
271
273 int kmax;
274
277
280
283
285 double *x;
286
288 double *r;
289
291 double *e;
292
294 double *w;
295
297 double *g;
298
300 int *ls;
301
303 double *alp;
304
306 int *lp;
307
309 int *info;
310
312 double *bl;
313
315 double *bu;
316
318 double *a;
319
321 int *la;
322
324 double *ws;
325
327 int *lws;
328
330 int peq;
331
332 // Dimension of reduced-space, set only when mode>=0.
333 int k;
334 };
335
336
337 typedef BqpdEngine* BqpdEnginePtr;
338} // end namespace Minotaur
339
340#endif
Information for restarting from the previous optimal solution.
Definition: BqpdEngine.h:248
int * info
Information on return from bqpd.
Definition: BqpdEngine.h:309
~BqpdData()
Destroy.
Definition: BqpdEngine.cpp:936
int * la
Storage for jacobian.
Definition: BqpdEngine.h:321
int * lp
Workspace associated with recursion.
Definition: BqpdEngine.h:306
double * ws
Storage for hessian values and other things.
Definition: BqpdEngine.h:324
double * e
Steepest-edge normalization coefficients .
Definition: BqpdEngine.h:291
double * bl
Lower bounds for variables and constraints.
Definition: BqpdEngine.h:312
double * x
Initial point for solving QP.
Definition: BqpdEngine.h:285
int * ls
Indices of the active constraints .
Definition: BqpdEngine.h:300
double * bu
Upper bounds for variables and constraints.
Definition: BqpdEngine.h:315
double * g
Gradient vector of f(x).
Definition: BqpdEngine.h:297
BqpdData(UInt n_t, UInt m_t, int kmax_t, UInt maxa_t, UInt lh1_t, UInt nJac, bool zero=true)
Constructor.
Definition: BqpdEngine.cpp:818
void write(std::ostream &out) const
Display all data.
Definition: BqpdEngine.cpp:1001
int peq
Pointer to equality constraints, used by bqpd.
Definition: BqpdEngine.h:330
UInt lh1
Number of nonzeros in Hessian.
Definition: BqpdEngine.h:276
UInt nJac
Number of nonzeros in Jacobian.
Definition: BqpdEngine.h:279
double * a
Storage for jacobian.
Definition: BqpdEngine.h:318
UInt m
Number of constraints.
Definition: BqpdEngine.h:270
UInt maxa
Size of a.
Definition: BqpdEngine.h:282
double * alp
Workspace associated with recursion.
Definition: BqpdEngine.h:303
BqpdData * clone()
Allocate space and copy.
Definition: BqpdEngine.cpp:866
int * lws
Storage for hessian indices and other things.
Definition: BqpdEngine.h:327
double * r
Residuals/multipliers.
Definition: BqpdEngine.h:288
double * w
Denominators for ratio tests.
Definition: BqpdEngine.h:294
void copyFrom(const BqpdData *rhs)
Only copy. No space allocation.
Definition: BqpdEngine.cpp:903
int kmax
kmax given to bqpd
Definition: BqpdEngine.h:273
UInt n
Number of variables.
Definition: BqpdEngine.h:267
Definition: BqpdEngine.h:53
void changeObj(FunctionPtr f, double cb)
Change objective function.
Definition: BqpdEngine.cpp:714
EngineStatus solve()
Solve the problem that was loaded and report the status.
Definition: BqpdEngine.cpp:360
void changeBound(ConstraintPtr cons, BoundType lu, double new_val)
Change a bound of a constraint.
Definition: BqpdEngine.cpp:671
void enableStrBrSetup()
Make settings for strong branching.
Definition: BqpdEngine.cpp:751
std::string getName() const
Get the name.
Definition: BqpdEngine.cpp:809
void loadFromWarmStart(WarmStartPtr)
Definition: BqpdEngine.h:119
void clear()
Method to unload the current problem.
Definition: BqpdEngine.cpp:132
void setIterationLimit(int limit)
Definition: BqpdEngine.cpp:778
ConstSolutionPtr getSolution()
Report the solution.
Definition: BqpdEngine.cpp:656
EnginePtr emptyCopy()
Return an empty BqpdEngine pointer.
Definition: BqpdEngine.cpp:117
double getSolutionValue()
Report the solution value from the last solve.
Definition: BqpdEngine.cpp:646
ConstWarmStartPtr getWarmStart()
Definition: BqpdEngine.h:110
void changeConstraint(ConstraintPtr con, LinearFunctionPtr lf, double lb, double ub)
Change the linear function, and the bounds of a constraint.
Definition: BqpdEngine.cpp:734
void writeStats(std::ostream &out) const
Definition: BqpdEngine.cpp:794
void resetIterationLimit()
Reset the iteration limit to maximum possible.
Definition: BqpdEngine.cpp:788
BqpdEngine(EnvPtr env)
Constructor using given environment options.
Definition: BqpdEngine.cpp:46
void removeCons(std::vector< ConstraintPtr > &delcons)
Delete constraints from the engine.
Definition: BqpdEngine.cpp:200
~BqpdEngine()
Destroy.
Definition: BqpdEngine.cpp:83
void disableStrBrSetup()
Restore settings after strong branching.
Definition: BqpdEngine.cpp:765
void addConstraint(ConstraintPtr)
Add a new constraint to the engine.
Definition: BqpdEngine.cpp:111
EngineStatus getStatus()
Report the status of the last solve.
Definition: BqpdEngine.cpp:665
void load(ProblemPtr problem)
Method to read the problem and initialize bqpd.
Definition: BqpdEngine.cpp:123
WarmStartPtr getWarmStartCopy()
Definition: BqpdEngine.h:113
int setDualObjLimit(double)
Set the dual objective limit.
Definition: BqpdEngine.h:134
void negateObj()
Negate the objective function. Min f is changed to Min -f.
Definition: BqpdEngine.cpp:724
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
The base class linear function is of the form c'x.
Definition: LinearFunction.h:31
Base class for nonlinear functions.
Definition: NonlinearFunction.h:31
Definition: Problem.h:74
Definition: QPEngine.h:24
Definition: Solution.h:30
Definition: Timer.h:40
Definition: Variable.h:31
Definition: WarmStart.h:45
Definition: ActiveNodeStore.h:20
BoundType
Different types of variable-bounds.
Definition: Types.h:131
unsigned int UInt
Unsigned integer.
Definition: Types.h:30
EngineStatus
Different status that an external engine may report.
Definition: Types.h:176
Definition: BqpdEngine.h:27
UInt strIters
Sum of number of iterations in all calls.
Definition: BqpdEngine.h:34
double cTime
Time taken in strong branching alone.
Definition: BqpdEngine.h:32
double time
Calls to solve while strong branching.
Definition: BqpdEngine.h:30
double strTime
Sum of time taken in all calls to solve.
Definition: BqpdEngine.h:31
UInt strCalls
Total number of calls to solve.
Definition: BqpdEngine.h:29
UInt iters
Time taken in copying data for strong-branching.
Definition: BqpdEngine.h:33

Minotaur source code documented by Doxygen 1.9.4 on Fri Apr 25 2025