22 |
22 |
23 #include <lemon/lp_glpk.h> |
23 #include <lemon/lp_glpk.h> |
24 |
24 |
25 namespace lemon { |
25 namespace lemon { |
26 |
26 |
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 } |
|
46 |
27 |
47 LpGlpk::LpGlpk() : Parent(), |
28 LpGlpk::LpGlpk() : Parent(), |
48 lp(lpx_create_prob()) { |
29 lp(lpx_create_prob()) { |
49 ///\todo constrol function for this: |
30 ///\todo constrol function for this: |
50 lpx_set_int_parm(lp, LPX_K_DUAL, 1); |
31 lpx_set_int_parm(lp, LPX_K_DUAL, 1); |
58 int LpGlpk::_addCol() { |
39 int LpGlpk::_addCol() { |
59 int i=lpx_add_cols(lp, 1); |
40 int i=lpx_add_cols(lp, 1); |
60 _setColLowerBound(i, -INF); |
41 _setColLowerBound(i, -INF); |
61 _setColUpperBound(i, INF); |
42 _setColUpperBound(i, INF); |
62 return i; |
43 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; |
63 } |
87 } |
64 |
88 |
65 int LpGlpk::_addRow() { |
89 int LpGlpk::_addRow() { |
66 int i=lpx_add_rows(lp, 1); |
90 int i=lpx_add_rows(lp, 1); |
67 return i; |
91 return i; |