COIN-OR::LEMON - Graph Library

Changeset 2321:e23a610bed51 in lemon-0.x for lemon


Ignore:
Timestamp:
12/04/06 14:13:14 (13 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3097
Message:

Copy constructor for LpGlpk?

Location:
lemon
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lemon/lp_glpk.cc

    r2312 r2321  
    3232  }
    3333 
     34  LpGlpk::LpGlpk(const LpGlpk &glp) : Parent(glp),
     35                                      lp(lpx_create_prob()) {
     36    ///\todo constrol function for this:
     37    lpx_set_int_parm(lp, LPX_K_DUAL, 1);
     38    messageLevel(0);
     39    //Coefficient matrix, row bounds
     40    lpx_add_rows(lp, lpx_get_num_rows(glp.lp));
     41    lpx_add_cols(lp, lpx_get_num_cols(glp.lp));
     42    int len;
     43    int ind[1+lpx_get_num_cols(glp.lp)];
     44    Value val[1+lpx_get_num_cols(glp.lp)];
     45    for (int i=1;i<=lpx_get_num_rows(glp.lp);++i)
     46      {
     47        len=lpx_get_mat_row(glp.lp,i,ind,val);
     48        lpx_set_mat_row(lp, i,len,ind,val);
     49        lpx_set_row_bnds(lp,i,lpx_get_row_type(glp.lp,i),
     50                         lpx_get_row_lb(glp.lp,i),lpx_get_row_ub(glp.lp,i));
     51      }
     52
     53    //Objective function, coloumn bounds
     54    lpx_set_obj_dir(lp, lpx_get_obj_dir(glp.lp));
     55    //Objectif function's constant term treated separately
     56    lpx_set_obj_coef(lp,0,lpx_get_obj_coef(glp.lp,0));
     57    for (int i=1;i<=lpx_get_num_cols(glp.lp);++i)
     58      {
     59        lpx_set_obj_coef(lp,i,lpx_get_obj_coef(glp.lp,i));
     60        lpx_set_col_bnds(lp,i,lpx_get_col_type(glp.lp,i),
     61                         lpx_get_col_lb(glp.lp,i),lpx_get_col_ub(glp.lp,i));
     62      }
     63  }
     64 
    3465  LpGlpk::~LpGlpk() {
    3566    lpx_delete_prob(lp);
     
    4879  LpSolverBase &LpGlpk::_newLp()
    4980  {
    50     LpGlpk* newlp=new LpGlpk();
     81    LpGlpk* newlp=new LpGlpk;
    5182    return *newlp;
    5283  }
     
    5687  LpSolverBase &LpGlpk::_copyLp()
    5788  {
    58     LpGlpk* newlp=new LpGlpk();
    59 
    60     //Coefficient matrix, row bounds
    61     lpx_add_rows(newlp->lp, lpx_get_num_rows(lp));
    62     lpx_add_cols(newlp->lp, lpx_get_num_cols(lp));
    63     int len;
    64     int ind[1+lpx_get_num_cols(lp)];
    65     Value val[1+lpx_get_num_cols(lp)];
    66     for (int i=1;i<=lpx_get_num_rows(lp);++i){
    67       len=lpx_get_mat_row(lp,i,ind,val);
    68       lpx_set_mat_row(newlp->lp, i,len,ind,val);
    69       lpx_set_row_bnds(newlp->lp,i,lpx_get_row_type(lp,i),
    70                        lpx_get_row_lb(lp,i),lpx_get_row_ub(lp,i));
    71     }
    72 
    73     //Objective function, coloumn bounds
    74     lpx_set_obj_dir(newlp->lp, lpx_get_obj_dir(lp));
    75     //Objectif function's constant term treated separately
    76     lpx_set_obj_coef(newlp->lp,0,lpx_get_obj_coef(lp,0));
    77     for (int i=1;i<=lpx_get_num_cols(lp);++i){
    78       lpx_set_obj_coef(newlp->lp,i,lpx_get_obj_coef(lp,i));
    79       lpx_set_col_bnds(newlp->lp,i,lpx_get_col_type(lp,i),
    80                        lpx_get_col_lb(lp,i),lpx_get_col_ub(lp,i));
    81      
    82      
    83     }
    84 
     89    LpGlpk* newlp=new LpGlpk(*this);
    8590    return *newlp;
    8691  }
  • lemon/lp_glpk.h

    r2312 r2321  
    4545   
    4646    LpGlpk();
     47    LpGlpk(const LpGlpk &);
    4748    ~LpGlpk();
    4849   
     
    109110    ///The presolver is off by default.
    110111    void presolver(bool b);
    111    
     112
     113    LPX *lpx() {return lp;}
    112114  };
    113115} //END OF NAMESPACE LEMON
Note: See TracChangeset for help on using the changeset viewer.