Minotaur 0.4.1
Docs for developers
Variable.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
16#ifndef MINOTAURVARIABLE_H
17#define MINOTAURVARIABLE_H
18
19#include <string>
20
21#include "Types.h"
22
23namespace Minotaur {
24
31 class Variable {
32 public:
35 friend class AnalyticalCenter;
36 friend class Linearizations;
37 friend class QGHandlerAdvance;
38 friend class ParQGHandlerAdvance;
39 friend class PerspCon;
40 friend class Problem;
41 friend class TransSep;
42 friend class QGHandler;
43 friend class OAHandler;
44 friend class QuadHandler;
45 friend class MultiSolHeur;
46
48 Variable();
49
51 Variable(UInt id, UInt index, double lb, double ub, VariableType vtype,
52 std::string name);
53
55 virtual ~Variable();
56
58 VariablePtr clone(UInt id) const;
59
61 UInt getId() const { return id_; }
62
69 UInt getIndex() const { return index_; }
70
72 double getInitVal() const { return initVal_; }
73
75 double getLb() const { return lb_; }
76
78 double getUb() const { return ub_; }
79
81 VariableType getType() const { return vtype_; }
82
84 FunctionType getFunType() const { return ftype_; }
85
87 VarSrcType getSrcType() const { return stype_; }
88
90 VarState getState() const { return state_; }
91
92 UInt getNumCons() const;
93
94 UInt getItmp() const;
95
97 ConstrSet::iterator consBegin();
98
100 ConstrSet::iterator consEnd();
101
103 const std::string getName() const;
104
105 void setItmp(UInt itmp);
106
111 void write(std::ostream &out) const;
112
114 void writeConstraintMap(std::ostream &out) const;
115
116 protected:
119 {
120 ftype_ = ftype;
121 return;
122 }
123
125 void setId_(UInt n) { id_ = n; }
126
128 void setIndex_(UInt n) { index_ = n; }
129
131 void setInitVal_(double val) { initVal_ = val; }
132
134 void setLb_(double newLb) { lb_ = newLb; }
135
137 void setName_(std::string newName) { name_ = newName; }
138
140 void setSrcType(VarSrcType stype) { stype_ = stype; }
141
143 void setState_(VarState state)
144 {
145 state_ = state;
146 return;
147 }
148
150 void setType_(VariableType vtype);
151
153 void setUb_(double newUb) { ub_ = newUb; }
154
160
166
168 void clearConstraints_();
169
170 private:
172 ConstrSet cons_;
173
175 FunctionType ftype_;
176
178 UInt id_;
179
181 UInt index_;
182
184 double lb_;
185
187 std::string name_;
188
190 double initVal_;
191
193 VarState state_;
194
196 VarSrcType stype_;
197
199 double ub_;
200
202 VariableType vtype_;
203
205 Variable(const Variable &v);
206
208 Variable &operator=(const Variable &v);
209
211 UInt itmp_;
212 };
213
214 typedef std::set<std::pair<ConstraintPtr, FunctionType>>::const_iterator
215 ConstraintFunIterator;
216} //namespace Minotaur
217
218#endif
Declare important 'types' used in Minotaur.
Definition: AnalyticalCenter.h:27
The Constraint class is used to manage a constraint.
Definition: Constraint.h:61
Definition: Linearizations.h:39
Definition: MultiSolHeur.h:38
Handler for convex constraints, based on quesada-grossmann algorithm.
Definition: OAHandler.h:46
Handler for convex constraints, based on quesada-grossmann algorithm.
Definition: ParQGHandlerAdvance.h:47
Definition: PerspCon.h:81
Definition: Problem.h:74
Handler for convex constraints, based on quesada-grossmann algorithm.
Definition: QGHandlerAdvance.h:53
Handler for convex constraints, based on quesada-grossmann algorithm.
Definition: QGHandler.h:45
‍Iterator for LinSqrMap
Definition: QuadHandler.h:63
Definition: TransSep.h:40
Definition: Variable.h:31
UInt getIndex() const
Definition: Variable.h:69
VarState getState() const
Get the state (fixed, deleted, ...).
Definition: Variable.h:90
void setId_(UInt n)
Change the id to a new value.
Definition: Variable.h:125
void setLb_(double newLb)
Change the lowerbound to a new value.
Definition: Variable.h:134
VarSrcType getSrcType() const
Get the type of origin of this variable.
Definition: Variable.h:87
void write(std::ostream &out) const
Write the full description of the variable including name, bounds, type etc.
Definition: Variable.cpp:135
ConstrSet::iterator consEnd()
Last iterator of constraints where this variable appears.
Definition: Variable.cpp:83
void setSrcType(VarSrcType stype)
Change the type of the origin of this variable.
Definition: Variable.h:140
void setType_(VariableType vtype)
Change the type to a new value.
Definition: Variable.cpp:121
Variable()
Default constructor.
Definition: Variable.cpp:22
double getInitVal() const
Get starting or initial value.
Definition: Variable.h:72
ConstrSet::iterator consBegin()
First iterator of constraints where this variable appears.
Definition: Variable.cpp:77
void clearConstraints_()
Clear the list of constraints this variable belongs to.
Definition: Variable.cpp:71
const std::string getName() const
Get name of the variable.
Definition: Variable.cpp:89
void setState_(VarState state)
Change the state to a new value.
Definition: Variable.h:143
void writeConstraintMap(std::ostream &out) const
Write the list of constraints in which this variable occurs.
Definition: Variable.cpp:169
UInt getId() const
Get the unique id.
Definition: Variable.h:61
void setUb_(double newUb)
Change the upperbound to a new value.
Definition: Variable.h:153
FunctionType getFunType() const
Get the function type of constraints that this variable is in.
Definition: Variable.h:84
VariablePtr clone(UInt id) const
Create a copy.
Definition: Variable.cpp:54
void inConstraint_(ConstraintPtr c)
Add the constraint to the list of constraints this variable belongs to.
Definition: Variable.cpp:105
void setName_(std::string newName)
Change the name to a new value.
Definition: Variable.h:137
double getUb() const
Get upperbound.
Definition: Variable.h:78
void setIndex_(UInt n)
Change the index to a new value.
Definition: Variable.h:128
VariableType getType() const
Get the type (binary, integer, continuous).
Definition: Variable.h:81
void setFunType_(FunctionType ftype)
Change the function type to a new value.
Definition: Variable.h:118
virtual ~Variable()
Destroy.
Definition: Variable.cpp:65
double getLb() const
Get lowerbound.
Definition: Variable.h:75
void setInitVal_(double val)
Change starting value.
Definition: Variable.h:131
void outOfConstraint_(ConstraintPtr cPtr)
Remove the constraint from the list of constraints this variable belongs to.
Definition: Variable.cpp:111
Definition: ActiveNodeStore.h:20
VarState
Different states a variable can be in.
Definition: Types.h:137
VariableType
Different types of variables.
Definition: Types.h:76
VarSrcType
Where did the variable originate from?
Definition: Types.h:85
unsigned int UInt
Unsigned integer.
Definition: Types.h:30
FunctionType
Different types of functions in Minotaur.
Definition: Types.h:65

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