COIN-OR::LEMON - Graph Library

Changeset 2264:90c66dc93ca4 in lemon-0.x


Ignore:
Timestamp:
10/27/06 14:39:13 (13 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3022
Message:

A little test was born for Expr::simplify().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/lp_test.cc

    r1956 r2264  
    2020#include <lemon/lp_skeleton.h>
    2121#include "test_tools.h"
    22 
     22#include <lemon/tolerance.h>
    2323
    2424#ifdef HAVE_CONFIG_H
     
    176176    lp.addRow(-7<=x[1]+x[3]-12<=3);
    177177    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
    178209  }
    179210 
Note: See TracChangeset for help on using the changeset viewer.