diff -r 751a14b992f2 -r bfbdded3763a lemon/lp_glpk.cc --- a/lemon/lp_glpk.cc Fri Feb 16 15:57:48 2007 +0000 +++ b/lemon/lp_glpk.cc Fri Feb 16 19:11:31 2007 +0000 @@ -37,6 +37,7 @@ rows = _lp_bits::LpId(1); cols = _lp_bits::LpId(1); lp = lpx_create_prob(); + lpx_create_index(lp); ///\todo control function for this: lpx_set_int_parm(lp, LPX_K_DUAL, 1); messageLevel(0); @@ -112,7 +113,7 @@ lpx_del_rows(lp, 1, rows); } - void LpGlpk::_getColName(int col, std::string & name) + void LpGlpk::_getColName(int col, std::string & name) const { char *n = lpx_get_col_name(lp,col); @@ -125,6 +126,13 @@ lpx_set_col_name(lp,col,const_cast(name.c_str())); } + + int LpGlpk::_colByName(const std::string& name) const + { + int k = lpx_find_col(lp, const_cast(name.c_str())); + return k > 0 ? k : -1; + } + void LpGlpk::_setRowCoeffs(int i, ConstRowIterator b, ConstRowIterator e) { @@ -142,7 +150,7 @@ lpx_set_mat_row(lp, i, values.size() - 1, &indices[0], &values[0]); } - void LpGlpk::_getRowCoeffs(int i, RowIterator b) + void LpGlpk::_getRowCoeffs(int i, RowIterator b) const { int length = lpx_get_mat_row(lp, i, 0, 0); @@ -173,7 +181,7 @@ lpx_set_mat_col(lp, i, values.size() - 1, &indices[0], &values[0]); } - void LpGlpk::_getColCoeffs(int i, ColIterator b) + void LpGlpk::_getColCoeffs(int i, ColIterator b) const { int length = lpx_get_mat_col(lp, i, 0, 0); @@ -247,7 +255,7 @@ } } - LpGlpk::Value LpGlpk::_getCoeff(int row, int col) + LpGlpk::Value LpGlpk::_getCoeff(int row, int col) const { int length=lpx_get_mat_row(lp, row, 0, 0); @@ -312,7 +320,7 @@ } - LpGlpk::Value LpGlpk::_getColLowerBound(int i) + LpGlpk::Value LpGlpk::_getColLowerBound(int i) const { int b=lpx_get_col_type(lp, i); switch (b) { @@ -369,7 +377,7 @@ } } - LpGlpk::Value LpGlpk::_getColUpperBound(int i) + LpGlpk::Value LpGlpk::_getColUpperBound(int i) const { int b=lpx_get_col_type(lp, i); switch (b) { @@ -414,7 +422,7 @@ } - void LpGlpk::_getRowBounds(int i, Value &lb, Value &ub) + void LpGlpk::_getRowBounds(int i, Value &lb, Value &ub) const { int b=lpx_get_row_type(lp, i); @@ -444,7 +452,7 @@ lpx_set_obj_coef(lp, i, obj_coef); } - LpGlpk::Value LpGlpk::_getObjCoeff(int i){ + LpGlpk::Value LpGlpk::_getObjCoeff(int i) const { //i=0 means the constant term (shift) return lpx_get_obj_coef(lp, i); } @@ -472,26 +480,27 @@ } } - LpGlpk::Value LpGlpk::_getPrimal(int i) + LpGlpk::Value LpGlpk::_getPrimal(int i) const { return lpx_get_col_prim(lp,i); } - LpGlpk::Value LpGlpk::_getDual(int i) + LpGlpk::Value LpGlpk::_getDual(int i) const { return lpx_get_row_dual(lp,i); } - LpGlpk::Value LpGlpk::_getPrimalValue() + LpGlpk::Value LpGlpk::_getPrimalValue() const { return lpx_get_obj_val(lp); } - bool LpGlpk::_isBasicCol(int i) { + bool LpGlpk::_isBasicCol(int i) const + { return (lpx_get_col_stat(lp, i)==LPX_BS); } - LpGlpk::SolutionStatus LpGlpk::_getPrimalStatus() + LpGlpk::SolutionStatus LpGlpk::_getPrimalStatus() const { int stat= lpx_get_status(lp); switch (stat) { @@ -512,11 +521,8 @@ } } - LpGlpk::SolutionStatus LpGlpk::_getDualStatus() + LpGlpk::SolutionStatus LpGlpk::_getDualStatus() const { -// std::cout<<"Itt megy: "<