2 * src/lemon/lp_glpk.cc - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Combinatorial Optimization Research Group, EGRES).
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
17 #ifndef LEMON_LP_GLPK_CC
18 #define LEMON_LP_GLPK_CC
21 ///\brief Implementation of the LEMON-GLPK lp solver interface.
28 int LpGlpk::_addCol() {
29 int i=lpx_add_cols(lp, 1);
30 _setColLowerBound(i, -INF);
31 _setColUpperBound(i, INF);
36 int LpGlpk::_addRow() {
37 int i=lpx_add_rows(lp, 1);
42 void LpGlpk::_setRowCoeffs(int i,
47 lpx_set_mat_row(lp, i, length, indices, values);
50 void LpGlpk::_setColCoeffs(int i,
55 lpx_set_mat_col(lp, i, length, indices, values);
58 void LpGlpk::_setColLowerBound(int i, Value lo)
63 int b=lpx_get_col_type(lp, i);
64 double up=lpx_get_col_ub(lp, i);
69 lpx_set_col_bnds(lp, i, LPX_FR, lo, up);
75 lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
84 lpx_set_col_bnds(lp, i, LPX_LO, lo, up);
90 lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
92 lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
101 void LpGlpk::_setColUpperBound(int i, Value up)
106 int b=lpx_get_col_type(lp, i);
107 double lo=lpx_get_col_lb(lp, i);
114 lpx_set_col_bnds(lp, i, LPX_FR, lo, up);
118 lpx_set_col_bnds(lp, i, LPX_LO, lo, up);
126 lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
129 lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
135 lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
137 lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
145 void LpGlpk::_setRowLowerBound(int i, Value lo)
150 int b=lpx_get_row_type(lp, i);
151 double up=lpx_get_row_ub(lp, i);
156 lpx_set_row_bnds(lp, i, LPX_FR, lo, up);
162 lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
171 lpx_set_row_bnds(lp, i, LPX_LO, lo, up);
177 lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
179 lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
187 void LpGlpk::_setRowUpperBound(int i, Value up)
192 int b=lpx_get_row_type(lp, i);
193 double lo=lpx_get_row_lb(lp, i);
200 lpx_set_row_bnds(lp, i, LPX_FR, lo, up);
204 lpx_set_row_bnds(lp, i, LPX_LO, lo, up);
212 lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
215 lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
221 lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
223 lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
231 void LpGlpk::_setObjCoeff(int i, Value obj_coef)
233 lpx_set_obj_coef(lp, i, obj_coef);
236 } //END OF NAMESPACE LEMON
238 #endif //LEMON_LP_GLPK_CC