COIN-OR::LEMON - Graph Library

source: lemon/lemon/lp_skeleton.h @ 1126:a30455cd0107

1.1 r1.1.4
Last change on this file since 1126:a30455cd0107 was 1081:f1398882a928, checked in by Alpar Juttner <alpar@…>, 13 years ago

Unify sources

File size: 6.3 KB
RevLine 
[481]1/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 *
3 * This file is a part of LEMON, a generic C++ optimization library.
4 *
[1081]5 * Copyright (C) 2003-2011
[481]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
[576]19#ifndef LEMON_LP_SKELETON_H
20#define LEMON_LP_SKELETON_H
[481]21
22#include <lemon/lp_base.h>
23
24///\file
[587]25///\brief Skeleton file to implement LP/MIP solver interfaces
[1081]26///
[587]27///The classes in this file do nothing, but they can serve as skeletons when
28///implementing an interface to new solvers.
[481]29namespace lemon {
30
[587]31  ///A skeleton class to implement LP/MIP solver base interface
[1081]32
[587]33  ///This class does nothing, but it can serve as a skeleton when
34  ///implementing an interface to new solvers.
[482]35  class SkeletonSolverBase : public virtual LpBase {
[481]36    int col_num,row_num;
37
38  protected:
39
[482]40    SkeletonSolverBase()
41      : col_num(-1), row_num(-1) {}
42
[481]43    /// \e
44    virtual int _addCol();
45    /// \e
46    virtual int _addRow();
47    /// \e
48    virtual void _eraseCol(int i);
49    /// \e
50    virtual void _eraseRow(int i);
[482]51
[481]52    /// \e
[482]53    virtual void _getColName(int col, std::string& name) const;
[481]54    /// \e
[482]55    virtual void _setColName(int col, const std::string& name);
[481]56    /// \e
57    virtual int _colByName(const std::string& name) const;
58
59    /// \e
[482]60    virtual void _getRowName(int row, std::string& name) const;
[481]61    /// \e
[482]62    virtual void _setRowName(int row, const std::string& name);
[481]63    /// \e
[482]64    virtual int _rowByName(const std::string& name) const;
65
[481]66    /// \e
[482]67    virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
68    /// \e
69    virtual void _getRowCoeffs(int i, InsertIterator b) const;
70    /// \e
71    virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
72    /// \e
73    virtual void _getColCoeffs(int i, InsertIterator b) const;
[481]74
75    /// Set one element of the coefficient matrix
76    virtual void _setCoeff(int row, int col, Value value);
77
78    /// Get one element of the coefficient matrix
79    virtual Value _getCoeff(int row, int col) const;
80
81    /// The lower bound of a variable (column) have to be given by an
82    /// extended number of type Value, i.e. a finite number of type
83    /// Value or -\ref INF.
84    virtual void _setColLowerBound(int i, Value value);
85    /// \e
86
87    /// The lower bound of a variable (column) is an
88    /// extended number of type Value, i.e. a finite number of type
89    /// Value or -\ref INF.
90    virtual Value _getColLowerBound(int i) const;
91
92    /// The upper bound of a variable (column) have to be given by an
93    /// extended number of type Value, i.e. a finite number of type
94    /// Value or \ref INF.
95    virtual void _setColUpperBound(int i, Value value);
96    /// \e
97
98    /// The upper bound of a variable (column) is an
99    /// extended number of type Value, i.e. a finite number of type
100    /// Value or \ref INF.
101    virtual Value _getColUpperBound(int i) const;
102
[482]103    /// The lower bound of a constraint (row) have to be given by an
[481]104    /// extended number of type Value, i.e. a finite number of type
[482]105    /// Value or -\ref INF.
106    virtual void _setRowLowerBound(int i, Value value);
[481]107    /// \e
108
[482]109    /// The lower bound of a constraint (row) is an
110    /// extended number of type Value, i.e. a finite number of type
111    /// Value or -\ref INF.
112    virtual Value _getRowLowerBound(int i) const;
[481]113
[482]114    /// The upper bound of a constraint (row) have to be given by an
115    /// extended number of type Value, i.e. a finite number of type
116    /// Value or \ref INF.
117    virtual void _setRowUpperBound(int i, Value value);
[481]118    /// \e
119
[482]120    /// The upper bound of a constraint (row) is an
121    /// extended number of type Value, i.e. a finite number of type
122    /// Value or \ref INF.
123    virtual Value _getRowUpperBound(int i) const;
[481]124
125    /// \e
[482]126    virtual void _setObjCoeffs(ExprIterator b, ExprIterator e);
127    /// \e
128    virtual void _getObjCoeffs(InsertIterator b) const;
129
[481]130    /// \e
131    virtual void _setObjCoeff(int i, Value obj_coef);
132    /// \e
133    virtual Value _getObjCoeff(int i) const;
134
135    ///\e
[482]136    virtual void _setSense(Sense);
137    ///\e
138    virtual Sense _getSense() const;
139
140    ///\e
141    virtual void _clear();
142
[623]143    ///\e
144    virtual void _messageLevel(MessageLevel);
[482]145  };
146
[587]147  /// \brief Skeleton class for an LP solver interface
[482]148  ///
[587]149  ///This class does nothing, but it can serve as a skeleton when
150  ///implementing an interface to new solvers.
151
[482]152  ///\ingroup lp_group
[587]153  class LpSkeleton : public LpSolver, public SkeletonSolverBase {
[482]154  public:
[587]155    ///\e
156    LpSkeleton() : LpSolver(), SkeletonSolverBase() {}
157    ///\e
158    virtual LpSkeleton* newSolver() const;
159    ///\e
160    virtual LpSkeleton* cloneSolver() const;
[482]161  protected:
162
163    ///\e
164    virtual SolveExitStatus _solve();
165
166    ///\e
167    virtual Value _getPrimal(int i) const;
168    ///\e
169    virtual Value _getDual(int i) const;
170
171    ///\e
172    virtual Value _getPrimalValue() const;
173
174    ///\e
175    virtual Value _getPrimalRay(int i) const;
176    ///\e
177    virtual Value _getDualRay(int i) const;
178
179    ///\e
180    virtual ProblemType _getPrimalType() const;
181    ///\e
182    virtual ProblemType _getDualType() const;
183
184    ///\e
185    virtual VarStatus _getColStatus(int i) const;
186    ///\e
187    virtual VarStatus _getRowStatus(int i) const;
188
189    ///\e
190    virtual const char* _solverName() const;
191
192  };
193
[587]194  /// \brief Skeleton class for a MIP solver interface
[482]195  ///
[587]196  ///This class does nothing, but it can serve as a skeleton when
197  ///implementing an interface to new solvers.
[482]198  ///\ingroup lp_group
[587]199  class MipSkeleton : public MipSolver, public SkeletonSolverBase {
[482]200  public:
[587]201    ///\e
202    MipSkeleton() : MipSolver(), SkeletonSolverBase() {}
203    ///\e
204    virtual MipSkeleton* newSolver() const;
205    ///\e
206    virtual MipSkeleton* cloneSolver() const;
[482]207
208  protected:
209    ///\e
[481]210    virtual SolveExitStatus _solve();
211
212    ///\e
[482]213    virtual Value _getSol(int i) const;
[481]214
215    ///\e
[482]216    virtual Value _getSolValue() const;
[481]217
218    ///\e
[482]219    virtual ProblemType _getType() const;
[481]220
221    ///\e
[482]222    virtual const char* _solverName() const;
[481]223  };
224
225} //namespace lemon
226
[576]227#endif
Note: See TracBrowser for help on using the repository browser.