1 | /* -*- mode: C++; indent-tabs-mode: nil; -*- |
---|
2 | * |
---|
3 | * This file is a part of LEMON, a generic C++ optimization library. |
---|
4 | * |
---|
5 | * Copyright (C) 2003-2008 |
---|
6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
---|
7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). |
---|
8 | * |
---|
9 | * Permission to use, modify and distribute this software is granted |
---|
10 | * provided that this copyright notice appears in all copies. For |
---|
11 | * precise terms see the accompanying LICENSE file. |
---|
12 | * |
---|
13 | * This software is provided "AS IS" with no warranty of any kind, |
---|
14 | * express or implied, and with no claim as to its suitability for any |
---|
15 | * purpose. |
---|
16 | * |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef LEMON_LP_SKELETON |
---|
20 | #define LEMON_LP_SKELETON |
---|
21 | |
---|
22 | #include <lemon/lp_base.h> |
---|
23 | |
---|
24 | ///\file |
---|
25 | ///\brief A skeleton file to implement LP solver interfaces |
---|
26 | namespace lemon { |
---|
27 | |
---|
28 | ///A skeleton class to implement LP solver interfaces |
---|
29 | class LpSkeleton :public LpSolverBase { |
---|
30 | int col_num,row_num; |
---|
31 | |
---|
32 | protected: |
---|
33 | |
---|
34 | ///\e |
---|
35 | virtual LpSolverBase* _newLp(); |
---|
36 | ///\e |
---|
37 | virtual LpSolverBase* _copyLp(); |
---|
38 | /// \e |
---|
39 | virtual int _addCol(); |
---|
40 | /// \e |
---|
41 | virtual int _addRow(); |
---|
42 | /// \e |
---|
43 | virtual void _eraseCol(int i); |
---|
44 | /// \e |
---|
45 | virtual void _eraseRow(int i); |
---|
46 | /// \e |
---|
47 | virtual void _getColName(int col, std::string & name) const; |
---|
48 | /// \e |
---|
49 | virtual void _setColName(int col, const std::string & name); |
---|
50 | /// \e |
---|
51 | virtual int _colByName(const std::string& name) const; |
---|
52 | |
---|
53 | /// \e |
---|
54 | virtual void _setRowCoeffs(int i, ConstRowIterator b, ConstRowIterator e); |
---|
55 | /// \e |
---|
56 | virtual void _getRowCoeffs(int i, RowIterator b) const; |
---|
57 | /// \e |
---|
58 | virtual void _setColCoeffs(int i, ConstColIterator b, ConstColIterator e); |
---|
59 | /// \e |
---|
60 | virtual void _getColCoeffs(int i, ColIterator b) const; |
---|
61 | |
---|
62 | /// Set one element of the coefficient matrix |
---|
63 | virtual void _setCoeff(int row, int col, Value value); |
---|
64 | |
---|
65 | /// Get one element of the coefficient matrix |
---|
66 | virtual Value _getCoeff(int row, int col) const; |
---|
67 | |
---|
68 | /// The lower bound of a variable (column) have to be given by an |
---|
69 | /// extended number of type Value, i.e. a finite number of type |
---|
70 | /// Value or -\ref INF. |
---|
71 | virtual void _setColLowerBound(int i, Value value); |
---|
72 | /// \e |
---|
73 | |
---|
74 | /// The lower bound of a variable (column) is an |
---|
75 | /// extended number of type Value, i.e. a finite number of type |
---|
76 | /// Value or -\ref INF. |
---|
77 | virtual Value _getColLowerBound(int i) const; |
---|
78 | |
---|
79 | /// The upper bound of a variable (column) have to be given by an |
---|
80 | /// extended number of type Value, i.e. a finite number of type |
---|
81 | /// Value or \ref INF. |
---|
82 | virtual void _setColUpperBound(int i, Value value); |
---|
83 | /// \e |
---|
84 | |
---|
85 | /// The upper bound of a variable (column) is an |
---|
86 | /// extended number of type Value, i.e. a finite number of type |
---|
87 | /// Value or \ref INF. |
---|
88 | virtual Value _getColUpperBound(int i) const; |
---|
89 | |
---|
90 | // /// The lower bound of a linear expression (row) have to be given by an |
---|
91 | // /// extended number of type Value, i.e. a finite number of type |
---|
92 | // /// Value or -\ref INF. |
---|
93 | // virtual void _setRowLowerBound(int i, Value value); |
---|
94 | // /// \e |
---|
95 | |
---|
96 | // /// The upper bound of a linear expression (row) have to be given by an |
---|
97 | // /// extended number of type Value, i.e. a finite number of type |
---|
98 | // /// Value or \ref INF. |
---|
99 | // virtual void _setRowUpperBound(int i, Value value); |
---|
100 | |
---|
101 | /// The lower and upper bound of a linear expression (row) have to be |
---|
102 | /// given by an |
---|
103 | /// extended number of type Value, i.e. a finite number of type |
---|
104 | /// Value or +/-\ref INF. |
---|
105 | virtual void _setRowBounds(int i, Value lb, Value ub); |
---|
106 | /// \e |
---|
107 | |
---|
108 | |
---|
109 | /// The lower and the upper bound of |
---|
110 | /// a constraint (row) are |
---|
111 | /// extended numbers of type Value, i.e. finite numbers of type |
---|
112 | /// Value, -\ref INF or \ref INF. |
---|
113 | virtual void _getRowBounds(int i, Value &lb, Value &ub) const; |
---|
114 | /// \e |
---|
115 | |
---|
116 | |
---|
117 | /// \e |
---|
118 | virtual void _clearObj(); |
---|
119 | /// \e |
---|
120 | virtual void _setObjCoeff(int i, Value obj_coef); |
---|
121 | |
---|
122 | /// \e |
---|
123 | virtual Value _getObjCoeff(int i) const; |
---|
124 | |
---|
125 | ///\e |
---|
126 | |
---|
127 | ///\bug Wrong interface |
---|
128 | /// |
---|
129 | virtual SolveExitStatus _solve(); |
---|
130 | |
---|
131 | ///\e |
---|
132 | |
---|
133 | ///\bug Wrong interface |
---|
134 | /// |
---|
135 | virtual Value _getPrimal(int i) const; |
---|
136 | |
---|
137 | ///\e |
---|
138 | |
---|
139 | ///\bug Wrong interface |
---|
140 | /// |
---|
141 | virtual Value _getDual(int i) const; |
---|
142 | |
---|
143 | ///\e |
---|
144 | |
---|
145 | ///\bug Wrong interface |
---|
146 | /// |
---|
147 | virtual Value _getPrimalValue() const; |
---|
148 | |
---|
149 | ///\e |
---|
150 | |
---|
151 | ///\bug Wrong interface |
---|
152 | /// |
---|
153 | virtual SolutionStatus _getPrimalStatus() const; |
---|
154 | |
---|
155 | ////e |
---|
156 | virtual SolutionStatus _getDualStatus() const; |
---|
157 | |
---|
158 | |
---|
159 | ///\e |
---|
160 | virtual ProblemTypes _getProblemType() const; |
---|
161 | |
---|
162 | ///\e |
---|
163 | virtual void _setMax(); |
---|
164 | ///\e |
---|
165 | virtual void _setMin(); |
---|
166 | |
---|
167 | ///\e |
---|
168 | virtual bool _isMax() const; |
---|
169 | |
---|
170 | |
---|
171 | |
---|
172 | ///\e |
---|
173 | virtual bool _isBasicCol(int i) const; |
---|
174 | |
---|
175 | |
---|
176 | |
---|
177 | public: |
---|
178 | LpSkeleton() : LpSolverBase(), col_num(0), row_num(0) {} |
---|
179 | }; |
---|
180 | |
---|
181 | } //namespace lemon |
---|
182 | |
---|
183 | #endif // LEMON_LP_SKELETON |
---|