test/mip_test.cc
changeset 2463 19651a04d056
parent 2391 14a343be7a5a
child 2553 bfced05fa852
equal deleted inserted replaced
10:178849d8b05e 11:39d7c771c25a
    39   using std::string;
    39   using std::string;
    40 
    40 
    41   lp.solve();
    41   lp.solve();
    42   //int decimal,sign;
    42   //int decimal,sign;
    43   std::ostringstream buf;
    43   std::ostringstream buf;
    44   buf << "Primalstatus should be: " << int(stat)<<" and it is "<<int(lp.primalStatus());
    44   buf << "Primalstatus should be: " << int(stat)<<" and it is "<<int(lp.mipStatus());
    45 
    45 
    46 
    46 
    47   //  itoa(stat,buf1, 10);
    47   //  itoa(stat,buf1, 10);
    48   check(lp.mipStatus()==stat, buf.str());
    48   check(lp.mipStatus()==stat, buf.str());
    49 
    49 
    79   mip.solve();
    79   mip.solve();
    80   //Check it out!
    80   //Check it out!
    81 
    81 
    82   //Constraints
    82   //Constraints
    83   mip.addRow(2*x1+x2 <=2);  
    83   mip.addRow(2*x1+x2 <=2);  
    84   mip.addRow(x1-2*x2 <=0);  
    84   mip.addRow(x1-2*x2 <=0);
    85 
    85 
    86   //Nonnegativity of the variable x1
    86   //Nonnegativity of the variable x1
    87   mip.colLowerBound(x1, 0);
    87   mip.colLowerBound(x1, 0);
    88 
       
    89 
       
    90 
    88 
    91   //Maximization of x1
    89   //Maximization of x1
    92   //over the triangle with vertices (0,0),(4/5,2/5),(0,2)
    90   //over the triangle with vertices (0,0),(4/5,2/5),(0,2)
    93   double expected_opt=4.0/5.0;
    91   double expected_opt=4.0/5.0;
    94   solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt);
    92   solveAndCheck(mip, MipSolverBase::OPTIMAL, expected_opt);