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