deba@458
|
1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*-
|
deba@458
|
2 |
*
|
deba@458
|
3 |
* This file is a part of LEMON, a generic C++ optimization library.
|
deba@458
|
4 |
*
|
alpar@877
|
5 |
* Copyright (C) 2003-2010
|
deba@458
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
deba@458
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
deba@458
|
8 |
*
|
deba@458
|
9 |
* Permission to use, modify and distribute this software is granted
|
deba@458
|
10 |
* provided that this copyright notice appears in all copies. For
|
deba@458
|
11 |
* precise terms see the accompanying LICENSE file.
|
deba@458
|
12 |
*
|
deba@458
|
13 |
* This software is provided "AS IS" with no warranty of any kind,
|
deba@458
|
14 |
* express or implied, and with no claim as to its suitability for any
|
deba@458
|
15 |
* purpose.
|
deba@458
|
16 |
*
|
deba@458
|
17 |
*/
|
deba@458
|
18 |
|
deba@529
|
19 |
#ifndef LEMON_LP_SKELETON_H
|
deba@529
|
20 |
#define LEMON_LP_SKELETON_H
|
deba@458
|
21 |
|
deba@458
|
22 |
#include <lemon/lp_base.h>
|
deba@458
|
23 |
|
deba@458
|
24 |
///\file
|
alpar@540
|
25 |
///\brief Skeleton file to implement LP/MIP solver interfaces
|
alpar@877
|
26 |
///
|
alpar@540
|
27 |
///The classes in this file do nothing, but they can serve as skeletons when
|
alpar@540
|
28 |
///implementing an interface to new solvers.
|
deba@458
|
29 |
namespace lemon {
|
deba@458
|
30 |
|
alpar@540
|
31 |
///A skeleton class to implement LP/MIP solver base interface
|
alpar@877
|
32 |
|
alpar@540
|
33 |
///This class does nothing, but it can serve as a skeleton when
|
alpar@540
|
34 |
///implementing an interface to new solvers.
|
deba@459
|
35 |
class SkeletonSolverBase : public virtual LpBase {
|
deba@458
|
36 |
int col_num,row_num;
|
deba@458
|
37 |
|
deba@458
|
38 |
protected:
|
deba@458
|
39 |
|
deba@459
|
40 |
SkeletonSolverBase()
|
deba@459
|
41 |
: col_num(-1), row_num(-1) {}
|
deba@459
|
42 |
|
deba@458
|
43 |
/// \e
|
deba@458
|
44 |
virtual int _addCol();
|
deba@458
|
45 |
/// \e
|
deba@458
|
46 |
virtual int _addRow();
|
deba@458
|
47 |
/// \e
|
deba@746
|
48 |
virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
|
deba@746
|
49 |
/// \e
|
deba@458
|
50 |
virtual void _eraseCol(int i);
|
deba@458
|
51 |
/// \e
|
deba@458
|
52 |
virtual void _eraseRow(int i);
|
deba@459
|
53 |
|
deba@458
|
54 |
/// \e
|
deba@459
|
55 |
virtual void _getColName(int col, std::string& name) const;
|
deba@458
|
56 |
/// \e
|
deba@459
|
57 |
virtual void _setColName(int col, const std::string& name);
|
deba@458
|
58 |
/// \e
|
deba@458
|
59 |
virtual int _colByName(const std::string& name) const;
|
deba@458
|
60 |
|
deba@458
|
61 |
/// \e
|
deba@459
|
62 |
virtual void _getRowName(int row, std::string& name) const;
|
deba@458
|
63 |
/// \e
|
deba@459
|
64 |
virtual void _setRowName(int row, const std::string& name);
|
deba@458
|
65 |
/// \e
|
deba@459
|
66 |
virtual int _rowByName(const std::string& name) const;
|
deba@459
|
67 |
|
deba@458
|
68 |
/// \e
|
deba@459
|
69 |
virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
|
deba@459
|
70 |
/// \e
|
deba@459
|
71 |
virtual void _getRowCoeffs(int i, InsertIterator b) const;
|
deba@459
|
72 |
/// \e
|
deba@459
|
73 |
virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
|
deba@459
|
74 |
/// \e
|
deba@459
|
75 |
virtual void _getColCoeffs(int i, InsertIterator b) const;
|
deba@458
|
76 |
|
deba@458
|
77 |
/// Set one element of the coefficient matrix
|
deba@458
|
78 |
virtual void _setCoeff(int row, int col, Value value);
|
deba@458
|
79 |
|
deba@458
|
80 |
/// Get one element of the coefficient matrix
|
deba@458
|
81 |
virtual Value _getCoeff(int row, int col) const;
|
deba@458
|
82 |
|
deba@458
|
83 |
/// The lower bound of a variable (column) have to be given by an
|
deba@458
|
84 |
/// extended number of type Value, i.e. a finite number of type
|
deba@458
|
85 |
/// Value or -\ref INF.
|
deba@458
|
86 |
virtual void _setColLowerBound(int i, Value value);
|
deba@458
|
87 |
/// \e
|
deba@458
|
88 |
|
deba@458
|
89 |
/// The lower bound of a variable (column) is an
|
deba@458
|
90 |
/// extended number of type Value, i.e. a finite number of type
|
deba@458
|
91 |
/// Value or -\ref INF.
|
deba@458
|
92 |
virtual Value _getColLowerBound(int i) const;
|
deba@458
|
93 |
|
deba@458
|
94 |
/// The upper bound of a variable (column) have to be given by an
|
deba@458
|
95 |
/// extended number of type Value, i.e. a finite number of type
|
deba@458
|
96 |
/// Value or \ref INF.
|
deba@458
|
97 |
virtual void _setColUpperBound(int i, Value value);
|
deba@458
|
98 |
/// \e
|
deba@458
|
99 |
|
deba@458
|
100 |
/// The upper bound of a variable (column) is an
|
deba@458
|
101 |
/// extended number of type Value, i.e. a finite number of type
|
deba@458
|
102 |
/// Value or \ref INF.
|
deba@458
|
103 |
virtual Value _getColUpperBound(int i) const;
|
deba@458
|
104 |
|
deba@459
|
105 |
/// The lower bound of a constraint (row) have to be given by an
|
deba@458
|
106 |
/// extended number of type Value, i.e. a finite number of type
|
deba@459
|
107 |
/// Value or -\ref INF.
|
deba@459
|
108 |
virtual void _setRowLowerBound(int i, Value value);
|
deba@458
|
109 |
/// \e
|
deba@458
|
110 |
|
deba@459
|
111 |
/// The lower bound of a constraint (row) is an
|
deba@459
|
112 |
/// extended number of type Value, i.e. a finite number of type
|
deba@459
|
113 |
/// Value or -\ref INF.
|
deba@459
|
114 |
virtual Value _getRowLowerBound(int i) const;
|
deba@458
|
115 |
|
deba@459
|
116 |
/// The upper bound of a constraint (row) have to be given by an
|
deba@459
|
117 |
/// extended number of type Value, i.e. a finite number of type
|
deba@459
|
118 |
/// Value or \ref INF.
|
deba@459
|
119 |
virtual void _setRowUpperBound(int i, Value value);
|
deba@458
|
120 |
/// \e
|
deba@458
|
121 |
|
deba@459
|
122 |
/// The upper bound of a constraint (row) is an
|
deba@459
|
123 |
/// extended number of type Value, i.e. a finite number of type
|
deba@459
|
124 |
/// Value or \ref INF.
|
deba@459
|
125 |
virtual Value _getRowUpperBound(int i) const;
|
deba@458
|
126 |
|
deba@458
|
127 |
/// \e
|
deba@459
|
128 |
virtual void _setObjCoeffs(ExprIterator b, ExprIterator e);
|
deba@459
|
129 |
/// \e
|
deba@459
|
130 |
virtual void _getObjCoeffs(InsertIterator b) const;
|
deba@459
|
131 |
|
deba@458
|
132 |
/// \e
|
deba@458
|
133 |
virtual void _setObjCoeff(int i, Value obj_coef);
|
deba@458
|
134 |
/// \e
|
deba@458
|
135 |
virtual Value _getObjCoeff(int i) const;
|
deba@458
|
136 |
|
deba@458
|
137 |
///\e
|
deba@459
|
138 |
virtual void _setSense(Sense);
|
deba@459
|
139 |
///\e
|
deba@459
|
140 |
virtual Sense _getSense() const;
|
deba@459
|
141 |
|
deba@459
|
142 |
///\e
|
deba@459
|
143 |
virtual void _clear();
|
deba@459
|
144 |
|
deba@576
|
145 |
///\e
|
deba@576
|
146 |
virtual void _messageLevel(MessageLevel);
|
alpar@1063
|
147 |
|
alpar@1063
|
148 |
///\e
|
alpar@1063
|
149 |
virtual void _write(std::string file, std::string format) const;
|
alpar@1063
|
150 |
|
deba@459
|
151 |
};
|
deba@459
|
152 |
|
alpar@540
|
153 |
/// \brief Skeleton class for an LP solver interface
|
deba@459
|
154 |
///
|
alpar@540
|
155 |
///This class does nothing, but it can serve as a skeleton when
|
alpar@540
|
156 |
///implementing an interface to new solvers.
|
alpar@540
|
157 |
|
deba@459
|
158 |
///\ingroup lp_group
|
alpar@540
|
159 |
class LpSkeleton : public LpSolver, public SkeletonSolverBase {
|
deba@459
|
160 |
public:
|
alpar@540
|
161 |
///\e
|
alpar@540
|
162 |
LpSkeleton() : LpSolver(), SkeletonSolverBase() {}
|
alpar@540
|
163 |
///\e
|
alpar@540
|
164 |
virtual LpSkeleton* newSolver() const;
|
alpar@540
|
165 |
///\e
|
alpar@540
|
166 |
virtual LpSkeleton* cloneSolver() const;
|
deba@459
|
167 |
protected:
|
deba@459
|
168 |
|
deba@459
|
169 |
///\e
|
deba@459
|
170 |
virtual SolveExitStatus _solve();
|
deba@459
|
171 |
|
deba@459
|
172 |
///\e
|
deba@459
|
173 |
virtual Value _getPrimal(int i) const;
|
deba@459
|
174 |
///\e
|
deba@459
|
175 |
virtual Value _getDual(int i) const;
|
deba@459
|
176 |
|
deba@459
|
177 |
///\e
|
deba@459
|
178 |
virtual Value _getPrimalValue() const;
|
deba@459
|
179 |
|
deba@459
|
180 |
///\e
|
deba@459
|
181 |
virtual Value _getPrimalRay(int i) const;
|
deba@459
|
182 |
///\e
|
deba@459
|
183 |
virtual Value _getDualRay(int i) const;
|
deba@459
|
184 |
|
deba@459
|
185 |
///\e
|
deba@459
|
186 |
virtual ProblemType _getPrimalType() const;
|
deba@459
|
187 |
///\e
|
deba@459
|
188 |
virtual ProblemType _getDualType() const;
|
deba@459
|
189 |
|
deba@459
|
190 |
///\e
|
deba@459
|
191 |
virtual VarStatus _getColStatus(int i) const;
|
deba@459
|
192 |
///\e
|
deba@459
|
193 |
virtual VarStatus _getRowStatus(int i) const;
|
deba@459
|
194 |
|
deba@459
|
195 |
///\e
|
deba@459
|
196 |
virtual const char* _solverName() const;
|
deba@459
|
197 |
|
deba@459
|
198 |
};
|
deba@459
|
199 |
|
alpar@540
|
200 |
/// \brief Skeleton class for a MIP solver interface
|
deba@459
|
201 |
///
|
alpar@540
|
202 |
///This class does nothing, but it can serve as a skeleton when
|
alpar@540
|
203 |
///implementing an interface to new solvers.
|
deba@459
|
204 |
///\ingroup lp_group
|
alpar@540
|
205 |
class MipSkeleton : public MipSolver, public SkeletonSolverBase {
|
deba@459
|
206 |
public:
|
alpar@540
|
207 |
///\e
|
alpar@540
|
208 |
MipSkeleton() : MipSolver(), SkeletonSolverBase() {}
|
alpar@540
|
209 |
///\e
|
alpar@540
|
210 |
virtual MipSkeleton* newSolver() const;
|
alpar@540
|
211 |
///\e
|
alpar@540
|
212 |
virtual MipSkeleton* cloneSolver() const;
|
deba@459
|
213 |
|
deba@459
|
214 |
protected:
|
deba@459
|
215 |
///\e
|
deba@458
|
216 |
virtual SolveExitStatus _solve();
|
deba@458
|
217 |
|
deba@458
|
218 |
///\e
|
deba@459
|
219 |
virtual Value _getSol(int i) const;
|
deba@458
|
220 |
|
deba@458
|
221 |
///\e
|
deba@459
|
222 |
virtual Value _getSolValue() const;
|
deba@458
|
223 |
|
deba@458
|
224 |
///\e
|
deba@459
|
225 |
virtual ProblemType _getType() const;
|
deba@458
|
226 |
|
deba@458
|
227 |
///\e
|
deba@459
|
228 |
virtual const char* _solverName() const;
|
alpar@1063
|
229 |
|
deba@458
|
230 |
};
|
deba@458
|
231 |
|
deba@458
|
232 |
} //namespace lemon
|
deba@458
|
233 |
|
deba@529
|
234 |
#endif
|