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

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


Author: athos
Date: Thu Jun  9 17:03:58 2005
New Revision: 1940

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

Log:
I could not check, because: aclocal-1.7: command not found

Modified: hugo/trunk/lemon/lp_base.h
==============================================================================
--- hugo/trunk/lemon/lp_base.h	(original)
+++ hugo/trunk/lemon/lp_base.h	Thu Jun  9 17:03:58 2005
@@ -118,7 +118,7 @@
       UNSOLVED = 1
     };
       
-    ///\e
+      ///\e
     enum SolutionStatus {
       ///Feasible solution has'n been found (but may exist).
 
@@ -137,6 +137,20 @@
       ///corresponding bases)
       INFINITE = 4
     };
+
+      ///\e The type of the investigated LP problem
+      enum Problemtypes {
+	  ///Primal-dual feasible
+	  PRIMAL_DUAL_FEASIBLE = 0,
+	  ///Primal feasible dual infeasible
+	  PRIMAL_FEASIBLE_DUAL_INFEASIBLE = 1,
+	  ///Primal infeasible dual feasible
+	  PRIMAL_INFEASIBLE_DUAL_FEASIBLE = 2,
+	  ///Primal-dual infeasible
+	  PRIMAL_DUAL_INFEASIBLE = 3,
+	  ///Could not determine so far
+	  UNKNOWN = 4
+      };
       
     ///The floating point type used by the solver
     typedef double Value;
@@ -563,6 +577,11 @@
     virtual Value _getPrimal(int i) = 0;
     virtual Value _getPrimalValue() = 0;
     virtual SolutionStatus _getPrimalStatus() = 0;
+    virtual SolutionStatus _getDualStatus() = 0;
+    ///\todo This could be implemented here, too, using _getPrimalStatus() and
+    ///_getDualStatus()
+    virtual ProblemTypes _getProblemType() = 0;
+
     virtual void _setMax() = 0;
     virtual void _setMin() = 0;
     
@@ -930,11 +949,21 @@
 
     ///@{
 
-    ///\e 
+    /// The status of the primal problem (the original LP problem)
     SolutionStatus primalStatus() {
       return _getPrimalStatus();
     }
 
+    /// The status of the dual (of the original LP) problem 
+    SolutionStatus dualStatus() {
+      return _getDualStatus();
+    }
+
+    ///The type of the original LP problem
+    Problemtypes problemType() {
+      return _getProblemType();
+    }
+
     ///\e
     Value primal(Col c) { return _getPrimal(cols.floatingId(c.id)); }
 

Modified: hugo/trunk/lemon/lp_cplex.cc
==============================================================================
--- hugo/trunk/lemon/lp_cplex.cc	(original)
+++ hugo/trunk/lemon/lp_cplex.cc	Thu Jun  9 17:03:58 2005
@@ -260,6 +260,21 @@
     }
   }
 
+  LpCplex::Value LpCplex::_getPrimal(int i)
+  {
+    Value x;
+    CPXgetx (env, lp, &x, i, i);
+    return x;
+  }
+  
+  LpCplex::Value LpCplex::_getPrimalValue()
+  {
+    Value objval;
+    //method = CPXgetmethod (env, lp);
+    status = CPXgetobjval (env, lp, &objval);
+    return objval;
+  }
+  
 
 //7.5-os cplex statusai (Vigyazat: a 9.0-asei masok!)
 // This table lists the statuses, returned by the CPXgetstat() routine, for solutions to LP problems or mixed integer problems. If no solution exists, the return value is zero.
@@ -377,22 +392,24 @@
       //FIXME error
     }
 
-  LpCplex::Value LpCplex::_getPrimal(int i)
-  {
-    Value x;
-    CPXgetx (env, lp, &x, i, i);
-    return x;
-  }
-  
-  LpCplex::Value LpCplex::_getPrimalValue()
-  {
-    Value objval;
-    //method = CPXgetmethod (env, lp);
-    status = CPXgetobjval (env, lp, &objval);
-    return objval;
-  }
-  
  
+  LpCplex::ProblemTypes LpCplex::_getProblemType()
+  {
+    int stat = CPXgetstat (env, lp);
+    switch (stat) {
+    case CPX_OPTIMAL://Optimal
+	return PRIMAL_DUAL_FEASIBLE;
+    case CPX_UNBOUNDED:
+ 	return PRIMAL_FEASIBLE_DUAL_INFEASIBLE;
+// 	return PRIMAL_INFEASIBLE_DUAL_FEASIBLE;
+// 	return PRIMAL_DUAL_INFEASIBLE;
+
+//Seems to be that this is all we can say for sure
+    default:
+	//In all other cases
+	return UNKNOWN;
+      //FIXME error
+    }
 
 
   void LpCplex::_setMax()

Modified: hugo/trunk/lemon/lp_cplex.h
==============================================================================
--- hugo/trunk/lemon/lp_cplex.h	(original)
+++ hugo/trunk/lemon/lp_cplex.h	Thu Jun  9 17:03:58 2005
@@ -75,34 +75,19 @@
     virtual void _clearObj();
     ///\e
     
-    ///\bug Unimplemented
-    ///
     virtual SolveExitStatus _solve();
-    ///\e
 
-    ///\bug Unimplemented
-    ///
     virtual Value _getPrimal(int i);
-    ///\e
+
     
-    ///\bug Unimplemented
-    ///
     virtual Value _getPrimalValue();
-    ///\e
     
-    ///\bug Unimplemented
-    ///
     virtual SolutionStatus _getPrimalStatus();
+    virtual SolutionStatus _getDualStatus();
+    virtual ProblemTypes _getProblemType();
 
-    ///\e
     
-    ///\bug Unimplemented
-    ///
     virtual void _setMax();
-    ///\e
-    
-    ///\bug Unimplemented
-    ///
     virtual void _setMin();
 
   };

Modified: hugo/trunk/lemon/lp_glpk.cc
==============================================================================
--- hugo/trunk/lemon/lp_glpk.cc	(original)
+++ hugo/trunk/lemon/lp_glpk.cc	Thu Jun  9 17:03:58 2005
@@ -444,7 +444,7 @@
     case LPX_D_UNDEF://Undefined (no solve has been run yet)
       return UNDEFINED;
     case LPX_D_NOFEAS://There is no feasible solution (primal, I guess)
-    case LPX_D_INFEAS://Infeasible 
+//    case LPX_D_INFEAS://Infeasible 
       return INFEASIBLE;
     case LPX_FEAS://Feasible    
       int stat2=  lpx_get_prim_stat(lp);
@@ -464,30 +464,19 @@
 
   LpGlpk::ProblemTypes LpGlpk::_problemType()
   {
-    int stat=  lpx_get_status(lp);
+      //int stat=  lpx_get_status(lp);
     int statp=  lpx_get_prim_stat(lp);
     int statd=  lpx_get_dual_stat(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
-    }
+    if (statp==LP_P_FEAS && statd==LP_D_FEAS)
+	return PRIMAL_DUAL_FEASIBLE;
+    if (statp==LP_P_FEAS && statd==LP_D_NOFEAS)
+	return PRIMAL_FEASIBLE_DUAL_INFEASIBLE;
+    if (statp==LP_P_NOFEAS && statd==LP_D_FEAS)
+	return PRIMAL_INFEASIBLE_DUAL_FEASIBLE;
+    if (statp==LP_P_NOFEAS && statd==LP_D_NOFEAS)
+	return PRIMAL_DUAL_INFEASIBLE;
+    //In all other cases
+    return UNKNOWN;
   }
 
   void LpGlpk::_setMax()

Modified: hugo/trunk/lemon/lp_glpk.h
==============================================================================
--- hugo/trunk/lemon/lp_glpk.h	(original)
+++ hugo/trunk/lemon/lp_glpk.h	Thu Jun  9 17:03:58 2005
@@ -85,6 +85,9 @@
     ///\todo It should be clarified
     ///
     virtual SolutionStatus _getPrimalStatus();
+    virtual SolutionStatus _getDualStatus();
+    virtual ProblemTypes _getProblemType();
+
     virtual void _setMax();
     virtual void _setMin();
 

Modified: hugo/trunk/lemon/lp_skeleton.cc
==============================================================================
--- hugo/trunk/lemon/lp_skeleton.cc	(original)
+++ hugo/trunk/lemon/lp_skeleton.cc	Thu Jun  9 17:03:58 2005
@@ -120,7 +120,17 @@
   
   LpSkeleton::SolutionStatus LpSkeleton::_getPrimalStatus()
   {
-    return OPTIMAL;
+    return UNDEFINED;
+  }
+
+  LpSkeleton::SolutionStatus LpSkeleton::_getDualStatus()
+  {
+    return UNDEFINED;
+  }
+
+  LpSkeleton::ProblemTypes LpSkeleton::_getProblemType()
+  {
+    return UNKNOWN;
   }
   
 } //namespace lemon

Modified: hugo/trunk/lemon/lp_skeleton.h
==============================================================================
--- hugo/trunk/lemon/lp_skeleton.h	(original)
+++ hugo/trunk/lemon/lp_skeleton.h	Thu Jun  9 17:03:58 2005
@@ -118,6 +118,13 @@
     ///
     virtual SolutionStatus _getPrimalStatus();
 
+    ////e
+    virtual SolutionStatus _getDualStatus();
+
+
+    ///\e
+    virtual ProblemTypes _getProblemType();
+
     ///\e
     virtual void _setMax();
     ///\e



More information about the Lemon-commits mailing list