[Lemon-commits] [lemon_svn] alpar: r1965 - in hugo/trunk: lemon test

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


Author: alpar
Date: Tue Jun 14 15:55:28 2005
New Revision: 1965

Modified:
   hugo/trunk/lemon/lp_base.h
   hugo/trunk/test/lp_test.cc

Log:
- lp_test is made working.
- some more 'const' for those who like them..

Modified: hugo/trunk/lemon/lp_base.h
==============================================================================
--- hugo/trunk/lemon/lp_base.h	(original)
+++ hugo/trunk/lemon/lp_base.h	Tue Jun 14 15:55:28 2005
@@ -47,12 +47,12 @@
 
     ///\param n is a floating id
     ///\return the corresponding fix id
-    int fixId(int n) {return cross[n];}
+    int fixId(int n) const {return cross[n];}
     ///Convert a fix id to a floating one
 
     ///\param n is a fix id
     ///\return the corresponding floating id
-    int floatingId(int n) { return index[n];}
+    int floatingId(int n) const { return index[n];}
     ///Add a new floating id.
 
     ///\param n is a floating id

Modified: hugo/trunk/test/lp_test.cc
==============================================================================
--- hugo/trunk/test/lp_test.cc	(original)
+++ hugo/trunk/test/lp_test.cc	Tue Jun 14 15:55:28 2005
@@ -40,6 +40,12 @@
     LP::Col p1,p2,p3,p4,p5;
     LP::Constr c;
     
+    p1=lp.addCol();
+    p2=lp.addCol();
+    p3=lp.addCol();
+    p4=lp.addCol();
+    p5=lp.addCol();
+    
     e[p1]=2;
     e.constComp()=12;
     e[p1]+=2;
@@ -199,11 +205,15 @@
   lp.max();
   lp.solve();
 
-
+  double opt=122.0/9.0;
+  
   if (lp.primalStatus()==LpSolverBase::OPTIMAL){
-    printf("Z = %g; x1 = %g; x2 = %g\n", 
-	   lp.primalValue(), 
-	   lp.primal(x1), lp.primal(x2));
+    std::cout<< "Z = "<<lp.primalValue()
+	     << " (error = " << lp.primalValue()-opt
+	     << "); x1 = "<<lp.primal(x1)
+	     << "; x2 = "<<lp.primal(x2)
+	     <<std::endl;
+    
   }
   else{
     std::cout<<"Optimal solution not found!"<<std::endl;
@@ -211,8 +221,8 @@
 
   check(lp.primalStatus()==LpSolverBase::OPTIMAL,"Primalstatus should be OPTIMAL");
 
-  double opt=123/9;
-  check(lp.primalValue()==opt,"The optimum value is 122/9");
+  check(std::abs(lp.primalValue()-opt)<1e-3,
+	"Wrong optimal value: the right optimum is 122/9 (13.555555...)");
 
 
 }
@@ -224,9 +234,9 @@
   lpTest(lp_skel);
 
 #ifdef HAVE_GLPK
-  LpGlpk lp_glpk;
-  lpTest(lp_glpk);
-  aTest(lp_glpk);
+  LpGlpk lp_glpk1,lp_glpk2;
+  lpTest(lp_glpk1);
+  aTest(lp_glpk2);
 #endif
 
 #ifdef HAVE_CPLEX



More information about the Lemon-commits mailing list