test/lp_test.cc
changeset 2292 38d985e82205
parent 1956 a055123339d5
child 2314 dbbd5c514163
equal deleted inserted replaced
12:8ec464bc426d 13:1b16ec12af4a
    17  */
    17  */
    18 
    18 
    19 #include <sstream>
    19 #include <sstream>
    20 #include <lemon/lp_skeleton.h>
    20 #include <lemon/lp_skeleton.h>
    21 #include "test_tools.h"
    21 #include "test_tools.h"
    22 
    22 #include <lemon/tolerance.h>
    23 
    23 
    24 #ifdef HAVE_CONFIG_H
    24 #ifdef HAVE_CONFIG_H
    25 #include <config.h>
    25 #include <config.h>
    26 #endif
    26 #endif
    27 
    27 
   173     lp.addRow(LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23);
   173     lp.addRow(LP::INF,3.0*(x[1]+x[2]*2-5*x[3]+12-x[4]/3)+2*x[4]-4,23);
   174     
   174     
   175     lp.addRow(x[1]+x[3]<=x[5]-3);
   175     lp.addRow(x[1]+x[3]<=x[5]-3);
   176     lp.addRow(-7<=x[1]+x[3]-12<=3);
   176     lp.addRow(-7<=x[1]+x[3]-12<=3);
   177     lp.addRow(x[1]<=x[5]);
   177     lp.addRow(x[1]<=x[5]);
       
   178 
       
   179     std::ostringstream buf;
       
   180 
       
   181 
       
   182     //Checking the simplify function
       
   183 
       
   184 //     //How to check the simplify function? A map gives no information
       
   185 //     //on the question whether a given key is or is not stored in it, or
       
   186 //     //it does?
       
   187 //   Yes, it does, using the find() function.
       
   188     e=((p1+p2)+(p1-p2));
       
   189     e.simplify();
       
   190     buf << "Coeff. of p2 should be 0";
       
   191     //    std::cout<<e[p1]<<e[p2]<<e[p3]<<std::endl;
       
   192     check(e.find(p2)==e.end(), buf.str());
       
   193 
       
   194      
       
   195 
       
   196 
       
   197     e=((p1+p2)+(p1-0.99*p2));
       
   198     double tolerance=0.001;
       
   199     e.simplify(tolerance);
       
   200     buf << "Coeff. of p2 should be 0.01";
       
   201     check(e[p2]>0, buf.str());
       
   202     
       
   203     tolerance=0.02;
       
   204     e.simplify(tolerance);
       
   205     buf << "Coeff. of p2 should be 0";
       
   206     check(e.find(p2)==e.end(), buf.str());
       
   207     
       
   208 
   178   }
   209   }
   179   
   210   
   180   {
   211   {
   181     LP::DualExpr e,f,g;
   212     LP::DualExpr e,f,g;
   182     LP::Row p1,p2,p3,p4,p5;
   213     LP::Row p1,p2,p3,p4,p5;