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 AnalyticalCenter;
36 friend class Linearizations;
37 friend class LogHandler;
38 friend class QGHandlerAdvance;
39 friend class ParQGHandlerAdvance;
40 friend class PerspCon;
41 friend class Problem;
42 friend class TransSep;
43 friend class QGHandler;
44 friend class OAHandler;
45 friend class QuadHandler;
46 friend class MultiSolHeur;
47
49 Variable();
50
52 Variable(UInt id, UInt index, double lb, double ub, VariableType vtype,
53 std::string name);
54
56 virtual ~Variable();
57
59 VariablePtr clone(UInt id) const;
60
62 UInt getId() const { return id_; }
63
70 UInt getIndex() const { return index_; }
71
73 double getInitVal() const { return initVal_; }
74
76 double getLb() const { return lb_; }
77
79 double getUb() const { return ub_; }
80
82 VariableType getType() const { return vtype_; }
83
85 FunctionType getFunType() const { return ftype_; }
86
88 VarSrcType getSrcType() const { return stype_; }
89
91 VarState getState() const { return state_; }
92
93 UInt getNumCons() const;
94
95 UInt getItmp() const;
96
98 ConstrSet::iterator consBegin();
99
101 ConstrSet::iterator consEnd();
102
104 const std::string getName() const;
105
106 void setItmp(UInt itmp);
107
112 void write(std::ostream &out) const;
113
115 void writeConstraintMap(std::ostream &out) const;
116
117 protected:
120 {
121 ftype_ = ftype;
122 return;
123 }
124
126 void setId_(UInt n) { id_ = n; }
127
129 void setIndex_(UInt n) { index_ = n; }
130
132 void setInitVal_(double val) { initVal_ = val; }
133
135 void setLb_(double newLb) { lb_ = newLb; }
136
138 void setName_(std::string newName) { name_ = newName; }
139
141 void setSrcType(VarSrcType stype) { stype_ = stype; }
142
144 void setState_(VarState state)
145 {
146 state_ = state;
147 return;
148 }
149
151 void setType_(VariableType vtype);
152
154 void setUb_(double newUb) { ub_ = newUb; }
155
161
167
169 void clearConstraints_();
170
171 private:
173 ConstrSet cons_;
174
176 FunctionType ftype_;
177
179 UInt id_;
180
182 UInt index_;
183
185 double lb_;
186
188 std::string name_;
189
191 double initVal_;
192
194 VarState state_;
195
197 VarSrcType stype_;
198
200 double ub_;
201
203 VariableType vtype_;
204
206 Variable(const Variable &v);
207
209 Variable &operator=(const Variable &v);
210
212 UInt itmp_;
213 };
214
215 typedef std::set<std::pair<ConstraintPtr, FunctionType>>::const_iterator
216 ConstraintFunIterator;
217} //namespace Minotaur
218
219#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 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 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:70
VarState getState() const
Get the state (fixed, deleted, ...).
Definition Variable.h:91
void setId_(UInt n)
Change the id to a new value.
Definition Variable.h:126
void setLb_(double newLb)
Change the lowerbound to a new value.
Definition Variable.h:135
VarSrcType getSrcType() const
Get the type of origin of this variable.
Definition Variable.h:88
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:141
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:73
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:144
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:62
void setUb_(double newUb)
Change the upperbound to a new value.
Definition Variable.h:154
FunctionType getFunType() const
Get the function type of constraints that this variable is in.
Definition Variable.h:85
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:138
double getUb() const
Get upperbound.
Definition Variable.h:79
void setIndex_(UInt n)
Change the index to a new value.
Definition Variable.h:129
VariableType getType() const
Get the type (binary, integer, continuous).
Definition Variable.h:82
void setFunType_(FunctionType ftype)
Change the function type to a new value.
Definition Variable.h:119
virtual ~Variable()
Destroy.
Definition Variable.cpp:65
double getLb() const
Get lowerbound.
Definition Variable.h:76
void setInitVal_(double val)
Change starting value.
Definition Variable.h:132
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.8 on Thu Dec 18 2025