test/lp_test.cc
changeset 1780 9f052750753f
parent 1542 0219ee65ffcc
child 1797 91b8b9cea2f7
equal deleted inserted replaced
8:823080d38fde 9:a5994237020a
     1 #include<lemon/lp_skeleton.h>
     1 #include <sstream>
       
     2 #include <lemon/lp_skeleton.h>
     2 #include "test_tools.h"
     3 #include "test_tools.h"
     3 
     4 
     4 
     5 
     5 #ifdef HAVE_CONFIG_H
     6 #ifdef HAVE_CONFIG_H
     6 #include <config.h>
     7 #include <config.h>
   182   
   183   
   183 #endif
   184 #endif
   184 }
   185 }
   185 
   186 
   186 void solveAndCheck(LpSolverBase& lp, LpSolverBase::SolutionStatus stat, 
   187 void solveAndCheck(LpSolverBase& lp, LpSolverBase::SolutionStatus stat, 
   187 		   double exp_opt){
   188 		   double exp_opt) {
       
   189   using std::string;
   188   lp.solve();
   190   lp.solve();
   189   //int decimal,sign;
   191   //int decimal,sign;
   190   std::string buf1;
   192   std::ostringstream buf;
       
   193   buf << "Primalstatus should be: " << int(stat);
       
   194 
   191   //  itoa(stat,buf1, 10);
   195   //  itoa(stat,buf1, 10);
   192   check(lp.primalStatus()==stat,"Primalstatus should be "+buf1);
   196   check(lp.primalStatus()==stat, buf.str());
   193     
   197 
   194   if (stat ==  LpSolverBase::OPTIMAL){
   198   if (stat ==  LpSolverBase::OPTIMAL) {
   195     check(std::abs(lp.primalValue()-exp_opt)<1e-3,
   199     std::ostringstream buf;
   196 	  "Wrong optimal value: the right optimum is ");
   200     buf << "Wrong optimal value: the right optimum is " << exp_opt; 
       
   201     check(std::abs(lp.primalValue()-exp_opt) < 1e-3, buf.str());
   197     //+ecvt(exp_opt,2)
   202     //+ecvt(exp_opt,2)
   198   }
   203   }
   199 }
   204 }
   200  
   205  
   201 void aTest(LpSolverBase & lp)
   206 void aTest(LpSolverBase & lp)