COIN-OR::LEMON - Graph Library

Changeset 2441:d8d6ab871608 in lemon-0.x for lemon/lp_glpk.cc


Ignore:
Timestamp:
05/07/07 20:19:55 (17 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3278
Message:

Conformity to new GLPK interface
Hacking Mip without integer variables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/lp_glpk.cc

    r2391 r2441  
    2222#include <lemon/lp_glpk.h>
    2323//#include <iostream>
     24
     25#if GLP_MAJOR_VERSION > 4 || (GLP_MAJOR_VERSION == 4 && GLP_MINOR_VERSION > 15)
     26#define LEMON_glp(func) (glp_##func)
     27#define LEMON_lpx(func) (lpx_##func)
     28
     29#define LEMON_GLP(def) (GLP_##def)
     30#define LEMON_LPX(def) (LPX_##def)
     31
     32#else
     33
     34#define LEMON_glp(func) (lpx_##func)
     35#define LEMON_lpx(func) (lpx_##func)
     36
     37#define LEMON_GLP(def) (LPX_##def)
     38#define LEMON_LPX(def) (LPX_##def)
     39
     40#endif
     41
    2442namespace lemon {
    2543
    26 
    2744  LpGlpk::LpGlpk() : Parent() {
     45    solved = false;
    2846    rows = _lp_bits::LpId(1);
    2947    cols = _lp_bits::LpId(1);
    30     lp = lpx_create_prob();
    31     lpx_create_index(lp);
    32     ///\todo control function for this:
    33     lpx_set_int_parm(lp, LPX_K_DUAL, 1);
     48    lp = LEMON_glp(create_prob)();
     49    LEMON_glp(create_index)(lp);
     50    LEMON_lpx(set_int_parm)(lp, LEMON_LPX(K_DUAL), 1);
    3451    messageLevel(0);
    3552  }
    3653 
    3754  LpGlpk::LpGlpk(const LpGlpk &glp) : Parent() {
     55    solved = false;
    3856    rows = _lp_bits::LpId(1);
    3957    cols = _lp_bits::LpId(1);
    40     lp = lpx_create_prob();
    41     lpx_create_index(lp);
     58    lp = LEMON_glp(create_prob)();
     59    LEMON_glp(create_index)(lp);
    4260    ///\todo control function for this:
    43     lpx_set_int_parm(lp, LPX_K_DUAL, 1);
     61    LEMON_lpx(set_int_parm)(lp, LEMON_LPX(K_DUAL), 1);
    4462    messageLevel(0);
    4563    //Coefficient matrix, row bounds
    46     lpx_add_rows(lp, lpx_get_num_rows(glp.lp));
    47     lpx_add_cols(lp, lpx_get_num_cols(glp.lp));
     64    LEMON_glp(add_rows)(lp, LEMON_glp(get_num_rows)(glp.lp));
     65    LEMON_glp(add_cols)(lp, LEMON_glp(get_num_cols)(glp.lp));
    4866    int len;
    49     int ind[1+lpx_get_num_cols(glp.lp)];
    50     Value val[1+lpx_get_num_cols(glp.lp)];
    51     for (int i=1;i<=lpx_get_num_rows(glp.lp);++i)
     67    int ind[1+LEMON_glp(get_num_cols)(glp.lp)];
     68    Value val[1+LEMON_glp(get_num_cols)(glp.lp)];
     69    for (int i=1;i<=LEMON_glp(get_num_rows)(glp.lp);++i)
    5270      {
    53         len=lpx_get_mat_row(glp.lp,i,ind,val);
    54         lpx_set_mat_row(lp, i,len,ind,val);
    55         lpx_set_row_bnds(lp,i,lpx_get_row_type(glp.lp,i),
    56                          lpx_get_row_lb(glp.lp,i),lpx_get_row_ub(glp.lp,i));
     71        len=LEMON_glp(get_mat_row)(glp.lp,i,ind,val);
     72        LEMON_glp(set_mat_row)(lp, i,len,ind,val);
     73        LEMON_glp(set_row_bnds)(lp,i,
     74                                LEMON_glp(get_row_type)(glp.lp,i),
     75                                LEMON_glp(get_row_lb)(glp.lp,i),
     76                                LEMON_glp(get_row_ub)(glp.lp,i));
    5777      }
    5878
    5979    //Objective function, coloumn bounds
    60     lpx_set_obj_dir(lp, lpx_get_obj_dir(glp.lp));
     80    LEMON_glp(set_obj_dir)(lp, LEMON_glp(get_obj_dir)(glp.lp));
    6181    //Objectif function's constant term treated separately
    62     lpx_set_obj_coef(lp,0,lpx_get_obj_coef(glp.lp,0));
    63     for (int i=1;i<=lpx_get_num_cols(glp.lp);++i)
     82    LEMON_glp(set_obj_coef)(lp,0,LEMON_glp(get_obj_coef)(glp.lp,0));
     83    for (int i=1;i<=LEMON_glp(get_num_cols)(glp.lp);++i)
    6484      {
    65         lpx_set_obj_coef(lp,i,lpx_get_obj_coef(glp.lp,i));
    66         lpx_set_col_bnds(lp,i,lpx_get_col_type(glp.lp,i),
    67                          lpx_get_col_lb(glp.lp,i),lpx_get_col_ub(glp.lp,i));
     85        LEMON_glp(set_obj_coef)(lp,i,
     86                                LEMON_glp(get_obj_coef)(glp.lp,i));
     87        LEMON_glp(set_col_bnds)(lp,i,
     88                                LEMON_glp(get_col_type)(glp.lp,i),
     89                                LEMON_glp(get_col_lb)(glp.lp,i),
     90                                LEMON_glp(get_col_ub)(glp.lp,i));
    6891      }
    6992  }
    7093 
    7194  LpGlpk::~LpGlpk() {
    72     lpx_delete_prob(lp);
     95    LEMON_glp(delete_prob)(lp);
    7396  }
    7497 
    7598  int LpGlpk::_addCol() {
    76     int i=lpx_add_cols(lp, 1);
    77     _setColLowerBound(i, -INF);
    78     _setColUpperBound(i, INF);
     99    int i=LEMON_glp(add_cols)(lp, 1);
     100    LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(FR), 0.0, 0.0);
     101    solved = false;
    79102    return i;
    80103  }
     
    98121
    99122  int LpGlpk::_addRow() {
    100     int i=lpx_add_rows(lp, 1);
     123    int i=LEMON_glp(add_rows)(lp, 1);
     124    solved = false;
    101125    return i;
    102126  }
     
    106130    int ca[2];
    107131    ca[1]=i;
    108     lpx_del_cols(lp, 1, ca);
     132    LEMON_glp(del_cols)(lp, 1, ca);
     133    solved = false;
    109134  }
    110135 
     
    112137    int ra[2];
    113138    ra[1]=i;
    114     lpx_del_rows(lp, 1, ra);
     139    LEMON_glp(del_rows)(lp, 1, ra);
     140    solved = false;
    115141  }
    116142
     
    118144  {
    119145   
    120     char *n = lpx_get_col_name(lp,c);
     146    const char *n = LEMON_glp(get_col_name)(lp,c);
    121147    name = n?n:"";
    122148  }
     
    125151  void LpGlpk::_setColName(int c, const std::string & name)
    126152  {
    127     lpx_set_col_name(lp,c,const_cast<char*>(name.c_str()));
     153    LEMON_glp(set_col_name)(lp,c,const_cast<char*>(name.c_str()));
    128154
    129155  }
     
    131157  int LpGlpk::_colByName(const std::string& name) const
    132158  {
    133     int k = lpx_find_col(lp, const_cast<char*>(name.c_str()));
     159    int k = LEMON_glp(find_col)(lp, const_cast<char*>(name.c_str()));
    134160    return k > 0 ? k : -1;
    135161  }
     
    149175    }
    150176
    151     lpx_set_mat_row(lp, i, values.size() - 1, &indices[0], &values[0]);
     177    LEMON_glp(set_mat_row)(lp, i, values.size() - 1,
     178                                &indices[0], &values[0]);
     179
     180    solved = false;
    152181  }
    153182
    154183  void LpGlpk::_getRowCoeffs(int ix, RowIterator b) const
    155184  {
    156     int length = lpx_get_mat_row(lp, ix, 0, 0);
     185    int length = LEMON_glp(get_mat_row)(lp, ix, 0, 0);
    157186   
    158187    std::vector<int> indices(length + 1);
    159188    std::vector<Value> values(length + 1);
    160189   
    161     lpx_get_mat_row(lp, ix, &indices[0], &values[0]);
     190    LEMON_glp(get_mat_row)(lp, ix, &indices[0], &values[0]);
    162191   
    163192    for (int i = 1; i <= length; ++i) {
     
    180209    }
    181210   
    182     lpx_set_mat_col(lp, ix, values.size() - 1, &indices[0], &values[0]);
     211    LEMON_glp(set_mat_col)(lp, ix, values.size() - 1,
     212                                &indices[0], &values[0]);
     213
     214    solved = false;
    183215  }
    184216
    185217  void LpGlpk::_getColCoeffs(int ix, ColIterator b) const
    186218  {
    187     int length = lpx_get_mat_col(lp, ix, 0, 0);
     219    int length = LEMON_glp(get_mat_col)(lp, ix, 0, 0);
    188220   
    189221    std::vector<int> indices(length + 1);
    190222    std::vector<Value> values(length + 1);
    191223   
    192     lpx_get_mat_col(lp, ix, &indices[0], &values[0]);
     224    LEMON_glp(get_mat_col)(lp, ix, &indices[0], &values[0]);
    193225   
    194226    for (int i = 1; i <= length; ++i) {
     
    201233  {
    202234
    203     if (lpx_get_num_cols(lp) < lpx_get_num_rows(lp)) {
    204 
    205       int length=lpx_get_mat_row(lp, ix, 0, 0);
     235    if (LEMON_glp(get_num_cols)(lp) < LEMON_glp(get_num_rows)(lp)) {
     236
     237      int length=LEMON_glp(get_mat_row)(lp, ix, 0, 0);
    206238     
    207239      std::vector<int> indices(length + 2);
    208240      std::vector<Value> values(length + 2);
    209241     
    210       lpx_get_mat_row(lp, ix, &indices[0], &values[0]);
     242      LEMON_glp(get_mat_row)(lp, ix, &indices[0], &values[0]);
    211243     
    212244      //The following code does not suppose that the elements of the
     
    226258      }
    227259   
    228       lpx_set_mat_row(lp, ix, length, &indices[0], &values[0]);
     260      LEMON_glp(set_mat_row)(lp, ix, length, &indices[0], &values[0]);
    229261
    230262    } else {
    231263
    232       int length=lpx_get_mat_col(lp, jx, 0, 0);
     264      int length=LEMON_glp(get_mat_col)(lp, jx, 0, 0);
    233265     
    234266      std::vector<int> indices(length + 2);
    235267      std::vector<Value> values(length + 2);
    236268     
    237       lpx_get_mat_col(lp, jx, &indices[0], &values[0]);
     269      LEMON_glp(get_mat_col)(lp, jx, &indices[0], &values[0]);
    238270     
    239271      //The following code does not suppose that the elements of the
     
    253285      }
    254286   
    255       lpx_set_mat_col(lp, jx, length, &indices[0], &values[0]);
    256     }
     287      LEMON_glp(set_mat_col)(lp, jx, length, &indices[0], &values[0]);
     288    }
     289
     290    solved = false;
    257291  }
    258292
     
    260294  {
    261295
    262     int length=lpx_get_mat_row(lp, ix, 0, 0);
     296    int length=LEMON_glp(get_mat_row)(lp, ix, 0, 0);
    263297   
    264298    std::vector<int> indices(length + 1);
    265299    std::vector<Value> values(length + 1);
    266300   
    267     lpx_get_mat_row(lp, ix, &indices[0], &values[0]);
     301    LEMON_glp(get_mat_row)(lp, ix, &indices[0], &values[0]);
    268302   
    269303    //The following code does not suppose that the elements of the
     
    284318      //FIXME error
    285319    }
    286     int b=lpx_get_col_type(lp, i);
    287     double up=lpx_get_col_ub(lp, i);   
     320    int b=LEMON_glp(get_col_type)(lp, i);
     321    double up=LEMON_glp(get_col_ub)(lp, i);     
    288322    if (lo==-INF) {
    289323      switch (b) {
    290       case LPX_FR:
    291       case LPX_LO:
    292         lpx_set_col_bnds(lp, i, LPX_FR, lo, up);
    293         break;
    294       case LPX_UP:
    295         break;
    296       case LPX_DB:
    297       case LPX_FX:
    298         lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
     324      case LEMON_GLP(FR):
     325      case LEMON_GLP(LO):
     326        LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(FR), lo, up);
     327        break;
     328      case LEMON_GLP(UP):
     329        break;
     330      case LEMON_GLP(DB):
     331      case LEMON_GLP(FX):
     332        LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(UP), lo, up);
    299333        break;
    300334      default: ;
     
    303337    } else {
    304338      switch (b) {
    305       case LPX_FR:
    306       case LPX_LO:
    307         lpx_set_col_bnds(lp, i, LPX_LO, lo, up);
    308         break;
    309       case LPX_UP:       
    310       case LPX_DB:
    311       case LPX_FX:
     339      case LEMON_GLP(FR):
     340      case LEMON_GLP(LO):
     341        LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(LO), lo, up);
     342        break;
     343      case LEMON_GLP(UP):         
     344      case LEMON_GLP(DB):
     345      case LEMON_GLP(FX):
    312346        if (lo==up)
    313           lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
     347          LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(FX), lo, up);
    314348        else
    315           lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
     349          LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(DB), lo, up);
    316350        break;
    317351      default: ;
     
    320354    }
    321355
     356    solved = false;
    322357  }
    323358
    324359  LpGlpk::Value LpGlpk::_getColLowerBound(int i) const
    325360  {
    326     int b=lpx_get_col_type(lp, i);
     361    int b=LEMON_glp(get_col_type)(lp, i);
    327362      switch (b) {
    328       case LPX_LO:
    329       case LPX_DB:
    330       case LPX_FX:
    331         return lpx_get_col_lb(lp, i);   
     363      case LEMON_GLP(LO):
     364      case LEMON_GLP(DB):
     365      case LEMON_GLP(FX):
     366        return LEMON_glp(get_col_lb)(lp, i);   
    332367      default: ;
    333368        return -INF;
     
    340375      //FIXME error
    341376    }
    342     int b=lpx_get_col_type(lp, i);
    343     double lo=lpx_get_col_lb(lp, i);
     377    int b=LEMON_glp(get_col_type)(lp, i);
     378    double lo=LEMON_glp(get_col_lb)(lp, i);
    344379    if (up==INF) {
    345380      switch (b) {
    346       case LPX_FR:
    347       case LPX_LO:
    348         break;
    349       case LPX_UP:
    350         lpx_set_col_bnds(lp, i, LPX_FR, lo, up);
    351         break;
    352       case LPX_DB:
    353       case LPX_FX:
    354         lpx_set_col_bnds(lp, i, LPX_LO, lo, up);
     381      case LEMON_GLP(FR):
     382      case LEMON_GLP(LO):
     383        break;
     384      case LEMON_GLP(UP):
     385        LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(FR), lo, up);
     386        break;
     387      case LEMON_GLP(DB):
     388      case LEMON_GLP(FX):
     389        LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(LO), lo, up);
    355390        break;
    356391      default: ;
     
    359394    } else {
    360395      switch (b) {
    361       case LPX_FR:
    362         lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
    363         break;
    364       case LPX_UP:
    365         lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
    366         break;
    367       case LPX_LO:
    368       case LPX_DB:
    369       case LPX_FX:
     396      case LEMON_GLP(FR):
     397        LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(UP), lo, up);
     398        break;
     399      case LEMON_GLP(UP):
     400        LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(UP), lo, up);
     401        break;
     402      case LEMON_GLP(LO):
     403      case LEMON_GLP(DB):
     404      case LEMON_GLP(FX):
    370405        if (lo==up)
    371           lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
     406          LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(FX), lo, up);
    372407        else
    373           lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
     408          LEMON_glp(set_col_bnds)(lp, i, LEMON_GLP(DB), lo, up);
    374409        break;
    375410      default: ;
     
    377412      }
    378413    }
     414
     415    solved = false;
    379416  }
    380417
    381418  LpGlpk::Value LpGlpk::_getColUpperBound(int i) const
    382419  {
    383     int b=lpx_get_col_type(lp, i);
     420    int b=LEMON_glp(get_col_type)(lp, i);
    384421      switch (b) {
    385       case LPX_UP:
    386       case LPX_DB:
    387       case LPX_FX:
    388         return lpx_get_col_ub(lp, i);   
     422      case LEMON_GLP(UP):
     423      case LEMON_GLP(DB):
     424      case LEMON_GLP(FX):
     425        return LEMON_glp(get_col_ub)(lp, i);   
    389426      default: ;
    390427        return INF;
     
    401438    if (lb == -INF){
    402439      if (ub == INF){
    403         lpx_set_row_bnds(lp, i, LPX_FR, lb, ub);
     440        LEMON_glp(set_row_bnds)(lp, i, LEMON_GLP(FR), lb, ub);
    404441      }
    405442      else{
    406         lpx_set_row_bnds(lp, i, LPX_UP, lb, ub);
     443        LEMON_glp(set_row_bnds)(lp, i, LEMON_GLP(UP), lb, ub);
    407444      }
    408445    }
    409446    else{
    410447      if (ub==INF){
    411         lpx_set_row_bnds(lp, i, LPX_LO, lb, ub);
     448        LEMON_glp(set_row_bnds)(lp, i, LEMON_GLP(LO), lb, ub);
    412449
    413450      }
    414451      else{
    415452        if (lb == ub){
    416           lpx_set_row_bnds(lp, i, LPX_FX, lb, ub);
     453          LEMON_glp(set_row_bnds)(lp, i, LEMON_GLP(FX), lb, ub);
    417454        }
    418455        else{
    419           lpx_set_row_bnds(lp, i, LPX_DB, lb, ub);
     456          LEMON_glp(set_row_bnds)(lp, i, LEMON_GLP(DB), lb, ub);
    420457        }
    421458      }
    422459    }
    423460
     461    solved = false;
    424462  }
    425463
     
    427465  {
    428466
    429     int b=lpx_get_row_type(lp, i);
     467    int b=LEMON_glp(get_row_type)(lp, i);
    430468    switch (b) {
    431     case LPX_FR:
    432     case LPX_UP:
     469    case LEMON_GLP(FR):
     470    case LEMON_GLP(UP):
    433471      lb = -INF;
    434472        break;
    435473    default:
    436       lb=lpx_get_row_lb(lp, i);
     474      lb=LEMON_glp(get_row_lb)(lp, i);
    437475    }
    438476
    439477    switch (b) {
    440     case LPX_FR:
    441     case LPX_LO:
     478    case LEMON_GLP(FR):
     479    case LEMON_GLP(LO):
    442480      ub = INF;
    443481        break;
    444482    default:
    445       ub=lpx_get_row_ub(lp, i);
     483      ub=LEMON_glp(get_row_ub)(lp, i);
    446484    }
    447485   
     
    451489  {
    452490    //i=0 means the constant term (shift)
    453     lpx_set_obj_coef(lp, i, obj_coef);
     491    LEMON_glp(set_obj_coef)(lp, i, obj_coef);
     492
     493    solved = false;
    454494  }
    455495
    456496  LpGlpk::Value LpGlpk::_getObjCoeff(int i) const {
    457497    //i=0 means the constant term (shift)
    458     return lpx_get_obj_coef(lp, i);
     498    return LEMON_glp(get_obj_coef)(lp, i);
    459499  }
    460500
    461501  void LpGlpk::_clearObj()
    462502  {
    463     for (int i=0;i<=lpx_get_num_cols(lp);++i){
    464       lpx_set_obj_coef(lp, i, 0);
    465     }
     503    for (int i=0;i<=LEMON_glp(get_num_cols)(lp);++i){
     504      LEMON_glp(set_obj_coef)(lp, i, 0);
     505    }
     506
     507    solved = false;
    466508  }
    467509
     
    469511  {
    470512    // A way to check the problem to be solved
    471     //lpx_write_cpxlp(lp,"naittvan.cpx");   
    472 
    473     lpx_std_basis(lp);
    474     int i =  lpx_simplex(lp);
     513    //LEMON_glp(write_cpxlp(lp,"naittvan.cpx");   
     514
     515    LEMON_lpx(std_basis)(lp);
     516    int i =  LEMON_lpx(simplex)(lp);
    475517   
    476518    switch (i) {
    477     case LPX_E_OK:
     519    case LEMON_LPX(E_OK):
     520      solved = true;
    478521      return SOLVED;
    479522    default:
     
    484527  LpGlpk::Value LpGlpk::_getPrimal(int i) const
    485528  {
    486     return lpx_get_col_prim(lp,i);
     529    return LEMON_glp(get_col_prim)(lp,i);
    487530  }
    488531
    489532  LpGlpk::Value LpGlpk::_getDual(int i) const
    490533  {
    491     return lpx_get_row_dual(lp,i);
     534    return LEMON_glp(get_row_dual)(lp,i);
    492535  }
    493536 
    494537  LpGlpk::Value LpGlpk::_getPrimalValue() const
    495538  {
    496     return lpx_get_obj_val(lp);
     539    return LEMON_glp(get_obj_val)(lp);
    497540  }
    498541  bool LpGlpk::_isBasicCol(int i) const
    499542  {
    500     return (lpx_get_col_stat(lp, i)==LPX_BS);
     543    return (LEMON_glp(get_col_stat)(lp, i)==LEMON_GLP(BS));
    501544  }
    502545 
     
    504547  LpGlpk::SolutionStatus LpGlpk::_getPrimalStatus() const
    505548  {
    506     int stat=  lpx_get_status(lp);
     549    if (!solved) return UNDEFINED;
     550    int stat=  LEMON_lpx(get_status)(lp);
    507551    switch (stat) {
    508     case LPX_UNDEF://Undefined (no solve has been run yet)
     552    case LEMON_LPX(UNDEF)://Undefined (no solve has been run yet)
    509553      return UNDEFINED;
    510     case LPX_NOFEAS://There is no feasible solution (primal, I guess)
    511     case LPX_INFEAS://Infeasible
     554    case LEMON_LPX(NOFEAS)://There is no feasible solution (primal, I guess)
     555    case LEMON_LPX(INFEAS)://Infeasible
    512556      return INFEASIBLE;
    513     case LPX_UNBND://Unbounded
     557    case LEMON_LPX(UNBND)://Unbounded
    514558      return INFINITE;
    515     case LPX_FEAS://Feasible
     559    case LEMON_LPX(FEAS)://Feasible
    516560      return FEASIBLE;
    517     case LPX_OPT://Feasible
     561    case LEMON_LPX(OPT)://Feasible
    518562      return OPTIMAL;
    519563    default:
     
    525569  LpGlpk::SolutionStatus LpGlpk::_getDualStatus() const
    526570  {
    527     switch (lpx_get_dual_stat(lp)) {
    528     case LPX_D_UNDEF://Undefined (no solve has been run yet)
     571    if (!solved) return UNDEFINED;
     572    switch (LEMON_lpx(get_dual_stat)(lp)) {
     573    case LEMON_LPX(D_UNDEF)://Undefined (no solve has been run yet)
    529574      return UNDEFINED;
    530     case LPX_D_NOFEAS://There is no dual feasible solution
    531 //    case LPX_D_INFEAS://Infeasible
     575    case LEMON_LPX(D_NOFEAS)://There is no dual feasible solution
     576//    case LEMON_LPX(D_INFEAS://Infeasible
    532577      return INFEASIBLE;
    533     case LPX_D_FEAS://Feasible   
    534       switch (lpx_get_status(lp)) {
    535       case LPX_NOFEAS:
     578    case LEMON_LPX(D_FEAS)://Feasible   
     579      switch (LEMON_lpx(get_status)(lp)) {
     580      case LEMON_LPX(NOFEAS):
    536581        return INFINITE;
    537       case LPX_OPT:
     582      case LEMON_LPX(OPT):
    538583        return OPTIMAL;
    539584      default:
     
    548593  LpGlpk::ProblemTypes LpGlpk::_getProblemType() const
    549594  {
    550       //int stat=  lpx_get_status(lp);
    551     int statp=  lpx_get_prim_stat(lp);
    552     int statd=  lpx_get_dual_stat(lp);
    553     if (statp==LPX_P_FEAS && statd==LPX_D_FEAS)
     595    if (!solved) return UNKNOWN;
     596      //int stat=  LEMON_glp(get_status(lp);
     597    int statp=  LEMON_lpx(get_prim_stat)(lp);
     598    int statd=  LEMON_lpx(get_dual_stat)(lp);
     599    if (statp==LEMON_LPX(P_FEAS) && statd==LEMON_LPX(D_FEAS))
    554600        return PRIMAL_DUAL_FEASIBLE;
    555     if (statp==LPX_P_FEAS && statd==LPX_D_NOFEAS)
     601    if (statp==LEMON_LPX(P_FEAS) && statd==LEMON_LPX(D_NOFEAS))
    556602        return PRIMAL_FEASIBLE_DUAL_INFEASIBLE;
    557     if (statp==LPX_P_NOFEAS && statd==LPX_D_FEAS)
     603    if (statp==LEMON_LPX(P_NOFEAS) && statd==LEMON_LPX(D_FEAS))
    558604        return PRIMAL_INFEASIBLE_DUAL_FEASIBLE;
    559     if (statp==LPX_P_NOFEAS && statd==LPX_D_NOFEAS)
     605    if (statp==LEMON_LPX(P_NOFEAS) && statd==LEMON_LPX(D_NOFEAS))
    560606        return PRIMAL_DUAL_INFEASIBLE;
    561607    //In all other cases
     
    565611  void LpGlpk::_setMax()
    566612  {
    567     lpx_set_obj_dir(lp, LPX_MAX);
     613    solved = false;
     614    LEMON_glp(set_obj_dir)(lp, LEMON_GLP(MAX));
    568615  }
    569616
    570617  void LpGlpk::_setMin()
    571618  {
    572     lpx_set_obj_dir(lp, LPX_MIN);
     619    solved = false;
     620    LEMON_glp(set_obj_dir)(lp, LEMON_GLP(MIN));
    573621  }
    574622
    575623  bool LpGlpk::_isMax() const
    576624  {
    577     return (lpx_get_obj_dir(lp)==LPX_MAX);
     625    return (LEMON_glp(get_obj_dir)(lp)==LEMON_GLP(MAX));
    578626  }
    579627
     
    582630  void LpGlpk::messageLevel(int m)
    583631  {
    584     lpx_set_int_parm(lp, LPX_K_MSGLEV, m);
     632    LEMON_lpx(set_int_parm)(lp, LEMON_LPX(K_MSGLEV), m);
    585633  }
    586634
    587635  void LpGlpk::presolver(bool b)
    588636  {
    589     lpx_set_int_parm(lp, LPX_K_PRESOL, b);
     637    LEMON_lpx(set_int_parm)(lp, LEMON_LPX(K_PRESOL), b);
    590638  }
    591639
Note: See TracChangeset for help on using the changeset viewer.