test/lp_test.cc
changeset 1025 c8fa41fcc4a7
parent 957 2eebc8f7dca5
child 1064 fc3854d936f7
equal deleted inserted replaced
13:59d5795cf70b 14:02feec8ca169
    39 #include <lemon/clp.h>
    39 #include <lemon/clp.h>
    40 #endif
    40 #endif
    41 
    41 
    42 using namespace lemon;
    42 using namespace lemon;
    43 
    43 
       
    44 int countCols(LpBase & lp) {
       
    45   int count=0;
       
    46   for (LpBase::ColIt c(lp); c!=INVALID; ++c) ++count;
       
    47   return count;
       
    48 }
       
    49 
       
    50 int countRows(LpBase & lp) {
       
    51   int count=0;
       
    52   for (LpBase::RowIt r(lp); r!=INVALID; ++r) ++count;
       
    53   return count;
       
    54 }
       
    55 
       
    56 
    44 void lpTest(LpSolver& lp)
    57 void lpTest(LpSolver& lp)
    45 {
    58 {
    46 
    59 
    47   typedef LpSolver LP;
    60   typedef LpSolver LP;
       
    61 
       
    62   // Test LpBase::clear()
       
    63   check(countRows(lp)==0, "Wrong number of rows");
       
    64   check(countCols(lp)==0, "Wrong number of cols");
       
    65   lp.addCol(); lp.addRow(); lp.addRow();
       
    66   check(countRows(lp)==2, "Wrong number of rows");
       
    67   check(countCols(lp)==1, "Wrong number of cols");
       
    68   lp.clear();
       
    69   check(countRows(lp)==0, "Wrong number of rows");
       
    70   check(countCols(lp)==0, "Wrong number of cols");
       
    71   lp.addCol(); lp.addCol(); lp.addCol(); lp.addRow();
       
    72   check(countRows(lp)==1, "Wrong number of rows");
       
    73   check(countCols(lp)==3, "Wrong number of cols");
       
    74   lp.clear();
    48 
    75 
    49   std::vector<LP::Col> x(10);
    76   std::vector<LP::Col> x(10);
    50   //  for(int i=0;i<10;i++) x.push_back(lp.addCol());
    77   //  for(int i=0;i<10;i++) x.push_back(lp.addCol());
    51   lp.addColSet(x);
    78   lp.addColSet(x);
    52   lp.colLowerBound(x,1);
    79   lp.colLowerBound(x,1);