Changeset 1436:e0beb94d08bf in lemon0.x
 Timestamp:
 05/26/05 14:16:16 (17 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1910
 Location:
 lemon
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

lemon/lp_base.h
r1435 r1436 418 418 //Abstract virtual functions 419 419 virtual LpSolverBase &_newLp() = 0; 420 virtual LpSolverBase &_copyLp() = 0; 420 virtual LpSolverBase &_copyLp(){ 421 ///\todo This should be implemented here, too, when we have problem retrieving routines. It can be overriden. 422 423 //Starting: 424 LpSolverBase & newlp(_newLp()); 425 return newlp; 426 //return *(LpSolverBase*)0; 427 }; 421 428 422 429 virtual int _addCol() = 0; … … 609 616 } 610 617 618 ///Set an element of the coefficient matrix of the LP 619 620 ///\param r is the row of the element to be modified 621 ///\param c is the coloumn of the element to be modified 622 ///\param val is the new value of the coefficient 623 void setCoeff(Row r, Col c, Value val){ 624 _setCoeff(rows.floatingId(r.id),cols.floatingId(c.id), val); 625 } 626 611 627 /// Set the lower bound of a column (i.e a variable) 612 628 
lemon/lp_cplex.cc
r1435 r1436 22 22 23 23 LpCplex::LpCplex() : LpSolverBase() { 24 env = NULL; 25 lp = NULL; 26 env = CPXopenCPLEXdevelop(&status); 27 // if (Env == NULL) 28 // { 29 // fprintf(stderr,"A CPLEX környezet megnyitása sikertelen.\n"); 30 // CPXgeterrorstring(Env, Status, ErrorMsg); 31 // fprintf(stderr,"%s",ErrorMsg); 32 // goto Terminate; 33 // } 34 35 // *** A problema létrehozása *** 24 25 // env = CPXopenCPLEXdevelop(&status); 26 env = CPXopenCPLEX(&status); 36 27 lp = CPXcreateprob(env, &status, "LP problem"); 37 38 // if (Problem == NULL) 39 // { 40 // fprintf(stderr,"Az LP létrehozása sikertelen"); 41 // goto Terminate; 42 // } 43 28 //CPXmsg (cpxresults, "Hellobello\n"); 44 29 } 45 30 46 31 LpCplex::~LpCplex() { 47 status = CPXfreeprob(env,&lp); 48 // if (Status != 0) 49 // { 50 // fprintf(stderr,"A CPLEX feladat törlése sikertelen.\n"); 51 // CPXgeterrorstring(Env, Status, ErrorMsg); 52 // fprintf(stderr,"%s",ErrorMsg); 53 // goto Terminate; 54 // } 55 56 status = CPXcloseCPLEX(&env); 57 // if (Status != 0) 58 // { 59 // fprintf(stderr,"A CPLEX környezet bezárása sikertelen.\n"); 60 // CPXgeterrorstring(Env, Status, ErrorMsg); 61 // fprintf(stderr,"%s",ErrorMsg); 62 // goto Terminate; 63 // } 64 32 CPXfreeprob(env,&lp); 33 CPXcloseCPLEX(&env); 65 34 } 66 35 67 36 LpSolverBase &LpCplex::_newLp() 68 37 { 69 return *(LpSolverBase*)0; 70 } 38 //The first approach opens a new environment 39 LpCplex* newlp=new LpCplex(); 40 return *newlp; 41 } 42 71 43 LpSolverBase &LpCplex::_copyLp() { 72 return *(LpSolverBase*)0; 73 //Ez lesz majd CPXcloneprob (env, lp, &status); 44 //The first approach opens a new environment 45 LpCplex* newlp=new LpCplex(); 46 //The routine CPXcloneprob can be used to create a new CPLEX problem 47 //object and copy all the problem data from an existing problem 48 //object to it. Solution and starting information is not copied. 49 newlp>lp = CPXcloneprob (env, lp, &status); 50 return *newlp; 74 51 } 75 52 … … 83 60 return i; 84 61 } 62 85 63 86 64 int LpCplex::_addRow() … … 98 76 99 77 void LpCplex::_eraseCol(int i) { 100 ///\todo Not implemented yet78 CPXdelcols (env, lp, i, i); 101 79 } 102 80 103 81 void LpCplex::_eraseRow(int i) { 104 ///\todo Not implemented yet82 CPXdelrows (env, lp, i, i); 105 83 } 106 84 
lemon/lp_glpk.cc
r1435 r1436 25 25 namespace lemon { 26 26 27 ///\e28 29 ///\bug Unimplemented!30 ///31 LpSolverBase &LpGlpk::_newLp()32 {33 LpSolverBase *tmp=0;34 return *tmp;35 }36 37 ///\e38 39 ///\bug Unimplemented!40 ///41 LpSolverBase &LpGlpk::_copyLp()42 {43 LpSolverBase *tmp=0;44 return *tmp;45 }46 27 47 28 LpGlpk::LpGlpk() : Parent(), … … 61 42 _setColUpperBound(i, INF); 62 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
Note: See TracChangeset
for help on using the changeset viewer.