COIN-OR::LEMON - Graph Library

Changeset 1436:e0beb94d08bf in lemon-0.x for lemon/lp_glpk.cc


Ignore:
Timestamp:
05/26/05 14:16:16 (14 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1910
Message:

_copyLp(), _newLp() implemented.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/lp_glpk.cc

    r1435 r1436  
    2525namespace lemon {
    2626
    27   ///\e
    28 
    29   ///\bug Unimplemented!
    30   ///
    31   LpSolverBase &LpGlpk::_newLp()
    32   {
    33     LpSolverBase *tmp=0;
    34     return *tmp;
    35   }
    36  
    37   ///\e
    38 
    39   ///\bug Unimplemented!
    40   ///
    41   LpSolverBase &LpGlpk::_copyLp()
    42   {
    43     LpSolverBase *tmp=0;
    44     return *tmp;
    45   }
    4627
    4728  LpGlpk::LpGlpk() : Parent(),
     
    6142    _setColUpperBound(i, INF);
    6243    return i;
     44  }
     45
     46  ///\e
     47
     48
     49  LpSolverBase &LpGlpk::_newLp()
     50  {
     51    LpGlpk* newlp=new LpGlpk();
     52    return *newlp;
     53  }
     54 
     55  ///\e
     56
     57  LpSolverBase &LpGlpk::_copyLp()
     58  {
     59    LpGlpk* newlp=new LpGlpk();
     60
     61    //Coefficient matrix, row bounds
     62    lpx_add_rows(newlp->lp, lpx_get_num_rows(lp));
     63    lpx_add_cols(newlp->lp, lpx_get_num_cols(lp));
     64    int len;
     65    int ind[1+lpx_get_num_cols(lp)];
     66    Value val[1+lpx_get_num_cols(lp)];
     67    for (int i=1;i<=lpx_get_num_rows(lp);++i){
     68      len=lpx_get_mat_row(lp,i,ind,val);
     69      lpx_set_mat_row(newlp->lp, i,len,ind,val);
     70      lpx_set_row_bnds(newlp->lp,i,lpx_get_row_type(lp,i),
     71                       lpx_get_row_lb(lp,i),lpx_get_row_ub(lp,i));
     72    }
     73
     74    //Objective function, coloumn bounds
     75    lpx_set_obj_dir(newlp->lp, lpx_get_obj_dir(lp));
     76    //Objectif function's constant term treated separately
     77    lpx_set_obj_coef(newlp->lp,0,lpx_get_obj_coef(lp,0));
     78    for (int i=1;i<=lpx_get_num_cols(lp);++i){
     79      lpx_set_obj_coef(newlp->lp,i,lpx_get_obj_coef(lp,i));
     80      lpx_set_col_bnds(newlp->lp,i,lpx_get_col_type(lp,i),
     81                       lpx_get_col_lb(lp,i),lpx_get_col_ub(lp,i));
     82     
     83     
     84    }
     85
     86    return *newlp;
    6387  }
    6488
Note: See TracChangeset for help on using the changeset viewer.