Minotaur 0.4.1
Docs for developers
Loading...
Searching...
No Matches
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 AbsHandler;
36 friend class AnalyticalCenter;
37 friend class ExpHandler;
38 friend class Linearizations;
39 friend class LogHandler;
40 friend class QGHandlerAdvance;
41 friend class ParQGHandlerAdvance;
42 friend class PerspCon;
43 friend class PowHandler;
44 friend class Problem;
45 friend class TransSep;
46 friend class QGHandler;
47 friend class OAHandler;
48 friend class QuadHandler;
49 friend class RecipHandler;
50 friend class MultiSolHeur;
51
53 Variable();
54
56 Variable(UInt id, UInt index, double lb, double ub, VariableType vtype,
57 std::string name);
58
60 virtual ~Variable();
61
63 VariablePtr clone(UInt id) const;
64
66 UInt getId() const { return id_; }
67
74 UInt getIndex() const { return index_; }
75
77 double getInitVal() const { return initVal_; }
78
80 double getLb() const { return lb_; }
81
83 double getUb() const { return ub_; }
84
86 VariableType getType() const { return vtype_; }
87
89 FunctionType getFunType() const { return ftype_; }
90
92 VarSrcType getSrcType() const { return stype_; }
93
95 VarState getState() const { return state_; }
96
97 UInt getNumCons() const;
98
99 UInt getItmp() const;
100
102 ConstrSet::iterator consBegin();
103
105 ConstrSet::iterator consEnd();
106
108 const std::string getName() const;
109
110 void setItmp(UInt itmp);
111
116 void write(std::ostream &out) const;
117
119 void writeConstraintMap(std::ostream &out) const;
120
121 protected:
124 {
125 ftype_ = ftype;
126 return;
127 }
128
130 void setId_(UInt n) { id_ = n; }
131
133 void setIndex_(UInt n) { index_ = n; }
134
136 void setInitVal_(double val) { initVal_ = val; }
137
139 void setLb_(double newLb) { lb_ = newLb; }
140
142 void setName_(std::string newName) { name_ = newName; }
143
145 void setSrcType(VarSrcType stype) { stype_ = stype; }
146
148 void setState_(VarState state)
149 {
150 state_ = state;
151 return;
152 }
153
155 void setType_(VariableType vtype);
156
158 void setUb_(double newUb) { ub_ = newUb; }
159
165
171
173 void clearConstraints_();
174
175 private:
177 ConstrSet cons_;
178
180 FunctionType ftype_;
181
183 UInt id_;
184
186 UInt index_;
187
189 double lb_;
190
192 std::string name_;
193
195 double initVal_;
196
198 VarState state_;
199
201 VarSrcType stype_;
202
204 double ub_;
205
207 VariableType vtype_;
208
210 Variable(const Variable &v);
211
213 Variable &operator=(const Variable &v);
214
216 UInt itmp_;
217 };
218
219 typedef std::set<std::pair<ConstraintPtr, FunctionType>>::const_iterator
220 ConstraintFunIterator;
221} //namespace Minotaur
222
223#endif
Declare important 'types' used in Minotaur.
Definition AbsHandler.h:50
Definition AnalyticalCenter.h:27
The Constraint class is used to manage a constraint.
Definition Constraint.h:61
Definition ExpHandler.h:31
Definition Linearizations.h:39
Definition LogHandler.h:31
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 PowHandler.h:30
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 RecipHandler.h:30
Definition TransSep.h:40
Definition Variable.h:31
UInt getIndex() const
Definition Variable.h:74
VarState getState() const
Get the state (fixed, deleted, ...).
Definition Variable.h:95
void setId_(UInt n)
Change the id to a new value.
Definition Variable.h:130
void setLb_(double newLb)
Change the lowerbound to a new value.
Definition Variable.h:139
VarSrcType getSrcType() const
Get the type of origin of this variable.
Definition Variable.h:92
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:145
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:77
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:148
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:66
void setUb_(double newUb)
Change the upperbound to a new value.
Definition Variable.h:158
FunctionType getFunType() const
Get the function type of constraints that this variable is in.
Definition Variable.h:89
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:142
double getUb() const
Get upperbound.
Definition Variable.h:83
void setIndex_(UInt n)
Change the index to a new value.
Definition Variable.h:133
VariableType getType() const
Get the type (binary, integer, continuous).
Definition Variable.h:86
void setFunType_(FunctionType ftype)
Change the function type to a new value.
Definition Variable.h:123
virtual ~Variable()
Destroy.
Definition Variable.cpp:65
double getLb() const
Get lowerbound.
Definition Variable.h:80
void setInitVal_(double val)
Change starting value.
Definition Variable.h:136
void outOfConstraint_(ConstraintPtr cPtr)
Remove the constraint from the list of constraints this variable belongs to.
Definition Variable.cpp:111
Definition AbsHandler.h:19
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.8 on Wed Jul 29 2026