diff -r 9863b5d51beb -r bc3a4c498eb2 src/lemon/lp_glpk.cc --- a/src/lemon/lp_glpk.cc Fri Apr 08 05:36:16 2005 +0000 +++ b/src/lemon/lp_glpk.cc Fri Apr 08 06:33:11 2005 +0000 @@ -24,169 +24,178 @@ namespace lemon { - /// \e - int LpGlpk::_addCol() { - int i=lpx_add_cols(lp, 1); - _setColLowerBound(i, -INF); - _setColUpperBound(i, INF); - return i; + LpGlpk::LpGlpk() : Parent(), + lp(lpx_create_prob()) { + ///\todo constrol function for this: + lpx_set_int_parm(lp, LPX_K_DUAL, 1); + messageLevel(0); + } + + LpGlpk::~LpGlpk() { + lpx_delete_prob(lp); + } + + int LpGlpk::_addCol() { + int i=lpx_add_cols(lp, 1); + _setColLowerBound(i, -INF); + _setColUpperBound(i, INF); + return i; + } + + int LpGlpk::_addRow() { + int i=lpx_add_rows(lp, 1); + return i; + } + + + void LpGlpk::_setRowCoeffs(int i, + int length, + const int * indices, + const Value * values ) + { + lpx_set_mat_row(lp, i, length, + const_cast(indices) , + const_cast(values)); + } + + void LpGlpk::_setColCoeffs(int i, + int length, + const int * indices, + const Value * values) + { + lpx_set_mat_col(lp, i, length, + const_cast(indices), + const_cast(values)); + } + + void LpGlpk::_setColLowerBound(int i, Value lo) + { + if (lo==INF) { + //FIXME error + } + int b=lpx_get_col_type(lp, i); + double up=lpx_get_col_ub(lp, i); + if (lo==-INF) { + switch (b) { + case LPX_FR: + case LPX_LO: + lpx_set_col_bnds(lp, i, LPX_FR, lo, up); + break; + case LPX_UP: + break; + case LPX_DB: + case LPX_FX: + lpx_set_col_bnds(lp, i, LPX_UP, lo, up); + break; + default: ; + //FIXME error + } + } else { + switch (b) { + case LPX_FR: + case LPX_LO: + lpx_set_col_bnds(lp, i, LPX_LO, lo, up); + break; + case LPX_UP: + case LPX_DB: + case LPX_FX: + if (lo==up) + lpx_set_col_bnds(lp, i, LPX_FX, lo, up); + else + lpx_set_col_bnds(lp, i, LPX_DB, lo, up); + break; + default: ; + //FIXME error + } } - /// \e - int LpGlpk::_addRow() { - int i=lpx_add_rows(lp, 1); - return i; + } + + void LpGlpk::_setColUpperBound(int i, Value up) + { + if (up==-INF) { + //FIXME error } - - - void LpGlpk::_setRowCoeffs(int i, - int length, - const int * indices, - const Value * values ) - { - lpx_set_mat_row(lp, i, length, - const_cast(indices) , - const_cast(values)); - } - - void LpGlpk::_setColCoeffs(int i, - int length, - const int * indices, - const Value * values) - { - lpx_set_mat_col(lp, i, length, - const_cast(indices), - const_cast(values)); - } - - void LpGlpk::_setColLowerBound(int i, Value lo) - { - if (lo==INF) { + int b=lpx_get_col_type(lp, i); + double lo=lpx_get_col_lb(lp, i); + if (up==INF) { + switch (b) { + case LPX_FR: + case LPX_LO: + break; + case LPX_UP: + lpx_set_col_bnds(lp, i, LPX_FR, lo, up); + break; + case LPX_DB: + case LPX_FX: + lpx_set_col_bnds(lp, i, LPX_LO, lo, up); + break; + default: ; //FIXME error } - int b=lpx_get_col_type(lp, i); - double up=lpx_get_col_ub(lp, i); - if (lo==-INF) { - switch (b) { - case LPX_FR: - case LPX_LO: - lpx_set_col_bnds(lp, i, LPX_FR, lo, up); - break; - case LPX_UP: - break; - case LPX_DB: - case LPX_FX: - lpx_set_col_bnds(lp, i, LPX_UP, lo, up); - break; - default: ; - //FIXME error - } - } else { - switch (b) { - case LPX_FR: - case LPX_LO: - lpx_set_col_bnds(lp, i, LPX_LO, lo, up); - break; - case LPX_UP: - case LPX_DB: - case LPX_FX: - if (lo==up) - lpx_set_col_bnds(lp, i, LPX_FX, lo, up); - else - lpx_set_col_bnds(lp, i, LPX_DB, lo, up); - break; - default: ; - //FIXME error - } - } - - } - - void LpGlpk::_setColUpperBound(int i, Value up) - { - if (up==-INF) { + } else { + switch (b) { + case LPX_FR: + lpx_set_col_bnds(lp, i, LPX_UP, lo, up); + break; + case LPX_UP: + lpx_set_col_bnds(lp, i, LPX_UP, lo, up); + break; + case LPX_LO: + case LPX_DB: + case LPX_FX: + if (lo==up) + lpx_set_col_bnds(lp, i, LPX_FX, lo, up); + else + lpx_set_col_bnds(lp, i, LPX_DB, lo, up); + break; + default: ; //FIXME error } - int b=lpx_get_col_type(lp, i); - double lo=lpx_get_col_lb(lp, i); - if (up==INF) { - switch (b) { - case LPX_FR: - case LPX_LO: - break; - case LPX_UP: - lpx_set_col_bnds(lp, i, LPX_FR, lo, up); - break; - case LPX_DB: - case LPX_FX: - lpx_set_col_bnds(lp, i, LPX_LO, lo, up); - break; - default: ; - //FIXME error - } - } else { - switch (b) { - case LPX_FR: - lpx_set_col_bnds(lp, i, LPX_UP, lo, up); - break; - case LPX_UP: - lpx_set_col_bnds(lp, i, LPX_UP, lo, up); - break; - case LPX_LO: - case LPX_DB: - case LPX_FX: - if (lo==up) - lpx_set_col_bnds(lp, i, LPX_FX, lo, up); - else - lpx_set_col_bnds(lp, i, LPX_DB, lo, up); - break; - default: ; - //FIXME error - } + } + } + + void LpGlpk::_setRowLowerBound(int i, Value lo) + { + if (lo==INF) { + //FIXME error + } + int b=lpx_get_row_type(lp, i); + double up=lpx_get_row_ub(lp, i); + if (lo==-INF) { + switch (b) { + case LPX_FR: + case LPX_LO: + lpx_set_row_bnds(lp, i, LPX_FR, lo, up); + break; + case LPX_UP: + break; + case LPX_DB: + case LPX_FX: + lpx_set_row_bnds(lp, i, LPX_UP, lo, up); + break; + default: ; + //FIXME error + } + } else { + switch (b) { + case LPX_FR: + case LPX_LO: + lpx_set_row_bnds(lp, i, LPX_LO, lo, up); + break; + case LPX_UP: + case LPX_DB: + case LPX_FX: + if (lo==up) + lpx_set_row_bnds(lp, i, LPX_FX, lo, up); + else + lpx_set_row_bnds(lp, i, LPX_DB, lo, up); + break; + default: ; + //FIXME error } } - - void LpGlpk::_setRowLowerBound(int i, Value lo) - { - if (lo==INF) { - //FIXME error - } - int b=lpx_get_row_type(lp, i); - double up=lpx_get_row_ub(lp, i); - if (lo==-INF) { - switch (b) { - case LPX_FR: - case LPX_LO: - lpx_set_row_bnds(lp, i, LPX_FR, lo, up); - break; - case LPX_UP: - break; - case LPX_DB: - case LPX_FX: - lpx_set_row_bnds(lp, i, LPX_UP, lo, up); - break; - default: ; - //FIXME error - } - } else { - switch (b) { - case LPX_FR: - case LPX_LO: - lpx_set_row_bnds(lp, i, LPX_LO, lo, up); - break; - case LPX_UP: - case LPX_DB: - case LPX_FX: - if (lo==up) - lpx_set_row_bnds(lp, i, LPX_FX, lo, up); - else - lpx_set_row_bnds(lp, i, LPX_DB, lo, up); - break; - default: ; - //FIXME error - } - } - } + } void LpGlpk::_setRowUpperBound(int i, Value up) { @@ -290,12 +299,19 @@ void LpGlpk::_setMax() { - lpx_set_obj_dir(lp, LPX_MAX); - } + lpx_set_obj_dir(lp, LPX_MAX); + } + void LpGlpk::_setMin() { - lpx_set_obj_dir(lp, LPX_MIN); - } + lpx_set_obj_dir(lp, LPX_MIN); + } + + + void LpGlpk::messageLevel(int m) + { + lpx_set_int_parm(lp, LPX_K_MSGLEV, m); + } } //END OF NAMESPACE LEMON