athos@1261
|
1 |
/* -*- C++ -*-
|
athos@1261
|
2 |
*
|
alpar@1956
|
3 |
* This file is a part of LEMON, a generic C++ optimization library
|
alpar@1956
|
4 |
*
|
alpar@1956
|
5 |
* Copyright (C) 2003-2006
|
alpar@1956
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
alpar@1359
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
athos@1261
|
8 |
*
|
athos@1261
|
9 |
* Permission to use, modify and distribute this software is granted
|
athos@1261
|
10 |
* provided that this copyright notice appears in all copies. For
|
athos@1261
|
11 |
* precise terms see the accompanying LICENSE file.
|
athos@1261
|
12 |
*
|
athos@1261
|
13 |
* This software is provided "AS IS" with no warranty of any kind,
|
athos@1261
|
14 |
* express or implied, and with no claim as to its suitability for any
|
athos@1261
|
15 |
* purpose.
|
athos@1261
|
16 |
*
|
athos@1261
|
17 |
*/
|
athos@1261
|
18 |
|
athos@1261
|
19 |
#ifndef LEMON_LP_GLPK_H
|
athos@1261
|
20 |
#define LEMON_LP_GLPK_H
|
athos@1261
|
21 |
|
athos@1261
|
22 |
///\file
|
athos@1261
|
23 |
///\brief Header of the LEMON-GLPK lp solver interface.
|
alpar@1328
|
24 |
///\ingroup gen_opt_group
|
athos@1261
|
25 |
|
ladanyi@1356
|
26 |
#include <lemon/lp_base.h>
|
athos@1261
|
27 |
extern "C" {
|
alpar@1326
|
28 |
#include <glpk.h>
|
athos@1261
|
29 |
}
|
athos@1261
|
30 |
|
athos@1261
|
31 |
namespace lemon {
|
athos@1261
|
32 |
|
athos@1261
|
33 |
|
alpar@1398
|
34 |
/// \brief Interface for the GLPK LP solver
|
athos@1261
|
35 |
///
|
alpar@1398
|
36 |
/// This class implements an interface for the GLPK LP solver.
|
alpar@1328
|
37 |
///\ingroup gen_opt_group
|
athos@2144
|
38 |
class LpGlpk : virtual public LpSolverBase {
|
alpar@1321
|
39 |
protected:
|
alpar@1321
|
40 |
LPX* lp;
|
alpar@1321
|
41 |
|
athos@1261
|
42 |
public:
|
alpar@1321
|
43 |
|
athos@1261
|
44 |
typedef LpSolverBase Parent;
|
athos@1261
|
45 |
|
alpar@1321
|
46 |
LpGlpk();
|
alpar@2321
|
47 |
LpGlpk(const LpGlpk &);
|
alpar@1321
|
48 |
~LpGlpk();
|
alpar@1321
|
49 |
|
athos@1261
|
50 |
protected:
|
alpar@1364
|
51 |
virtual LpSolverBase &_newLp();
|
alpar@1364
|
52 |
virtual LpSolverBase &_copyLp();
|
alpar@1364
|
53 |
|
athos@1261
|
54 |
virtual int _addCol();
|
athos@1261
|
55 |
virtual int _addRow();
|
athos@1432
|
56 |
virtual void _eraseCol(int i);
|
athos@1432
|
57 |
virtual void _eraseRow(int i);
|
alpar@1895
|
58 |
virtual void _getColName(int col, std::string & name);
|
alpar@1895
|
59 |
virtual void _setColName(int col, const std::string & name);
|
deba@2312
|
60 |
virtual void _setRowCoeffs(int i, LpRowIterator b, LpRowIterator e);
|
deba@2312
|
61 |
virtual void _setColCoeffs(int i, LpColIterator b, LpColIterator e);
|
athos@1431
|
62 |
virtual void _setCoeff(int row, int col, Value value);
|
athos@2324
|
63 |
virtual Value _getCoeff(int row, int col);
|
athos@2324
|
64 |
|
athos@1261
|
65 |
virtual void _setColLowerBound(int i, Value value);
|
athos@1261
|
66 |
virtual void _setColUpperBound(int i, Value value);
|
athos@1405
|
67 |
// virtual void _setRowLowerBound(int i, Value value);
|
athos@1405
|
68 |
// virtual void _setRowUpperBound(int i, Value value);
|
athos@1379
|
69 |
virtual void _setRowBounds(int i, Value lower, Value upper);
|
athos@1261
|
70 |
virtual void _setObjCoeff(int i, Value obj_coef);
|
athos@2324
|
71 |
virtual Value _getObjCoeff(int i);
|
athos@1377
|
72 |
virtual void _clearObj();
|
athos@1377
|
73 |
// virtual void _setObj(int length,
|
athos@1377
|
74 |
// int const * indices,
|
athos@1377
|
75 |
// Value const * values ) = 0;
|
athos@1376
|
76 |
|
alpar@1263
|
77 |
///\e
|
alpar@1263
|
78 |
|
alpar@1321
|
79 |
///\todo It should be clarified
|
alpar@1263
|
80 |
///
|
alpar@1303
|
81 |
virtual SolveExitStatus _solve();
|
alpar@1293
|
82 |
virtual Value _getPrimal(int i);
|
marci@1787
|
83 |
virtual Value _getDual(int i);
|
alpar@1312
|
84 |
virtual Value _getPrimalValue();
|
marci@1840
|
85 |
virtual bool _isBasicCol(int i);
|
alpar@1312
|
86 |
///\e
|
alpar@1312
|
87 |
|
alpar@1321
|
88 |
///\todo It should be clarified
|
alpar@1312
|
89 |
///
|
alpar@1312
|
90 |
virtual SolutionStatus _getPrimalStatus();
|
athos@1460
|
91 |
virtual SolutionStatus _getDualStatus();
|
athos@1460
|
92 |
virtual ProblemTypes _getProblemType();
|
athos@1460
|
93 |
|
alpar@1321
|
94 |
virtual void _setMax();
|
alpar@1321
|
95 |
virtual void _setMin();
|
athos@1261
|
96 |
|
athos@2324
|
97 |
virtual bool _isMax();
|
athos@2324
|
98 |
|
alpar@1321
|
99 |
public:
|
alpar@1321
|
100 |
///Set the verbosity of the messages
|
alpar@1321
|
101 |
|
alpar@1326
|
102 |
///Set the verbosity of the messages
|
alpar@1326
|
103 |
///
|
alpar@1321
|
104 |
///\param m is the level of the messages output by the solver routines.
|
alpar@1321
|
105 |
///The possible values are:
|
alpar@1321
|
106 |
///- 0 --- no output (default value)
|
alpar@1321
|
107 |
///- 1 --- error messages only
|
alpar@1321
|
108 |
///- 2 --- normal output
|
alpar@1321
|
109 |
///- 3 --- full output (includes informational messages)
|
alpar@1321
|
110 |
void messageLevel(int m);
|
alpar@1326
|
111 |
///Turns on or off the presolver
|
alpar@1326
|
112 |
|
alpar@1326
|
113 |
///Turns on (\c b is \c true) or off (\c b is \c false) the presolver
|
alpar@1326
|
114 |
///
|
alpar@1326
|
115 |
///The presolver is off by default.
|
alpar@1326
|
116 |
void presolver(bool b);
|
alpar@2321
|
117 |
|
alpar@2321
|
118 |
LPX *lpx() {return lp;}
|
athos@1261
|
119 |
};
|
athos@1261
|
120 |
} //END OF NAMESPACE LEMON
|
athos@1261
|
121 |
|
athos@1261
|
122 |
#endif //LEMON_LP_GLPK_H
|
athos@1261
|
123 |
|