Add soplex support to scripts/bootstrap.sh plus...
it checks whether cbc and soplex are installed at the given prefix.
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
23 ///\brief Header of the LEMON-GLPK lp solver interface.
26 #include <lemon/lp_base.h>
28 // forward declaration
29 #if !defined _GLP_PROB && !defined GLP_PROB
32 typedef struct { double _opaque_prob; } glp_prob;
33 /* LP/MIP problem object */
39 /// \brief Base interface for the GLPK LP and MIP solver
41 /// This class implements the common interface of the GLPK LP and MIP solver.
43 class GlpkBase : virtual public LpBase {
50 GlpkBase(const GlpkBase&);
55 virtual int _addCol();
56 virtual int _addRow();
57 virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
59 virtual void _eraseCol(int i);
60 virtual void _eraseRow(int i);
62 virtual void _eraseColId(int i);
63 virtual void _eraseRowId(int i);
65 virtual void _getColName(int col, std::string& name) const;
66 virtual void _setColName(int col, const std::string& name);
67 virtual int _colByName(const std::string& name) const;
69 virtual void _getRowName(int row, std::string& name) const;
70 virtual void _setRowName(int row, const std::string& name);
71 virtual int _rowByName(const std::string& name) const;
73 virtual void _setRowCoeffs(int i, ExprIterator b, ExprIterator e);
74 virtual void _getRowCoeffs(int i, InsertIterator b) const;
76 virtual void _setColCoeffs(int i, ExprIterator b, ExprIterator e);
77 virtual void _getColCoeffs(int i, InsertIterator b) const;
79 virtual void _setCoeff(int row, int col, Value value);
80 virtual Value _getCoeff(int row, int col) const;
82 virtual void _setColLowerBound(int i, Value value);
83 virtual Value _getColLowerBound(int i) const;
85 virtual void _setColUpperBound(int i, Value value);
86 virtual Value _getColUpperBound(int i) const;
88 virtual void _setRowLowerBound(int i, Value value);
89 virtual Value _getRowLowerBound(int i) const;
91 virtual void _setRowUpperBound(int i, Value value);
92 virtual Value _getRowUpperBound(int i) const;
94 virtual void _setObjCoeffs(ExprIterator b, ExprIterator e);
95 virtual void _getObjCoeffs(InsertIterator b) const;
97 virtual void _setObjCoeff(int i, Value obj_coef);
98 virtual Value _getObjCoeff(int i) const;
100 virtual void _setSense(Sense);
101 virtual Sense _getSense() const;
103 virtual void _clear();
105 virtual void _messageLevel(MessageLevel level);
109 static void freeEnv();
111 struct FreeEnvHelper {
117 static FreeEnvHelper freeEnvHelper;
125 ///Pointer to the underlying GLPK data structure.
126 LPX *lpx() {return lp;}
127 ///Const pointer to the underlying GLPK data structure.
128 const LPX *lpx() const {return lp;}
130 ///Returns the constraint identifier understood by GLPK.
131 int lpxRow(Row r) const { return rows(id(r)); }
133 ///Returns the variable identifier understood by GLPK.
134 int lpxCol(Col c) const { return cols(id(c)); }
138 /// \brief Interface for the GLPK LP solver
140 /// This class implements an interface for the GLPK LP solver.
142 class GlpkLp : public LpSolver, public GlpkBase {
148 GlpkLp(const GlpkLp&);
151 virtual GlpkLp* cloneSolver() const;
153 virtual GlpkLp* newSolver() const;
157 mutable std::vector<double> _primal_ray;
158 mutable std::vector<double> _dual_ray;
160 void _clear_temporals();
164 virtual const char* _solverName() const;
166 virtual SolveExitStatus _solve();
167 virtual Value _getPrimal(int i) const;
168 virtual Value _getDual(int i) const;
170 virtual Value _getPrimalValue() const;
172 virtual VarStatus _getColStatus(int i) const;
173 virtual VarStatus _getRowStatus(int i) const;
175 virtual Value _getPrimalRay(int i) const;
176 virtual Value _getDualRay(int i) const;
178 virtual ProblemType _getPrimalType() const;
179 virtual ProblemType _getDualType() const;
183 ///Solve with primal simplex
184 SolveExitStatus solvePrimal();
186 ///Solve with dual simplex
187 SolveExitStatus solveDual();
195 ///Turns on or off the presolver
197 ///Turns on (\c b is \c true) or off (\c b is \c false) the presolver
199 ///The presolver is off by default.
200 void presolver(bool presolve);
204 /// \brief Interface for the GLPK MIP solver
206 /// This class implements an interface for the GLPK MIP solver.
208 class GlpkMip : public MipSolver, public GlpkBase {
214 GlpkMip(const GlpkMip&);
216 virtual GlpkMip* cloneSolver() const;
217 virtual GlpkMip* newSolver() const;
221 virtual const char* _solverName() const;
223 virtual ColTypes _getColType(int col) const;
224 virtual void _setColType(int col, ColTypes col_type);
226 virtual SolveExitStatus _solve();
227 virtual ProblemType _getType() const;
228 virtual Value _getSol(int i) const;
229 virtual Value _getSolValue() const;
234 } //END OF NAMESPACE LEMON
236 #endif //LEMON_GLPK_H