Minotaur 0.4.1
Docs for developers
PerspCutGenerator.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
13#ifndef MINOTAURPERSPCUTGENERATOR_H
14#define MINOTAURPERSPCUTGENERATOR_H
15
16#include "CutManager.h"
17#include "Engine.h"
18#include "Problem.h"
19#include "Function.h"
20#include "PerspCon.h"
21#include "SolutionPool.h"
22#include "LinearFunction.h"
23
24namespace Minotaur {
25//MS: constraint form expected is f(x) <= b
26// MS: make functions private/public
27 class PerspCutGenerator;
28 typedef PerspCutGenerator* PerspCutGeneratorPtr;
29 typedef const PerspCutGenerator* ConstPerspCutGeneratorPtr;
30
31 struct PRStats {
32 size_t imprvPt;
33 size_t infPt;
34 size_t cuts;
35 };
36
38 public:
39
42
44 PerspCutGenerator(EnvPtr env, ProblemPtr problem, EnginePtr nlpe_);
45
48
50
51 bool addPC(RelaxationPtr rel, const double * y, UInt i,
52 const double *ptToCut, const double *prPt, bool isObj,
53 VariablePtr objVar, CutManagerPtr cutMan, double relVal);
54
56 std::string getName() const;
57
58 UInt getNumCuts() {return stats_->cuts;}
59
60 void fixedValue(double * prPt, bool isObj, UInt i);
61
66 void addCut(RelaxationPtr rel, const double *nlpx, const double *lpx, UInt it,
67 SeparationStatus * pcStatus);
68
73 void atIntPt(RelaxationPtr rel , const double * nlpx,
74 const double *lpx, SeparationStatus * pcStatus, CutManager *);
75
80 //void linearAt(RelaxationPtr rel, FunctionPtr f, double fval,
81 //const double *x, double *c, LinearFunctionPtr *lf,
82 //int *error);
87 void getCutFun(RelaxationPtr rel,LinearFunctionPtr *lf, UInt it, const double *x,
88 double *c, int *error);
89
91 bool addCutToRel(RelaxationPtr rel, const double * ptToCut,
92 LinearFunctionPtr lf, double c, VariablePtr objVar, double relVal, CutManagerPtr);
99 //void addCutOriFeas(RelaxationPtr rel , UInt it, const double *x);
100
102 void oriFeasPt(RelaxationPtr rel , const double *x);
103
104 void oriInfeasPt(RelaxationPtr rel, const double *x);
105
115 //void addPCut(RelaxationPtr rel , UInt it, const double *x);
116
117 void atPtx(RelaxationPtr rel, const double *x);
118
119 void cutToCons(RelaxationPtr rel, const double *x, UInt it);
124 //void feasBisecPt(const double *x, double *y, UInt it);
125
130 //void vertexPt(double * y, UInt it);
131
137 //void bisecPtOri(const double *x, double * w, double * w1, UInt it);
138
139
145 bool bisecPt(double *x, double * newPt, UInt i,
146 bool isObj, double relVal);
147
148 void cvxCombPt(RelaxationPtr rel, const double * y, UInt it);
149
150 bool changeVarForm(VariablePtr v, double xc, double sb, UInt itn, double *newPt, bool isObj, bool nlin);
154 void linearAt(RelaxationPtr rel, const double *x, const double *prPt, double *c, LinearFunctionPtr *lf, UInt itn, int *error, bool isObj);
155
157 std::vector<prCons> getPRCons() {return prCons_;};
158
159 prObj getPRObj() {return prObj_;};
160
162 //std::vector<VariablePtr> getPRBinVar() {return binvar_;};
163
164 //std::vector<UInt> getPRStruct() {return sType_;};
165
167 UInt isFeasible(const double *x, UInt i, bool isObj, double relVal);
168
170 //variables, if z has value 0 then the function returns false; And if z has
171 //value 1, then the function returns the same point. Similarly, for z = 1
172 //fixing case.
173 bool prVars(const double *y, double *prPt, UInt itn, bool isObj);
174
175 void findPRCons();
176
177 bool uniDirZSearch(double *y, double * newPt, UInt i, double zdir);
178
180 bool getStatus();
181
182
184 //only if solC_ satisfies the PR amenable constraint or (xC, 1) satisfies,
185 //where xC is x components of solC_.
186 bool lineSearchAC(double *y, double * newPt, UInt i, bool isObj, double relVal);
187
189 void writeStats(std::ostream &out) const;
190
191private:
192
193 //void fixBinVars_(std::stack<Modification *> &varMods);
194
195 //void unfixBinVars_(std::stack<Modification *> &varMods);
196
197 bool lineSearch_(double *y, double * newPt, UInt i, bool isObj, double relVal);
199 EnvPtr env_;
200
202 ProblemPtr minlp_;
203
204 EnginePtr nlpe_;
205
207 LoggerPtr logger_;
208
210 double solAbsTol_;
211
213 double solRelTol_;
214
216 double objAbsTol_;
217
219 double objRelTol_;
220
222 double intTol_;
223
225 double* cvxPt;
226
228 PRStats *stats_;
229
231 static const std::string me_;
232
234 std::vector<prCons> prCons_;
235
236 prObj prObj_;
237
238 double * solC_;
239
240 //bool isObj_;
241
242 };
243}
244
245#endif // MINOTAURPERSPCUTHANDLER_H
246
Manages addition and deletion of cuts to problem.
Define the base class Engine.
Get information about a Function.
Declare the class LinearFunction for storing and modifying a linear function.
Declare a base class PerspCon for identifying structures amenable to perspective reformulation (PR) (...
Declare the base class Modification.
Declare a container for storing solutions and their qualities.
Abstract base class to manage cuts in the relaxation.
Definition: CutManager.h:42
Definition: Engine.h:34
Definition: Environment.h:28
The base class linear function is of the form c'x.
Definition: LinearFunction.h:31
Definition: PerspCutGenerator.h:37
bool addPC(RelaxationPtr rel, const double *y, UInt i, const double *ptToCut, const double *prPt, bool isObj, VariablePtr objVar, CutManagerPtr cutMan, double relVal)
Added perspective cut to a constraint at a given point.
Definition: PerspCutGenerator.cpp:1224
bool addCutToRel(RelaxationPtr rel, const double *ptToCut, LinearFunctionPtr lf, double c, VariablePtr objVar, double relVal, CutManagerPtr)
Add PCut torelaxation.
Definition: PerspCutGenerator.cpp:886
PerspCutGenerator()
Default constructor.
Definition: PerspCutGenerator.cpp:43
bool bisecPt(double *x, double *newPt, UInt i, bool isObj, double relVal)
Definition: PerspCutGenerator.cpp:1080
void atPtx(RelaxationPtr rel, const double *x)
~PerspCutGenerator()
Destructor.
Definition: PerspCutGenerator.cpp:1284
void getCutFun(RelaxationPtr rel, LinearFunctionPtr *lf, UInt it, const double *x, double *c, int *error)
bool getStatus()
Return 1 if there are PR amenable constraints in the problem.
Definition: PerspCutGenerator.cpp:264
std::string getName() const
Returns name of the handler.
Definition: PerspCutGenerator.cpp:1278
void writeStats(std::ostream &out) const
Writes statistics.
Definition: PerspCutGenerator.cpp:1266
bool lineSearchAC(double *y, double *newPt, UInt i, bool isObj, double relVal)
Perform line search using analytical center solC_. This search happens.
Definition: PerspCutGenerator.cpp:1148
void oriFeasPt(RelaxationPtr rel, const double *x)
Iterate over PR amenable constraints to add PCut;.
void atIntPt(RelaxationPtr rel, const double *nlpx, const double *lpx, SeparationStatus *pcStatus, CutManager *)
bool prVars(const double *y, double *prPt, UInt itn, bool isObj)
Generate variables for PR reformulation. Case in which z = 0 fixes x.
Definition: PerspCutGenerator.cpp:631
UInt isFeasible(const double *x, UInt i, bool isObj, double relVal)
Check feasibility of PR amenable constraints at the given solution.
Definition: PerspCutGenerator.cpp:535
void addCut(RelaxationPtr rel, const double *nlpx, const double *lpx, UInt it, SeparationStatus *pcStatus)
void linearAt(RelaxationPtr rel, const double *x, const double *prPt, double *c, LinearFunctionPtr *lf, UInt itn, int *error, bool isObj)
Definition: PerspCutGenerator.cpp:274
std::vector< prCons > getPRCons()
Return vector of perspective amenable constraint.
Definition: PerspCutGenerator.h:157
Definition: Problem.h:74
Definition: Relaxation.h:53
Definition: Variable.h:31
Definition: ActiveNodeStore.h:20
unsigned int UInt
Unsigned integer.
Definition: Types.h:30
SeparationStatus
Status from separation routine:
Definition: Types.h:217
Definition: PerspCutGenerator.h:31
size_t cuts
Number of points infeasible to original constraint.
Definition: PerspCutGenerator.h:34
size_t infPt
Number of points feasible to original nonlinear constraint but not the PR constraint.
Definition: PerspCutGenerator.h:33
Definition: PerspCon.h:72

Minotaur source code documented by Doxygen 1.9.4 on Fri May 16 2025