[Lemon-commits] [lemon_svn] athos: r2862 - in hugo/trunk: demo lemon

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 21:50:52 CET 2006


Author: athos
Date: Mon Jul 17 13:56:17 2006
New Revision: 2862

Modified:
   hugo/trunk/demo/mip_demo.cc
   hugo/trunk/lemon/lp_base.h
   hugo/trunk/lemon/mip_glpk.cc
   hugo/trunk/lemon/mip_glpk.h

Log:
Modifications to the interface: colType() functions, though I left the old integer() functions, too.

Modified: hugo/trunk/demo/mip_demo.cc
==============================================================================
--- hugo/trunk/demo/mip_demo.cc	(original)
+++ hugo/trunk/demo/mip_demo.cc	Mon Jul 17 13:56:17 2006
@@ -9,7 +9,7 @@
 
    Mip ilp;
 
-    
+
   typedef Mip::Row Row;
   typedef Mip::Col Col;
   

Modified: hugo/trunk/lemon/lp_base.h
==============================================================================
--- hugo/trunk/lemon/lp_base.h	(original)
+++ hugo/trunk/lemon/lp_base.h	Mon Jul 17 13:56:17 2006
@@ -1158,31 +1158,58 @@
   };  
 
 
-  ///Common base class for ILP solvers
+  ///Common base class for MIP solvers
   ///\todo Much more docs
   ///\ingroup gen_opt_group
   class MipSolverBase : virtual public LpSolverBase{
   public:
 
-    ///Set the type of the given Col to integer or remove that property.
+    ///Possible variable (coloumn) types (e.g. real, integer, binary etc.)
+    enum ColTypes {
+      ///Continuous variable
+      REAL = 0,
+      ///Integer variable
+      INTEGER = 1
+      ///\todo No support for other types yet.
+    };
+
+    ///Sets the type of the given coloumn to the given type
     ///
-    ///Set the type of the given Col to integer or remove that property.
-    void integer(Col c, bool enable) {
-      _integer(cols.floatingId(c.id),enable);
+    ///Sets the type of the given coloumn to the given type.
+    void colType(Col c, ColTypes col_type) {
+      _colType(cols.floatingId(c.id),col_type);
     }
 
     ///Gives back the type of the column.
     ///
     ///Gives back the type of the column.
+    ColTypes colType(Col c){
+      return _colType(cols.floatingId(c.id));
+    }
+
+    ///Sets the type of the given Col to integer or remove that property.
+    ///
+    ///Sets the type of the given Col to integer or remove that property.
+    void integer(Col c, bool enable) {
+      if (enable)
+	colType(c,INTEGER);
+      else
+	colType(c,REAL);
+    }
+
+    ///Gives back whether the type of the column is integer or not.
+    ///
+    ///Gives back the type of the column.
     ///\return true if the column has integer type and false if not.
     bool integer(Col c){
-      return _integer(cols.floatingId(c.id));
+      return (colType(c)==INTEGER);
     }
 
   protected:
 
-    virtual bool _integer(int col) = 0;
-    virtual void _integer(int col, bool enable) = 0;
+    virtual ColTypes _colType(int col) = 0;
+    virtual void _colType(int col, ColTypes col_type) = 0;
+
   };
   
   ///\relates LpSolverBase::Expr

Modified: hugo/trunk/lemon/mip_glpk.cc
==============================================================================
--- hugo/trunk/lemon/mip_glpk.cc	(original)
+++ hugo/trunk/lemon/mip_glpk.cc	Mon Jul 17 13:56:17 2006
@@ -29,20 +29,30 @@
   MipGlpk::MipGlpk() {
     lpx_set_class(lp,LPX_MIP);
   }
-  
-  void MipGlpk::_integer(int i, bool enable){
-    if(enable){
-      lpx_set_col_kind(lp,i,LPX_IV);
-    }else{
-      lpx_set_col_kind(lp,i,LPX_CV);
+
+  void MipGlpk::_colType(int i, ColTypes col_type){
+    switch (col_type){
+      case INTEGER:
+	lpx_set_col_kind(lp,i,LPX_IV);
+	break;
+      case REAL:
+	lpx_set_col_kind(lp,i,LPX_CV);
+	break;
+      default:
+        //FIXME problem
     }
   }
   
-  bool MipGlpk::_integer(int i){
-    if(LPX_IV == lpx_get_col_kind(lp,i)){
-      return true;
+  ColTypes MipGlpk::_colType(int i){
+    switch (lpx_get_col_kind(lp,i)){
+    case LPX_IV:
+      return INTEGER;//Or binary
+    case LPX_CV:
+      return REAL;
+    default:
+      return REAL;//Error!
     }
-    return false;
+    
   }
   
   LpGlpk::SolveExitStatus MipGlpk::_solve(){

Modified: hugo/trunk/lemon/mip_glpk.h
==============================================================================
--- hugo/trunk/lemon/mip_glpk.h	(original)
+++ hugo/trunk/lemon/mip_glpk.h	Mon Jul 17 13:56:17 2006
@@ -45,8 +45,8 @@
     
   protected:
   
-    virtual void _integer(int c, bool enable);
-    virtual bool _integer(int c);
+    virtual ColTypes _colType(int col);
+    virtual void _colType(int col, ColTypes col_type);
     
     virtual LpGlpk::SolveExitStatus _solve();
     virtual ParentLp::Value _getPrimal(int i);



More information about the Lemon-commits mailing list