test/lp_test.cc
changeset 2605 852361980706
parent 2571 f5c6e63f51d1
child 2637 bafe730864da
     1.1 --- a/test/lp_test.cc	Tue Apr 08 15:16:16 2008 +0000
     1.2 +++ b/test/lp_test.cc	Tue Apr 08 16:01:28 2008 +0000
     1.3 @@ -20,6 +20,7 @@
     1.4  #include <lemon/lp_skeleton.h>
     1.5  #include "test_tools.h"
     1.6  #include <lemon/tolerance.h>
     1.7 +#include <lemon/lp_utils.h>
     1.8  
     1.9  #ifdef HAVE_CONFIG_H
    1.10  #include <lemon/config.h>
    1.11 @@ -216,7 +217,8 @@
    1.12    
    1.13    {
    1.14      LP::DualExpr e,f,g;
    1.15 -    LP::Row p1,p2,p3,p4,p5;
    1.16 +    LP::Row p1 = INVALID, p2 = INVALID, p3 = INVALID, 
    1.17 +      p4 = INVALID, p5 = INVALID;
    1.18      
    1.19      e[p1]=2;
    1.20      e[p1]+=2;
    1.21 @@ -295,7 +297,6 @@
    1.22  
    1.23    lp.max();
    1.24  
    1.25 -
    1.26    //Testing the problem retrieving routines
    1.27    check(lp.objCoeff(x1)==1,"First term should be 1 in the obj function!");
    1.28    check(lp.isMax(),"This is a maximization!");
    1.29 @@ -307,7 +308,39 @@
    1.30    lp.getRowBounds(upright,lb,ub);
    1.31    check(  lb==-LpSolverBase::INF,"The lower bound for the first row should be -infty.");
    1.32    check(  ub==1,"The upper bound for the first row should be 1.");
    1.33 +  LpSolverBase::Expr e = lp.row(upright);
    1.34 +  check(  e.size() == 2, "The row retrieval gives back wrong expression.");
    1.35 +  check(  e[x1] == 1, "The first coefficient should 1.");
    1.36 +  check(  e[x2] == 1, "The second coefficient should 1.");
    1.37  
    1.38 +  LpSolverBase::DualExpr de = lp.col(x1);
    1.39 +  check(  de.size() == 4, "The col retrieval gives back wrong expression.");
    1.40 +  check(  de[upright] == 1, "The first coefficient should 1.");
    1.41 +
    1.42 +  LpSolverBase* clp = lp.copyLp();
    1.43 +
    1.44 +  //Testing the problem retrieving routines
    1.45 +  check(clp->objCoeff(x1)==1,"First term should be 1 in the obj function!");
    1.46 +  check(clp->isMax(),"This is a maximization!");
    1.47 +  check(clp->coeff(upright,x1)==1,"The coefficient in question is 1!");
    1.48 +  //  std::cout<<lp.colLowerBound(x1)<<std::endl;
    1.49 +  check(  clp->colLowerBound(x1)==0,"The lower bound for variable x1 should be 0.");
    1.50 +  std::cerr << clp->colUpperBound(x1) << std::endl;
    1.51 +  check(  clp->colUpperBound(x1)==LpSolverBase::INF,"The upper bound for variable x1 should be infty.");
    1.52 +
    1.53 +  clp->getRowBounds(upright,lb,ub);
    1.54 +  check(  lb==-LpSolverBase::INF,"The lower bound for the first row should be -infty.");
    1.55 +  check(  ub==1,"The upper bound for the first row should be 1.");
    1.56 +  e = clp->row(upright);
    1.57 +  check(  e.size() == 2, "The row retrieval gives back wrong expression.");
    1.58 +  check(  e[x1] == 1, "The first coefficient should 1.");
    1.59 +  check(  e[x2] == 1, "The second coefficient should 1.");
    1.60 +
    1.61 +  de = clp->col(x1);
    1.62 +  check(  de.size() == 4, "The col retrieval gives back wrong expression.");
    1.63 +  check(  de[upright] == 1, "The first coefficient should 1.");
    1.64 +  
    1.65 +  delete clp;
    1.66  
    1.67    //Maximization of x1+x2
    1.68    //over the triangle with vertices (0,0) (0,1) (1,0)
    1.69 @@ -338,6 +371,7 @@
    1.70    lp.min();
    1.71    check(lp.primalStatus()==LpSolverBase::UNDEFINED,"Primalstatus should be UNDEFINED");
    1.72  
    1.73 +
    1.74  //   lp.solve();
    1.75  //   if (lp.primalStatus()==LpSolverBase::OPTIMAL){
    1.76  //     std::cout<< "Z = "<<lp.primalValue()