1.1 --- a/lemon/lp_glpk.cc Mon May 23 04:48:14 2005 +0000
1.2 +++ b/lemon/lp_glpk.cc Thu May 26 12:16:16 2005 +0000
1.3 @@ -24,25 +24,6 @@
1.4
1.5 namespace lemon {
1.6
1.7 - ///\e
1.8 -
1.9 - ///\bug Unimplemented!
1.10 - ///
1.11 - LpSolverBase &LpGlpk::_newLp()
1.12 - {
1.13 - LpSolverBase *tmp=0;
1.14 - return *tmp;
1.15 - }
1.16 -
1.17 - ///\e
1.18 -
1.19 - ///\bug Unimplemented!
1.20 - ///
1.21 - LpSolverBase &LpGlpk::_copyLp()
1.22 - {
1.23 - LpSolverBase *tmp=0;
1.24 - return *tmp;
1.25 - }
1.26
1.27 LpGlpk::LpGlpk() : Parent(),
1.28 lp(lpx_create_prob()) {
1.29 @@ -62,6 +43,49 @@
1.30 return i;
1.31 }
1.32
1.33 + ///\e
1.34 +
1.35 +
1.36 + LpSolverBase &LpGlpk::_newLp()
1.37 + {
1.38 + LpGlpk* newlp=new LpGlpk();
1.39 + return *newlp;
1.40 + }
1.41 +
1.42 + ///\e
1.43 +
1.44 + LpSolverBase &LpGlpk::_copyLp()
1.45 + {
1.46 + LpGlpk* newlp=new LpGlpk();
1.47 +
1.48 + //Coefficient matrix, row bounds
1.49 + lpx_add_rows(newlp->lp, lpx_get_num_rows(lp));
1.50 + lpx_add_cols(newlp->lp, lpx_get_num_cols(lp));
1.51 + int len;
1.52 + int ind[1+lpx_get_num_cols(lp)];
1.53 + Value val[1+lpx_get_num_cols(lp)];
1.54 + for (int i=1;i<=lpx_get_num_rows(lp);++i){
1.55 + len=lpx_get_mat_row(lp,i,ind,val);
1.56 + lpx_set_mat_row(newlp->lp, i,len,ind,val);
1.57 + lpx_set_row_bnds(newlp->lp,i,lpx_get_row_type(lp,i),
1.58 + lpx_get_row_lb(lp,i),lpx_get_row_ub(lp,i));
1.59 + }
1.60 +
1.61 + //Objective function, coloumn bounds
1.62 + lpx_set_obj_dir(newlp->lp, lpx_get_obj_dir(lp));
1.63 + //Objectif function's constant term treated separately
1.64 + lpx_set_obj_coef(newlp->lp,0,lpx_get_obj_coef(lp,0));
1.65 + for (int i=1;i<=lpx_get_num_cols(lp);++i){
1.66 + lpx_set_obj_coef(newlp->lp,i,lpx_get_obj_coef(lp,i));
1.67 + lpx_set_col_bnds(newlp->lp,i,lpx_get_col_type(lp,i),
1.68 + lpx_get_col_lb(lp,i),lpx_get_col_ub(lp,i));
1.69 +
1.70 +
1.71 + }
1.72 +
1.73 + return *newlp;
1.74 + }
1.75 +
1.76 int LpGlpk::_addRow() {
1.77 int i=lpx_add_rows(lp, 1);
1.78 return i;