Minotaur 0.4.1
Docs for developers
Cut.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
13#ifndef MINOTAURCUT_H
14#define MINOTAURCUT_H
15
16#include "Types.h"
17
18namespace Minotaur {
19
20 class Function;
21
22 struct CutInfo
23 {
24 UInt timesEnabled;
33
34 double hash;
35 double varScore;
36 double fixedScore;
37
40 bool inRel;
41 };
42
43
52 class Cut {
53
54 public:
56 Cut();
57
71 Cut(size_t n, FunctionPtr f, double lb, double ub, bool never_delete,
72 bool never_disable);
73
74
75 Cut(ProblemPtr p, FunctionPtr f, double lb, double ub, bool never_delete,
76 bool never_disable);
78 ~Cut();
79
85
92 double eval(const double *x, int *err);
93
100 void evalScore(const double *x, double *vio, double *score);
101
107
110
112 CutInfo *getInfo() { return &info_; }
113
115 double getLb() { return lb_; }
116
118 std::string getName() { return name_; }
119
121 double getUb() { return ub_; }
122
124 void setCons(ConstraintPtr c) { cons_ = c; }
125
127 void setName_(std::string name) { name_ = name; }
128
130 void write(std::ostream &out) const;
131
133 void writeStats(std::ostream &out) const;
134
135 protected:
138
141
144
146 double lb_;
147
150
152 size_t n_;
153
155 double ub_;
156
159
161 std::string name_;
162
169 void initInfo_(bool never_delete, bool never_disable);
170
174 void evalFixedScore_();
175 };
176
177 typedef std::vector<CutPtr> CutVector;
178 typedef CutVector::iterator CutIterator;
179 typedef CutVector::const_iterator CutConstIterator;
180} //namespace Minotaur
181#endif
Declare important 'types' used in Minotaur.
The Constraint class is used to manage a constraint.
Definition: Constraint.h:61
Store function, bounds and other information about a cut.
Definition: Cut.h:52
CutInfo * getInfo()
Get pointer to the cut info data structure.
Definition: Cut.h:112
double getUb()
Get ub of the inequality.
Definition: Cut.h:121
double lb_
Lower bound.
Definition: Cut.h:146
double eval(const double *x, int *err)
Evaluate the activity of this cut at a given point.
Definition: Cut.cpp:83
FunctionPtr f_
Pointer to the function of a cut.
Definition: Cut.h:140
double getLb()
Get lb of the inequality.
Definition: Cut.h:115
void evalScore(const double *x, double *vio, double *score)
Evaluate score of this cut at a given point.
Definition: Cut.cpp:88
FunctionPtr getFunction()
Get Function Pointer of the cut.
Definition: Cut.h:109
std::string name_
Name of the cut (could be NULL).
Definition: Cut.h:161
CutInfo info_
Information about the cut.
Definition: Cut.h:143
~Cut()
Destroy.
Definition: Cut.cpp:72
void initInfo_(bool never_delete, bool never_disable)
Initialize the values in info_ data structure.
Definition: Cut.cpp:110
size_t n_
Number of variables in the problem. Used to calculate hash.
Definition: Cut.h:152
ConstraintPtr cons_
Pointer to the constraint. Null if it is disabled.
Definition: Cut.h:137
double fixedScore_
Fixed score of each cut.
Definition: Cut.h:158
Cut()
Empty Constructor.
Definition: Cut.cpp:35
std::string getName()
Get name of the cut.
Definition: Cut.h:118
void evalFixedScore_()
Assign a fixed score to the cut.
Definition: Cut.cpp:101
ConstraintPtr getConstraint()
Get Constraint pointer if this cut is in the problem. Null otherwise.
Definition: Cut.h:106
void writeStats(std::ostream &out) const
Display statistics and information.
Definition: Cut.cpp:143
void setName_(std::string name)
Set name of the cut.
Definition: Cut.h:127
void write(std::ostream &out) const
Display.
Definition: Cut.cpp:131
void applyToProblem(ProblemPtr p)
Add a cut to the problem.
Definition: Cut.cpp:78
LoggerPtr logger_
Logger for display.
Definition: Cut.h:149
double ub_
Upper bound.
Definition: Cut.h:155
void setCons(ConstraintPtr c)
Constraint associated with the cut.
Definition: Cut.h:124
Definition: Function.h:37
Definition: Logger.h:37
Definition: Problem.h:74
Definition: ActiveNodeStore.h:20
unsigned int UInt
Unsigned integer.
Definition: Types.h:30
Definition: Cut.h:23
UInt lastEnabled
No. of times it was removed from problem.
Definition: Cut.h:26
bool neverDisable
If true, never delete cut from pool.
Definition: Cut.h:39
UInt numActive
Updated for cuts disabled in pool.
Definition: Cut.h:30
bool neverDelete
Fixed score (does not change.)
Definition: Cut.h:38
bool inRel
If true, never remove cut from problem.
Definition: Cut.h:40
UInt cntSinceActive
How many iters since it was last disabled.
Definition: Cut.h:28
UInt timesDisabled
No. of times it was moved from pool to problem.
Definition: Cut.h:25
double hash
Definition: Cut.h:34
UInt lastDisabled
How many iters since it was last enabled.
Definition: Cut.h:27
UInt cntSinceViol
Updated for cuts enabled in problem.
Definition: Cut.h:29
double varScore
Hash value of this cut.
Definition: Cut.h:35
int parent_active_cnts
Updated only for cuts in problem.
Definition: Cut.h:31
double fixedScore
Variable score (changes every iteration.)
Definition: Cut.h:36

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