1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
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.
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
19 #ifndef LEMON_LP_SKELETON
20 #define LEMON_LP_SKELETON
22 #include <lemon/lp_base.h>
25 ///\brief A skeleton file to implement LP solver interfaces
28 ///A skeleton class to implement LP solver interfaces
29 class SkeletonSolverBase : public virtual LpBase {
35 : col_num(-1), row_num(-1) {}
38 virtual int _addCol();
40 virtual int _addRow();
42 virtual void _eraseCol(int i);
44 virtual void _eraseRow(int i);
47 virtual void _getColName(int col, std::string& name) const;
49 virtual void _setColName(int col, const std::string& name);
51 virtual int _colByName(const std::string& name) const;
54 virtual void _getRowName(int row, std::string& name) const;
56 virtual void _setRowName(int row, const std::string& name);
58 virtual int _rowByName(const std::string& name) const;
61 virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
63 virtual void _getRowCoeffs(int i, InsertIterator b) const;
65 virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
67 virtual void _getColCoeffs(int i, InsertIterator b) const;
69 /// Set one element of the coefficient matrix
70 virtual void _setCoeff(int row, int col, Value value);
72 /// Get one element of the coefficient matrix
73 virtual Value _getCoeff(int row, int col) const;
75 /// The lower bound of a variable (column) have to be given by an
76 /// extended number of type Value, i.e. a finite number of type
77 /// Value or -\ref INF.
78 virtual void _setColLowerBound(int i, Value value);
81 /// The lower bound of a variable (column) is an
82 /// extended number of type Value, i.e. a finite number of type
83 /// Value or -\ref INF.
84 virtual Value _getColLowerBound(int i) const;
86 /// The upper bound of a variable (column) have to be given by an
87 /// extended number of type Value, i.e. a finite number of type
88 /// Value or \ref INF.
89 virtual void _setColUpperBound(int i, Value value);
92 /// The upper bound of a variable (column) is an
93 /// extended number of type Value, i.e. a finite number of type
94 /// Value or \ref INF.
95 virtual Value _getColUpperBound(int i) const;
97 /// The lower bound of a constraint (row) have to be given by an
98 /// extended number of type Value, i.e. a finite number of type
99 /// Value or -\ref INF.
100 virtual void _setRowLowerBound(int i, Value value);
103 /// The lower bound of a constraint (row) is an
104 /// extended number of type Value, i.e. a finite number of type
105 /// Value or -\ref INF.
106 virtual Value _getRowLowerBound(int i) const;
108 /// The upper bound of a constraint (row) have to be given by an
109 /// extended number of type Value, i.e. a finite number of type
110 /// Value or \ref INF.
111 virtual void _setRowUpperBound(int i, Value value);
114 /// The upper bound of a constraint (row) is an
115 /// extended number of type Value, i.e. a finite number of type
116 /// Value or \ref INF.
117 virtual Value _getRowUpperBound(int i) const;
120 virtual void _setObjCoeffs(ExprIterator b, ExprIterator e);
122 virtual void _getObjCoeffs(InsertIterator b) const;
125 virtual void _setObjCoeff(int i, Value obj_coef);
127 virtual Value _getObjCoeff(int i) const;
130 virtual void _setSense(Sense);
132 virtual Sense _getSense() const;
135 virtual void _clear();
139 /// \brief Interface for a skeleton LP solver
141 /// This class implements an interface for a skeleton LP solver.
143 class LpSkeleton : public SkeletonSolverBase, public LpSolver {
145 LpSkeleton() : SkeletonSolverBase(), LpSolver() {}
150 virtual SolveExitStatus _solve();
153 virtual Value _getPrimal(int i) const;
155 virtual Value _getDual(int i) const;
158 virtual Value _getPrimalValue() const;
161 virtual Value _getPrimalRay(int i) const;
163 virtual Value _getDualRay(int i) const;
166 virtual ProblemType _getPrimalType() const;
168 virtual ProblemType _getDualType() const;
171 virtual VarStatus _getColStatus(int i) const;
173 virtual VarStatus _getRowStatus(int i) const;
176 virtual LpSkeleton* _newSolver() const;
178 virtual LpSkeleton* _cloneSolver() const;
180 virtual const char* _solverName() const;
184 /// \brief Interface for a skeleton MIP solver
186 /// This class implements an interface for a skeleton MIP solver.
188 class MipSkeleton : public SkeletonSolverBase, public MipSolver {
190 MipSkeleton() : SkeletonSolverBase(), MipSolver() {}
195 ///\bug Wrong interface
197 virtual SolveExitStatus _solve();
201 ///\bug Wrong interface
203 virtual Value _getSol(int i) const;
207 ///\bug Wrong interface
209 virtual Value _getSolValue() const;
213 ///\bug Wrong interface
215 virtual ProblemType _getType() const;
218 virtual MipSkeleton* _newSolver() const;
221 virtual MipSkeleton* _cloneSolver() const;
223 virtual const char* _solverName() const;
229 #endif // LEMON_LP_SKELETON