[Lemon-commits] [lemon_svn] athos: r1867 - hugo/trunk/src/lemon

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:48:19 CET 2006


Author: athos
Date: Thu May  5 17:43:43 2005
New Revision: 1867

Modified:
   hugo/trunk/src/lemon/lp_base.h
   hugo/trunk/src/lemon/lp_cplex.cc
   hugo/trunk/src/lemon/lp_cplex.h
   hugo/trunk/src/lemon/lp_glpk.cc
   hugo/trunk/src/lemon/lp_glpk.h
   hugo/trunk/src/lemon/lp_skeleton.cc
   hugo/trunk/src/lemon/lp_skeleton.h

Log:
Deleted _setRowLowerBound() and _setRowUpperBound() functions. Cplex worked (now it does not because of _getPrimalStatus()).

Modified: hugo/trunk/src/lemon/lp_base.h
==============================================================================
--- hugo/trunk/src/lemon/lp_base.h	(original)
+++ hugo/trunk/src/lemon/lp_base.h	Thu May  5 17:43:43 2005
@@ -431,8 +431,8 @@
                                Value  const * values ) = 0;
     virtual void _setColLowerBound(int i, Value value) = 0;
     virtual void _setColUpperBound(int i, Value value) = 0;
-    virtual void _setRowLowerBound(int i, Value value) = 0;
-    virtual void _setRowUpperBound(int i, Value value) = 0;
+//     virtual void _setRowLowerBound(int i, Value value) = 0;
+//     virtual void _setRowUpperBound(int i, Value value) = 0;
     virtual void _setRowBounds(int i, Value lower, Value upper) = 0;
     virtual void _setObjCoeff(int i, Value obj_coef) = 0;
     virtual void _clearObj()=0;
@@ -567,8 +567,9 @@
 	}
       _setRowCoeffs(rows.floatingId(r.id),indices.size()-1,
 		    &indices[0],&values[0]);
-      _setRowLowerBound(rows.floatingId(r.id),l-e.constComp());
-      _setRowUpperBound(rows.floatingId(r.id),u-e.constComp());
+//       _setRowLowerBound(rows.floatingId(r.id),l-e.constComp());
+//       _setRowUpperBound(rows.floatingId(r.id),u-e.constComp());
+       _setRowBounds(rows.floatingId(r.id),l-e.constComp(),u-e.constComp());
     }
 
     ///Set a row (i.e a constaint) of the LP
@@ -633,23 +634,24 @@
       _setColUpperBound(cols.floatingId(c.id),upper);
     }
     
-    /// Set the lower bound of a row (i.e a constraint)
+//     /// Set the lower bound of a row (i.e a constraint)
 
-    /// The lower bound of a linear expression (row) has to be given by an 
-    /// extended number of type Value, i.e. a finite number of type 
-    /// Value or -\ref INF.
-    void rowLowerBound(Row r, Value value) {
-      _setRowLowerBound(rows.floatingId(r.id),value);
-    };
-    /// Set the upper bound of a row (i.e a constraint)
+//     /// The lower bound of a linear expression (row) has to be given by an 
+//     /// extended number of type Value, i.e. a finite number of type 
+//     /// Value or -\ref INF.
+//     void rowLowerBound(Row r, Value value) {
+//       _setRowLowerBound(rows.floatingId(r.id),value);
+//     };
+//     /// Set the upper bound of a row (i.e a constraint)
+
+//     /// The upper bound of a linear expression (row) has to be given by an 
+//     /// extended number of type Value, i.e. a finite number of type 
+//     /// Value or \ref INF.
+//     void rowUpperBound(Row r, Value value) {
+//       _setRowUpperBound(rows.floatingId(r.id),value);
+//     };
 
-    /// The upper bound of a linear expression (row) has to be given by an 
-    /// extended number of type Value, i.e. a finite number of type 
-    /// Value or \ref INF.
-    void rowUpperBound(Row r, Value value) {
-      _setRowUpperBound(rows.floatingId(r.id),value);
-    };
-    /// Set the lower and the upper bounds of a row (i.e a variable)
+    /// Set the lower and the upper bounds of a row (i.e a constraint)
 
     /// The lower and the upper bounds of
     /// a constraint (row) have to be given by an 

Modified: hugo/trunk/src/lemon/lp_cplex.cc
==============================================================================
--- hugo/trunk/src/lemon/lp_cplex.cc	(original)
+++ hugo/trunk/src/lemon/lp_cplex.cc	Thu May  5 17:43:43 2005
@@ -14,7 +14,7 @@
  * purpose.
  *
  */
-
+#include <iostream>
 #include<lemon/lp_cplex.h>
 
 ///\file
@@ -65,8 +65,14 @@
       
   }
   
-  LpSolverBase &LpCplex::_newLp() {return *(LpSolverBase*)0;}
-  LpSolverBase &LpCplex::_copyLp() {return *(LpSolverBase*)0;}
+  LpSolverBase &LpCplex::_newLp() 
+  {
+    return *(LpSolverBase*)0;
+  }
+  LpSolverBase &LpCplex::_copyLp() {
+    return *(LpSolverBase*)0;
+    //Ez lesz majd CPXcloneprob (env, lp, &status);
+  }
 
   int LpCplex::_addCol()
   {
@@ -155,7 +161,7 @@
     if (lb==INF || ub==-INF) {
       //FIXME error
     }
-
+    
     int cnt=1;
     int indices[1];
     indices[0]=i;
@@ -165,6 +171,7 @@
       sense[0]='L';
       CPXchgsense (env, lp, cnt, indices, sense);
       CPXchgcoef (env, lp, i, -1, ub);
+      
     }
     else{
       if (ub==INF){
@@ -188,36 +195,36 @@
     }
   }
 
-  void LpCplex::_setRowLowerBound(int i, Value value)
-  {
-    //Not implemented, obsolete
-  }
-  
-  void LpCplex::_setRowUpperBound(int i, Value value)
-  {
-    //Not implemented, obsolete
-//     //TODO Ezt kell meg megirni
-//     //type of the problem
-//     char sense[1];
-//     status = CPXgetsense (env, lp, sense, i, i);
-//     Value rhs[1];
-//     status = CPXgetrhs (env, lp, rhs, i, i);
+//   void LpCplex::_setRowLowerBound(int i, Value value)
+//   {
+//     //Not implemented, obsolete
+//   }
+  
+//   void LpCplex::_setRowUpperBound(int i, Value value)
+//   {
+//     //Not implemented, obsolete
+// //     //TODO Ezt kell meg megirni
+// //     //type of the problem
+// //     char sense[1];
+// //     status = CPXgetsense (env, lp, sense, i, i);
+// //     Value rhs[1];
+// //     status = CPXgetrhs (env, lp, rhs, i, i);
+
+// //     switch (sense[0]) {
+// //     case 'L'://<= constraint
+// //       break;
+// //     case 'E'://= constraint
+// //       break;
+// //     case 'G'://>= constraint
+// //       break;
+// //     case 'R'://ranged constraint
+// //       break;
+// //     default: ;
+// //       //FIXME error
+// //     }
 
-//     switch (sense[0]) {
-//     case 'L'://<= constraint
-//       break;
-//     case 'E'://= constraint
-//       break;
-//     case 'G'://>= constraint
-//       break;
-//     case 'R'://ranged constraint
-//       break;
-//     default: ;
-//       //FIXME error
-//     }
-
-//     status = CPXchgcoef (env, lp, i, -2, value_rng);
-  }
+// //     status = CPXchgcoef (env, lp, i, -2, value_rng);
+//   }
   
   void LpCplex::_setObjCoeff(int i, Value obj_coef)
   {
@@ -254,30 +261,41 @@
 
   LpCplex::SolutionStatus LpCplex::_getPrimalStatus()
   {
+// CPX_STAT_ABORT_DUAL_OBJ_LIM
+// CPX_STAT_ABORT_IT_LIM
+// CPX_STAT_ABORT_OBJ_LIM
+// CPX_STAT_ABORT_PRIM_OBJ_LIM
+// CPX_STAT_ABORT_TIME_LIM
+// CPX_STAT_ABORT_USER
+// CPX_STAT_FEASIBLE_RELAXED
+// CPX_STAT_INFEASIBLE
+// CPX_STAT_INForUNBD
+// CPX_STAT_NUM_BEST
+// CPX_STAT_OPTIMAL
+// CPX_STAT_OPTIMAL_FACE_UNBOUNDED
+// CPX_STAT_OPTIMAL_INFEAS
+// CPX_STAT_OPTIMAL_RELAXED
+// CPX_STAT_UNBOUNDED
+
     //Unimplemented
-    return OPTIMAL;
-//     int stat=  lpx_get_status(lp);
-//     switch (stat) {
-//     case LPX_UNDEF://Undefined (no solve has been run yet)
-//       return UNDEFINED;
-//       break;
-//     case LPX_NOFEAS://There is no feasible solution (primal, I guess)
-//     case LPX_INFEAS://Infeasible 
-//       return INFEASIBLE;
-//       break;
-//     case LPX_UNBND://Unbounded
-//       return INFINITE;
-//       break;
-//     case LPX_FEAS://Feasible
-//       return FEASIBLE;
-//       break;
-//     case LPX_OPT://Feasible
-//       return OPTIMAL;
-//       break;
-//     default:
-//       return UNDEFINED; //to avoid gcc warning
-//       //FIXME error
-//     }
+    int stat = CPXgetstat (env, lp);
+    switch (stat) {
+    case CPX_STAT_OPTIMAL://Optimal
+      return OPTIMAL;
+      break;
+    case CPX_STAT_INFEASIBLE://Infeasible 
+      return INFEASIBLE;
+      break;
+    case CPX_STAT_UNBOUNDED://Unbounded
+      return INFINITE;
+      break;
+    case CPX_STAT_NUM_BEST://Feasible
+      return FEASIBLE;
+      break;
+    default:
+      return UNDEFINED; //Everything else comes here
+      //FIXME error
+    }
   }
 
   LpCplex::Value LpCplex::_getPrimal(int i)
@@ -289,8 +307,10 @@
   
   LpCplex::Value LpCplex::_getPrimalValue()
   {
-    //Unimplemented
-    return 0;
+    Value objval;
+    //method = CPXgetmethod (env, lp);
+    status = CPXgetobjval (env, lp, &objval);
+    return objval;
   }
   
  

Modified: hugo/trunk/src/lemon/lp_cplex.h
==============================================================================
--- hugo/trunk/src/lemon/lp_cplex.h	(original)
+++ hugo/trunk/src/lemon/lp_cplex.h	Thu May  5 17:43:43 2005
@@ -65,8 +65,8 @@
                                const Value   * values);
     virtual void _setColLowerBound(int i, Value value);
     virtual void _setColUpperBound(int i, Value value);
-    virtual void _setRowLowerBound(int i, Value value);
-    virtual void _setRowUpperBound(int i, Value value);
+//     virtual void _setRowLowerBound(int i, Value value);
+//     virtual void _setRowUpperBound(int i, Value value);
     virtual void _setRowBounds(int i, Value lower, Value upper);
     virtual void _setObjCoeff(int i, Value obj_coef);
     virtual void _clearObj();

Modified: hugo/trunk/src/lemon/lp_glpk.cc
==============================================================================
--- hugo/trunk/src/lemon/lp_glpk.cc	(original)
+++ hugo/trunk/src/lemon/lp_glpk.cc	Thu May  5 17:43:43 2005
@@ -175,91 +175,91 @@
     }
   }
   
-  void LpGlpk::_setRowLowerBound(int i, Value lo)
-  {
-    if (lo==INF) {
-      //FIXME error
-    }
-    int b=lpx_get_row_type(lp, i);
-    double up=lpx_get_row_ub(lp, i);	
-    if (lo==-INF) {
-      switch (b) {
-      case LPX_FR:
-      case LPX_LO:
-	lpx_set_row_bnds(lp, i, LPX_FR, lo, up);
-	break;
-      case LPX_UP:
-	break;
-      case LPX_DB:
-      case LPX_FX:
-	lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
-	break;
-      default: ;
-	//FIXME error
-      }
-    } else {
-      switch (b) {
-      case LPX_FR:
-      case LPX_LO:
-	lpx_set_row_bnds(lp, i, LPX_LO, lo, up);
-	break;
-      case LPX_UP:	  
-      case LPX_DB:
-      case LPX_FX:
-	if (lo==up) 
-	  lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
-	else 
-	  lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
-	break;
-      default: ;
-	//FIXME error
-      }
-    }
-  }
+//   void LpGlpk::_setRowLowerBound(int i, Value lo)
+//   {
+//     if (lo==INF) {
+//       //FIXME error
+//     }
+//     int b=lpx_get_row_type(lp, i);
+//     double up=lpx_get_row_ub(lp, i);	
+//     if (lo==-INF) {
+//       switch (b) {
+//       case LPX_FR:
+//       case LPX_LO:
+// 	lpx_set_row_bnds(lp, i, LPX_FR, lo, up);
+// 	break;
+//       case LPX_UP:
+// 	break;
+//       case LPX_DB:
+//       case LPX_FX:
+// 	lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
+// 	break;
+//       default: ;
+// 	//FIXME error
+//       }
+//     } else {
+//       switch (b) {
+//       case LPX_FR:
+//       case LPX_LO:
+// 	lpx_set_row_bnds(lp, i, LPX_LO, lo, up);
+// 	break;
+//       case LPX_UP:	  
+//       case LPX_DB:
+//       case LPX_FX:
+// 	if (lo==up) 
+// 	  lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
+// 	else 
+// 	  lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
+// 	break;
+//       default: ;
+// 	//FIXME error
+//       }
+//     }
+//   }
   
-  void LpGlpk::_setRowUpperBound(int i, Value up)
-  {
-    if (up==-INF) {
-      //FIXME error
-    }
-    int b=lpx_get_row_type(lp, i);
-    double lo=lpx_get_row_lb(lp, i);
-    if (up==INF) {
-      switch (b) {
-      case LPX_FR:
-      case LPX_LO:
-	break;
-      case LPX_UP:
-	lpx_set_row_bnds(lp, i, LPX_FR, lo, up);
-	break;
-      case LPX_DB:
-      case LPX_FX:
-	lpx_set_row_bnds(lp, i, LPX_LO, lo, up);
-	break;
-      default: ;
-	//FIXME error
-      }
-    } else {
-      switch (b) {
-      case LPX_FR:
-	lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
-	break;
-      case LPX_UP:
-	lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
-	break;
-      case LPX_LO:
-      case LPX_DB:
-      case LPX_FX:
-	if (lo==up) 
-	  lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
-	else 
-	  lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
-	break;
-      default: ;
-	//FIXME error
-      }
-    }
-  }
+//   void LpGlpk::_setRowUpperBound(int i, Value up)
+//   {
+//     if (up==-INF) {
+//       //FIXME error
+//     }
+//     int b=lpx_get_row_type(lp, i);
+//     double lo=lpx_get_row_lb(lp, i);
+//     if (up==INF) {
+//       switch (b) {
+//       case LPX_FR:
+//       case LPX_LO:
+// 	break;
+//       case LPX_UP:
+// 	lpx_set_row_bnds(lp, i, LPX_FR, lo, up);
+// 	break;
+//       case LPX_DB:
+//       case LPX_FX:
+// 	lpx_set_row_bnds(lp, i, LPX_LO, lo, up);
+// 	break;
+//       default: ;
+// 	//FIXME error
+//       }
+//     } else {
+//       switch (b) {
+//       case LPX_FR:
+// 	lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
+// 	break;
+//       case LPX_UP:
+// 	lpx_set_row_bnds(lp, i, LPX_UP, lo, up);
+// 	break;
+//       case LPX_LO:
+//       case LPX_DB:
+//       case LPX_FX:
+// 	if (lo==up) 
+// 	  lpx_set_row_bnds(lp, i, LPX_FX, lo, up);
+// 	else 
+// 	  lpx_set_row_bnds(lp, i, LPX_DB, lo, up);
+// 	break;
+//       default: ;
+// 	//FIXME error
+//       }
+//     }
+//   }
 
   void LpGlpk::_setRowBounds(int i, Value lb, Value ub)
   {

Modified: hugo/trunk/src/lemon/lp_glpk.h
==============================================================================
--- hugo/trunk/src/lemon/lp_glpk.h	(original)
+++ hugo/trunk/src/lemon/lp_glpk.h	Thu May  5 17:43:43 2005
@@ -60,8 +60,8 @@
                                const Value   * values);
     virtual void _setColLowerBound(int i, Value value);
     virtual void _setColUpperBound(int i, Value value);
-    virtual void _setRowLowerBound(int i, Value value);
-    virtual void _setRowUpperBound(int i, Value value);
+//     virtual void _setRowLowerBound(int i, Value value);
+//     virtual void _setRowUpperBound(int i, Value value);
     virtual void _setRowBounds(int i, Value lower, Value upper);
     virtual void _setObjCoeff(int i, Value obj_coef);
     virtual void _clearObj();

Modified: hugo/trunk/src/lemon/lp_skeleton.cc
==============================================================================
--- hugo/trunk/src/lemon/lp_skeleton.cc	(original)
+++ hugo/trunk/src/lemon/lp_skeleton.cc	Thu May  5 17:43:43 2005
@@ -65,13 +65,13 @@
   {
   }
   
-  void LpSkeleton::_setRowLowerBound(int, Value)
-  {
-  }
-  
-  void LpSkeleton::_setRowUpperBound(int, Value)
-  {
-  }
+//   void LpSkeleton::_setRowLowerBound(int, Value)
+//   {
+//   }
+  
+//   void LpSkeleton::_setRowUpperBound(int, Value)
+//   {
+//   }
 
   void LpSkeleton::_setRowBounds(int, Value, Value)
   {

Modified: hugo/trunk/src/lemon/lp_skeleton.h
==============================================================================
--- hugo/trunk/src/lemon/lp_skeleton.h	(original)
+++ hugo/trunk/src/lemon/lp_skeleton.h	Thu May  5 17:43:43 2005
@@ -68,20 +68,24 @@
     virtual void _setColUpperBound(int i, Value value);
     /// \e
 
-    /// The lower bound of a linear expression (row) have to be given by an 
-    /// extended number of type Value, i.e. a finite number of type 
-    /// Value or -\ref INF.
-    virtual void _setRowLowerBound(int i, Value value);
-    /// \e
+//     /// The lower bound of a linear expression (row) have to be given by an 
+//     /// extended number of type Value, i.e. a finite number of type 
+//     /// Value or -\ref INF.
+//     virtual void _setRowLowerBound(int i, Value value);
+//     /// \e
+
+//     /// The upper bound of a linear expression (row) have to be given by an 
+//     /// extended number of type Value, i.e. a finite number of type 
+//     /// Value or \ref INF.
+//     virtual void _setRowUpperBound(int i, Value value);
 
-    /// \e
+    /// The lower and upper bound of a linear expression (row) have to be 
+    /// given by an 
+    /// extended number of type Value, i.e. a finite number of type 
+    /// Value or +/-\ref INF.
     virtual void _setRowBounds(int i, Value lb, Value ub);
     /// \e
 
-    /// The upper bound of a linear expression (row) have to be given by an 
-    /// extended number of type Value, i.e. a finite number of type 
-    /// Value or \ref INF.
-    virtual void _setRowUpperBound(int i, Value value);
 
     /// \e
     virtual void _clearObj();



More information about the Lemon-commits mailing list