Minotaur 0.4.1
Docs for developers
PerspCutHandler.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
15#ifndef MINOTAURPERSPCUTHANDLER_H
16#define MINOTAURPERSPCUTHANDLER_H
17
18#include "Handler.h"
19#include "Problem.h"
20#include "Function.h"
21#include "PerspCon.h"
22#include "LinearFunction.h"
23
24namespace Minotaur {
25//MS: constraint form expected is f(x) <= b
26 class PerspCutHandler;
27 typedef PerspCutHandler* PerspCutHandlerPtr;
28 typedef const PerspCutHandler* ConstPerspCutHandlerPtr;
29
30 struct PRStats {
31 size_t imprvPt;
32 size_t infPt;
33 size_t cuts;
34 };
35
36 class PerspCutHandler : public Handler {
37 public:
38
41
43 PerspCutHandler(EnvPtr env, ProblemPtr problem);
44
47
49 virtual Branches getBranches(BrCandPtr, DoubleVector &,
51 {return Branches();};
52
53 // Does nothing.
55 const DoubleVector &, ModVector &,
56 BrVarCandSet &, BrCandVector &,
57 bool &) {};
58
60 virtual ModificationPtr getBrMod(BrCandPtr, DoubleVector &,
62 {return ModificationPtr();};
63
65 std::string getName() const;
66
68 SolveStatus presolve(PreModQ *, bool *, Solution **sol) {return Finished;};
69
72 SolutionPoolPtr, ModVector &,
73 ModVector &) {return false;};
74
76 void relaxInitFull(RelaxationPtr, bool * ) {};
77
79 void relaxInitInc(RelaxationPtr, bool * ) {};
80
83
86
88 void separate(ConstSolutionPtr sol, NodePtr node,
89 RelaxationPtr rel, CutManager *cutman, SolutionPoolPtr s_pool,
90 ModVector &p_mods, ModVector &r_mods, bool *sol_found,
91 SeparationStatus *status);
92
93
98 void addCut(RelaxationPtr rel, const double *nlpx, const double *lpx, UInt it,
99 SeparationStatus * pcStatus);
100
105 void atIntPt(RelaxationPtr rel , const double * nlpx,
106 const double *lpx, SeparationStatus * pcStatus, CutManager *);
107
112 void linearAt(RelaxationPtr rel, FunctionPtr f, double fval,
113 const double *x, double *c, LinearFunctionPtr *lf,
114 int *error);
119 void getCutFun(RelaxationPtr rel,LinearFunctionPtr *lf, UInt it, const double *x,
120 double *c, int *error);
121
123 void addCutToRel(RelaxationPtr rel, LinearFunctionPtr lf, double c);
124
131 //void addCutOriFeas(RelaxationPtr rel , UInt it, const double *x);
132
134 void oriFeasPt(RelaxationPtr rel , const double *x);
135
136 void oriInfeasPt(RelaxationPtr rel, const double *x);
137
147 //void addPCut(RelaxationPtr rel , UInt it, const double *x);
148
149 void atPtx(RelaxationPtr rel, const double *x);
150
151 void cutToCons(RelaxationPtr rel, const double *x, UInt it);
156 //void feasBisecPt(const double *x, double *y, UInt it);
157
162 //void vertexPt(double * y, UInt it);
163
169 //void bisecPtOri(const double *x, double * w, double * w1, UInt it);
170
171
176 void bisecPt(const double *x, double * y, UInt it);
177
178 void cvxCombPt(RelaxationPtr rel, const double * y, UInt it);
179
180 double changeVarForm(VariablePtr v, double xc, double xb, UInt itn,
181 int *error);
185 void linearAt(RelaxationPtr rel, const double *y, double *c, LinearFunctionPtr *lf, UInt itn, int *error);
186
188 std::vector<ConstraintPtr> getPRCons() {return cons_;};
189
191 //std::vector<VariablePtr> getPRBinVar() {return binvar_;};
192
193 //std::vector<UInt> getPRStruct() {return sType_;};
194
196 bool isFeasible(ConstSolutionPtr, RelaxationPtr, bool &, double &);
197
199 void prVars(const double *x, double *y, UInt itn, int *error);
200
201 void findPRCons();
202
204 bool getStatus();
205
206
208 void writeStats(std::ostream &out) const;
209
210private:
211
213 EnvPtr env_;
214
216 ProblemPtr minlp_;
217
219 LoggerPtr logger_;
220
222 double solAbsTol_;
223
225 double solRelTol_;
226
228 double intTol_;
229
231 double* cvxPt;
232
234 PRStats *stats_;
235
237 static const std::string me_;
238
240 std::vector<ConstraintPtr> cons_;
241
243 std::vector<ConstraintPtr> prcons_;
244
246 std::vector<VariablePtr> binvar_;
247
249 std::vector<int> sType_;
250
253 std::vector<VariableGroup> nviv_;
254
256 // the constraints amenable to PR are fixed to
257 std::vector<VariableGroup> lviv_;
258 };
259}
260
261#endif // MINOTAURPERSPCUTHANDLER_H
262
Get information about a Function.
Define abstract base class for handlers of various kinds.
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.
Base class for describing candidates for branching on a node in branch-and-bound.
Definition: BrCand.h:32
Abstract base class to manage cuts in the relaxation.
Definition: CutManager.h:42
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
Definition: PerspCutHandler.h:36
void atPtx(RelaxationPtr rel, const double *x)
Definition: PerspCutHandler.cpp:394
void prVars(const double *x, double *y, UInt itn, int *error)
Generate variables for PR reformulation.
Definition: PerspCutHandler.cpp:259
SolveStatus presolve(PreModQ *, bool *, Solution **sol)
Does nothing.
Definition: PerspCutHandler.h:68
void atIntPt(RelaxationPtr rel, const double *nlpx, const double *lpx, SeparationStatus *pcStatus, CutManager *)
Definition: PerspCutHandler.cpp:361
void relaxInitInc(RelaxationPtr, bool *)
Does nothing.
Definition: PerspCutHandler.h:79
virtual void getBranchingCandidates(RelaxationPtr, const DoubleVector &, ModVector &, BrVarCandSet &, BrCandVector &, bool &)
find branching candidates.
Definition: PerspCutHandler.h:54
virtual ModificationPtr getBrMod(BrCandPtr, DoubleVector &, RelaxationPtr, BranchDirection)
Does nothing.
Definition: PerspCutHandler.h:60
void oriFeasPt(RelaxationPtr rel, const double *x)
Iterate over PR amenable constraints to add PCut;.
Definition: PerspCutHandler.cpp:419
void getCutFun(RelaxationPtr rel, LinearFunctionPtr *lf, UInt it, const double *x, double *c, int *error)
Definition: PerspCutHandler.cpp:473
void relaxNodeFull(NodePtr, RelaxationPtr, bool *)
Does nothing.
Definition: PerspCutHandler.h:82
PerspCutHandler()
Default constructor.
Definition: PerspCutHandler.cpp:42
std::string getName() const
Returns name of the handler.
Definition: PerspCutHandler.cpp:575
void separate(ConstSolutionPtr sol, NodePtr node, RelaxationPtr rel, CutManager *cutman, SolutionPoolPtr s_pool, ModVector &p_mods, ModVector &r_mods, bool *sol_found, SeparationStatus *status)
Separates current solution.
Definition: PerspCutHandler.cpp:556
void relaxNodeInc(NodePtr, RelaxationPtr, bool *)
Does nothing.
Definition: PerspCutHandler.h:85
std::vector< ConstraintPtr > getPRCons()
Return vector of perspective amenable constraint.
Definition: PerspCutHandler.h:188
void addCutToRel(RelaxationPtr rel, LinearFunctionPtr lf, double c)
Add PCut torelaxation.
Definition: PerspCutHandler.cpp:492
virtual Branches getBranches(BrCandPtr, DoubleVector &, RelaxationPtr, SolutionPoolPtr)
Does nothing.
Definition: PerspCutHandler.h:49
bool getStatus()
Return 1 if there are PR amenable constraints in the problem.
Definition: PerspCutHandler.cpp:84
bool isFeasible(ConstSolutionPtr, RelaxationPtr, bool &, double &)
Check feasibility of PR amenable constraints at the given solution.
Definition: PerspCutHandler.cpp:193
virtual bool presolveNode(RelaxationPtr, NodePtr, SolutionPoolPtr, ModVector &, ModVector &)
Does nothing.
Definition: PerspCutHandler.h:71
void relaxInitFull(RelaxationPtr, bool *)
Does nothing.
Definition: PerspCutHandler.h:76
void linearAt(RelaxationPtr rel, FunctionPtr f, double fval, const double *x, double *c, LinearFunctionPtr *lf, int *error)
Definition: PerspCutHandler.cpp:333
void bisecPt(const double *x, double *y, UInt it)
Definition: PerspCutHandler.cpp:506
void writeStats(std::ostream &out) const
Writes statistics.
Definition: PerspCutHandler.cpp:563
~PerspCutHandler()
Destructor.
Definition: PerspCutHandler.cpp:582
void addCut(RelaxationPtr rel, const double *nlpx, const double *lpx, UInt it, SeparationStatus *pcStatus)
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
SolveStatus
Different states an algorithm like branch-and-bound can be in.
Definition: Types.h:158
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

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