[Lemon-commits] [lemon_svn] alpar: r1760 - hugo/trunk/src/lemon

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


Author: alpar
Date: Fri Apr  8 08:33:11 2005
New Revision: 1760

Modified:
   hugo/trunk/src/lemon/lp_glpk.cc
   hugo/trunk/src/lemon/lp_glpk.h

Log:
No output messages by default


Modified: hugo/trunk/src/lemon/lp_glpk.cc
==============================================================================
--- hugo/trunk/src/lemon/lp_glpk.cc	(original)
+++ hugo/trunk/src/lemon/lp_glpk.cc	Fri Apr  8 08:33:11 2005
@@ -24,169 +24,178 @@
 
 namespace lemon {
 
-    /// \e
-    int LpGlpk::_addCol() { 
-	int i=lpx_add_cols(lp, 1);
-	_setColLowerBound(i, -INF);
-	_setColUpperBound(i, INF);
-	return i;
-    }
+  LpGlpk::LpGlpk() : Parent(), 
+		     lp(lpx_create_prob()) {
+    ///\todo constrol function for this:
+    lpx_set_int_parm(lp, LPX_K_DUAL, 1);
+    messageLevel(0);
+  }
+  
+  LpGlpk::~LpGlpk() {
+    lpx_delete_prob(lp);
+  }
+  
+  int LpGlpk::_addCol() { 
+    int i=lpx_add_cols(lp, 1);
+    _setColLowerBound(i, -INF);
+    _setColUpperBound(i, INF);
+    return i;
+  }
 
-    /// \e
-    int LpGlpk::_addRow() { 
-	int i=lpx_add_rows(lp, 1);
-	return i;
-    }
+  int LpGlpk::_addRow() { 
+    int i=lpx_add_rows(lp, 1);
+    return i;
+  }
 
   
-    void LpGlpk::_setRowCoeffs(int i, 
-			       int length,
-			       const int   * indices, 
-			       const Value   * values )
-    {
-      lpx_set_mat_row(lp, i, length,
-		      const_cast<int * >(indices) ,
-		      const_cast<Value * >(values));
-    }
+  void LpGlpk::_setRowCoeffs(int i, 
+			     int length,
+			     const int   * indices, 
+			     const Value   * values )
+  {
+    lpx_set_mat_row(lp, i, length,
+		    const_cast<int * >(indices) ,
+		    const_cast<Value * >(values));
+  }
   
-    void LpGlpk::_setColCoeffs(int i, 
-			       int length,
-			       const int   * indices, 
-			       const Value   * values)
-    {
-      lpx_set_mat_col(lp, i, length,
-		      const_cast<int * >(indices),
-		      const_cast<Value * >(values));
-    }
+  void LpGlpk::_setColCoeffs(int i, 
+			     int length,
+			     const int   * indices, 
+			     const Value   * values)
+  {
+    lpx_set_mat_col(lp, i, length,
+		    const_cast<int * >(indices),
+		    const_cast<Value * >(values));
+  }
   
-    void LpGlpk::_setColLowerBound(int i, Value lo)
-    {
-      if (lo==INF) {
+  void LpGlpk::_setColLowerBound(int i, Value lo)
+  {
+    if (lo==INF) {
+      //FIXME error
+    }
+    int b=lpx_get_col_type(lp, i);
+    double up=lpx_get_col_ub(lp, i);	
+    if (lo==-INF) {
+      switch (b) {
+      case LPX_FR:
+      case LPX_LO:
+	lpx_set_col_bnds(lp, i, LPX_FR, lo, up);
+	break;
+      case LPX_UP:
+	break;
+      case LPX_DB:
+      case LPX_FX:
+	lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
+	break;
+      default: ;
 	//FIXME error
       }
-      int b=lpx_get_col_type(lp, i);
-      double up=lpx_get_col_ub(lp, i);	
-      if (lo==-INF) {
-	switch (b) {
-	case LPX_FR:
-	case LPX_LO:
-	  lpx_set_col_bnds(lp, i, LPX_FR, lo, up);
-	  break;
-	case LPX_UP:
-	  break;
-	case LPX_DB:
-	case LPX_FX:
-	  lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
-	  break;
-	default: ;
-	  //FIXME error
-	}
-      } else {
-	switch (b) {
-	case LPX_FR:
-	case LPX_LO:
-	  lpx_set_col_bnds(lp, i, LPX_LO, lo, up);
-	  break;
-	case LPX_UP:	  
-	case LPX_DB:
-	case LPX_FX:
-	  if (lo==up) 
-	    lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
-	  else 
-	    lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
-	  break;
-	default: ;
-	  //FIXME error
-	}
+    } else {
+      switch (b) {
+      case LPX_FR:
+      case LPX_LO:
+	lpx_set_col_bnds(lp, i, LPX_LO, lo, up);
+	break;
+      case LPX_UP:	  
+      case LPX_DB:
+      case LPX_FX:
+	if (lo==up) 
+	  lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
+	else 
+	  lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
+	break;
+      default: ;
+	//FIXME error
       }
-
     }
+
+  }
   
-    void LpGlpk::_setColUpperBound(int i, Value up)
-    {
-      if (up==-INF) {
+  void LpGlpk::_setColUpperBound(int i, Value up)
+  {
+    if (up==-INF) {
+      //FIXME error
+    }
+    int b=lpx_get_col_type(lp, i);
+    double lo=lpx_get_col_lb(lp, i);
+    if (up==INF) {
+      switch (b) {
+      case LPX_FR:
+      case LPX_LO:
+	break;
+      case LPX_UP:
+	lpx_set_col_bnds(lp, i, LPX_FR, lo, up);
+	break;
+      case LPX_DB:
+      case LPX_FX:
+	lpx_set_col_bnds(lp, i, LPX_LO, lo, up);
+	break;
+      default: ;
 	//FIXME error
       }
-      int b=lpx_get_col_type(lp, i);
-      double lo=lpx_get_col_lb(lp, i);
-      if (up==INF) {
-	switch (b) {
-	case LPX_FR:
-	case LPX_LO:
-	  break;
-	case LPX_UP:
-	  lpx_set_col_bnds(lp, i, LPX_FR, lo, up);
-	  break;
-	case LPX_DB:
-	case LPX_FX:
-	  lpx_set_col_bnds(lp, i, LPX_LO, lo, up);
-	  break;
-	default: ;
-	  //FIXME error
-	}
-      } else {
-	switch (b) {
-	case LPX_FR:
-	  lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
-	  break;
-	case LPX_UP:
-	  lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
-	  break;
-	case LPX_LO:
-	case LPX_DB:
-	case LPX_FX:
-	  if (lo==up) 
-	    lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
-	  else 
-	    lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
-	  break;
-	default: ;
-	  //FIXME error
-	}
+    } else {
+      switch (b) {
+      case LPX_FR:
+	lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
+	break;
+      case LPX_UP:
+	lpx_set_col_bnds(lp, i, LPX_UP, lo, up);
+	break;
+      case LPX_LO:
+      case LPX_DB:
+      case LPX_FX:
+	if (lo==up) 
+	  lpx_set_col_bnds(lp, i, LPX_FX, lo, up);
+	else 
+	  lpx_set_col_bnds(lp, i, LPX_DB, lo, up);
+	break;
+      default: ;
+	//FIXME error
       }
     }
+  }
   
-    void LpGlpk::_setRowLowerBound(int i, Value lo)
-    {
-      if (lo==INF) {
+  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
       }
-      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
-	}
+    } 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)
   {
@@ -290,12 +299,19 @@
 
   void LpGlpk::_setMax()
   {
-      lpx_set_obj_dir(lp, LPX_MAX);
-   }
+    lpx_set_obj_dir(lp, LPX_MAX);
+  }
+
   void LpGlpk::_setMin()
   {
-      lpx_set_obj_dir(lp, LPX_MIN);
-   }
+    lpx_set_obj_dir(lp, LPX_MIN);
+  }
+
+ 
+  void LpGlpk::messageLevel(int m)
+  {
+    lpx_set_int_parm(lp, LPX_K_MSGLEV, m);
+  }
 
  
 } //END OF NAMESPACE LEMON

Modified: hugo/trunk/src/lemon/lp_glpk.h
==============================================================================
--- hugo/trunk/src/lemon/lp_glpk.h	(original)
+++ hugo/trunk/src/lemon/lp_glpk.h	Fri Apr  8 08:33:11 2005
@@ -32,24 +32,16 @@
   /// 
   /// This class implements a lemon wrapper for GLPK.
   class LpGlpk : public LpSolverBase {
-
+  protected:
+    LPX* lp;
+    
   public:
-
+    
     typedef LpSolverBase Parent;
     
-    /// \e
-    LPX* lp;
-
-    /// \e
-    LpGlpk() : Parent(), 
-			lp(lpx_create_prob()) {
-      lpx_set_int_parm(lp, LPX_K_DUAL, 1);
-    }
-    /// \e
-    ~LpGlpk() {
-      lpx_delete_prob(lp);
-    }
-
+    LpGlpk();
+    ~LpGlpk();
+    
   protected:
     virtual int _addCol();
     virtual int _addRow();
@@ -68,36 +60,30 @@
     virtual void _setObjCoeff(int i, Value obj_coef);
     ///\e
     
-    ///\bug Unimplemented
+    ///\todo It should be clarified
     ///
     virtual SolveExitStatus _solve();
-    ///\e
-    
-    ///\bug Unimplemented
-    ///
     virtual Value _getPrimal(int i);
-    ///\e
-    
-    ///\bug Unimplemented
-    ///
     virtual Value _getPrimalValue();
     ///\e
     
-    ///\bug Unimplemented
+    ///\todo It should be clarified
     ///
     virtual SolutionStatus _getPrimalStatus();
-
-    ///\e
-    
-    ///\bug Unimplemented
-    ///
     virtual void _setMax();
-    ///\e
-    
-    ///\bug Unimplemented
-    ///
     virtual void _setMin();
-  
+
+  public:
+    ///Set the verbosity of the messages
+
+    ///\param m is the level of the messages output by the solver routines.
+    ///The possible values are:
+    ///- 0 --- no output (default value)
+    ///- 1 --- error messages only
+    ///- 2 --- normal output
+    ///- 3 --- full output (includes informational messages)
+    void messageLevel(int m);
+    
   };
 } //END OF NAMESPACE LEMON
 



More information about the Lemon-commits mailing list