| ... |
... |
@@ -62,194 +62,192 @@
|
| 62 |
62 |
|
| 63 |
63 |
virtual void _getColName(int col, std::string& name) const;
|
| 64 |
64 |
virtual void _setColName(int col, const std::string& name);
|
| 65 |
65 |
virtual int _colByName(const std::string& name) const;
|
| 66 |
66 |
|
| 67 |
67 |
virtual void _getRowName(int row, std::string& name) const;
|
| 68 |
68 |
virtual void _setRowName(int row, const std::string& name);
|
| 69 |
69 |
virtual int _rowByName(const std::string& name) const;
|
| 70 |
70 |
|
| 71 |
71 |
virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
|
| 72 |
72 |
virtual void _getRowCoeffs(int i, InsertIterator b) const;
|
| 73 |
73 |
|
| 74 |
74 |
virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
|
| 75 |
75 |
virtual void _getColCoeffs(int i, InsertIterator b) const;
|
| 76 |
76 |
|
| 77 |
77 |
virtual void _setCoeff(int row, int col, Value value);
|
| 78 |
78 |
virtual Value _getCoeff(int row, int col) const;
|
| 79 |
79 |
|
| 80 |
80 |
virtual void _setColLowerBound(int i, Value value);
|
| 81 |
81 |
virtual Value _getColLowerBound(int i) const;
|
| 82 |
82 |
|
| 83 |
83 |
virtual void _setColUpperBound(int i, Value value);
|
| 84 |
84 |
virtual Value _getColUpperBound(int i) const;
|
| 85 |
85 |
|
| 86 |
86 |
virtual void _setRowLowerBound(int i, Value value);
|
| 87 |
87 |
virtual Value _getRowLowerBound(int i) const;
|
| 88 |
88 |
|
| 89 |
89 |
virtual void _setRowUpperBound(int i, Value value);
|
| 90 |
90 |
virtual Value _getRowUpperBound(int i) const;
|
| 91 |
91 |
|
| 92 |
92 |
virtual void _setObjCoeffs(ExprIterator b, ExprIterator e);
|
| 93 |
93 |
virtual void _getObjCoeffs(InsertIterator b) const;
|
| 94 |
94 |
|
| 95 |
95 |
virtual void _setObjCoeff(int i, Value obj_coef);
|
| 96 |
96 |
virtual Value _getObjCoeff(int i) const;
|
| 97 |
97 |
|
| 98 |
98 |
virtual void _setSense(Sense);
|
| 99 |
99 |
virtual Sense _getSense() const;
|
| 100 |
100 |
|
| 101 |
101 |
virtual void _clear();
|
| 102 |
102 |
|
| 103 |
103 |
public:
|
| 104 |
104 |
|
| 105 |
105 |
///Pointer to the underlying GLPK data structure.
|
| 106 |
106 |
LPX *lpx() {return lp;}
|
| 107 |
107 |
///Const pointer to the underlying GLPK data structure.
|
| 108 |
108 |
const LPX *lpx() const {return lp;}
|
| 109 |
109 |
|
| 110 |
110 |
///Returns the constraint identifier understood by GLPK.
|
| 111 |
111 |
int lpxRow(Row r) const { return rows(id(r)); }
|
| 112 |
112 |
|
| 113 |
113 |
///Returns the variable identifier understood by GLPK.
|
| 114 |
114 |
int lpxCol(Col c) const { return cols(id(c)); }
|
| 115 |
115 |
|
| 116 |
116 |
};
|
| 117 |
117 |
|
| 118 |
118 |
/// \brief Interface for the GLPK LP solver
|
| 119 |
119 |
///
|
| 120 |
120 |
/// This class implements an interface for the GLPK LP solver.
|
| 121 |
121 |
///\ingroup lp_group
|
| 122 |
122 |
class GlpkLp : public LpSolver, public GlpkBase {
|
| 123 |
123 |
public:
|
| 124 |
124 |
|
| 125 |
125 |
///\e
|
| 126 |
126 |
GlpkLp();
|
| 127 |
127 |
///\e
|
| 128 |
128 |
GlpkLp(const GlpkLp&);
|
| 129 |
129 |
|
| 130 |
130 |
///\e
|
| 131 |
131 |
virtual GlpkLp* cloneSolver() const;
|
| 132 |
132 |
///\e
|
| 133 |
133 |
virtual GlpkLp* newSolver() const;
|
| 134 |
134 |
|
| 135 |
135 |
private:
|
| 136 |
136 |
|
| 137 |
137 |
mutable std::vector<double> _primal_ray;
|
| 138 |
138 |
mutable std::vector<double> _dual_ray;
|
| 139 |
139 |
|
| 140 |
140 |
void _clear_temporals();
|
| 141 |
141 |
|
| 142 |
142 |
protected:
|
| 143 |
143 |
|
| 144 |
144 |
virtual const char* _solverName() const;
|
| 145 |
145 |
|
| 146 |
146 |
virtual SolveExitStatus _solve();
|
| 147 |
147 |
virtual Value _getPrimal(int i) const;
|
| 148 |
148 |
virtual Value _getDual(int i) const;
|
| 149 |
149 |
|
| 150 |
150 |
virtual Value _getPrimalValue() const;
|
| 151 |
151 |
|
| 152 |
152 |
virtual VarStatus _getColStatus(int i) const;
|
| 153 |
153 |
virtual VarStatus _getRowStatus(int i) const;
|
| 154 |
154 |
|
| 155 |
155 |
virtual Value _getPrimalRay(int i) const;
|
| 156 |
156 |
virtual Value _getDualRay(int i) const;
|
| 157 |
157 |
|
| 158 |
|
///\todo It should be clarified
|
| 159 |
|
///
|
| 160 |
158 |
virtual ProblemType _getPrimalType() const;
|
| 161 |
159 |
virtual ProblemType _getDualType() const;
|
| 162 |
160 |
|
| 163 |
161 |
public:
|
| 164 |
162 |
|
| 165 |
163 |
///Solve with primal simplex
|
| 166 |
164 |
SolveExitStatus solvePrimal();
|
| 167 |
165 |
|
| 168 |
166 |
///Solve with dual simplex
|
| 169 |
167 |
SolveExitStatus solveDual();
|
| 170 |
168 |
|
| 171 |
169 |
///Turns on or off the presolver
|
| 172 |
170 |
|
| 173 |
171 |
///Turns on (\c b is \c true) or off (\c b is \c false) the presolver
|
| 174 |
172 |
///
|
| 175 |
173 |
///The presolver is off by default.
|
| 176 |
174 |
void presolver(bool b);
|
| 177 |
175 |
|
| 178 |
176 |
///Enum for \c messageLevel() parameter
|
| 179 |
177 |
enum MessageLevel {
|
| 180 |
178 |
/// no output (default value)
|
| 181 |
179 |
MESSAGE_NO_OUTPUT = 0,
|
| 182 |
180 |
/// error messages only
|
| 183 |
181 |
MESSAGE_ERROR_MESSAGE = 1,
|
| 184 |
182 |
/// normal output
|
| 185 |
183 |
MESSAGE_NORMAL_OUTPUT = 2,
|
| 186 |
184 |
/// full output (includes informational messages)
|
| 187 |
185 |
MESSAGE_FULL_OUTPUT = 3
|
| 188 |
186 |
};
|
| 189 |
187 |
|
| 190 |
188 |
private:
|
| 191 |
189 |
|
| 192 |
190 |
MessageLevel _message_level;
|
| 193 |
191 |
|
| 194 |
192 |
public:
|
| 195 |
193 |
|
| 196 |
194 |
///Set the verbosity of the messages
|
| 197 |
195 |
|
| 198 |
196 |
///Set the verbosity of the messages
|
| 199 |
197 |
///
|
| 200 |
198 |
///\param m is the level of the messages output by the solver routines.
|
| 201 |
199 |
void messageLevel(MessageLevel m);
|
| 202 |
200 |
};
|
| 203 |
201 |
|
| 204 |
202 |
/// \brief Interface for the GLPK MIP solver
|
| 205 |
203 |
///
|
| 206 |
204 |
/// This class implements an interface for the GLPK MIP solver.
|
| 207 |
205 |
///\ingroup lp_group
|
| 208 |
206 |
class GlpkMip : public MipSolver, public GlpkBase {
|
| 209 |
207 |
public:
|
| 210 |
208 |
|
| 211 |
209 |
///\e
|
| 212 |
210 |
GlpkMip();
|
| 213 |
211 |
///\e
|
| 214 |
212 |
GlpkMip(const GlpkMip&);
|
| 215 |
213 |
|
| 216 |
214 |
virtual GlpkMip* cloneSolver() const;
|
| 217 |
215 |
virtual GlpkMip* newSolver() const;
|
| 218 |
216 |
|
| 219 |
217 |
protected:
|
| 220 |
218 |
|
| 221 |
219 |
virtual const char* _solverName() const;
|
| 222 |
220 |
|
| 223 |
221 |
virtual ColTypes _getColType(int col) const;
|
| 224 |
222 |
virtual void _setColType(int col, ColTypes col_type);
|
| 225 |
223 |
|
| 226 |
224 |
virtual SolveExitStatus _solve();
|
| 227 |
225 |
virtual ProblemType _getType() const;
|
| 228 |
226 |
virtual Value _getSol(int i) const;
|
| 229 |
227 |
virtual Value _getSolValue() const;
|
| 230 |
228 |
|
| 231 |
229 |
///Enum for \c messageLevel() parameter
|
| 232 |
230 |
enum MessageLevel {
|
| 233 |
231 |
/// no output (default value)
|
| 234 |
232 |
MESSAGE_NO_OUTPUT = 0,
|
| 235 |
233 |
/// error messages only
|
| 236 |
234 |
MESSAGE_ERROR_MESSAGE = 1,
|
| 237 |
235 |
/// normal output
|
| 238 |
236 |
MESSAGE_NORMAL_OUTPUT = 2,
|
| 239 |
237 |
/// full output (includes informational messages)
|
| 240 |
238 |
MESSAGE_FULL_OUTPUT = 3
|
| 241 |
239 |
};
|
| 242 |
240 |
|
| 243 |
241 |
private:
|
| 244 |
242 |
|
| 245 |
243 |
MessageLevel _message_level;
|
| 246 |
244 |
|
| 247 |
245 |
public:
|
| 248 |
246 |
|
| 249 |
247 |
///Set the verbosity of the messages
|
| 250 |
248 |
|
| 251 |
249 |
///Set the verbosity of the messages
|
| 252 |
250 |
///
|
| 253 |
251 |
///\param m is the level of the messages output by the solver routines.
|
| 254 |
252 |
void messageLevel(MessageLevel m);
|
| 255 |
253 |
};
|