src/work/athos/min_cost_flow.cc
changeset 736 ba76a7f56b23
parent 662 0155001b6f65
child 921 818510fa3d99
equal deleted inserted replaced
2:283813f31a46 3:303529274ce5
     9 using namespace hugo;
     9 using namespace hugo;
    10 
    10 
    11 
    11 
    12 
    12 
    13 bool passed = true;
    13 bool passed = true;
    14 /*
    14 
    15 void check(bool rc, char *msg="") {
    15 void check(bool rc, char *msg="") {
    16   passed = passed && rc;
    16   passed = passed && rc;
    17   if(!rc) {
    17   if(!rc) {
    18     std::cerr << "Test failed! ("<< msg << ")" << std::endl; \
    18     std::cerr << "Test failed! ("<< msg << ")" << std::endl; \
    19  
    19  
    20 
    20 
    21   }
    21   }
    22 }
    22 }
    23 */
    23 
    24 
    24 
    25 
    25 
    26 int main()
    26 int main()
    27 {
    27 {
    28 
    28 
    88   MinCostFlow< ListGraph, ListGraph::EdgeMap<int>, ListGraph::NodeMap<int> >
    88   MinCostFlow< ListGraph, ListGraph::EdgeMap<int>, ListGraph::NodeMap<int> >
    89     min_cost_flow_test(graph, cost, supply_demand);
    89     min_cost_flow_test(graph, cost, supply_demand);
    90 
    90 
    91   min_cost_flow_test.run();
    91   min_cost_flow_test.run();
    92   //int k=1;
    92   //int k=1;
       
    93   check(min_cost_flow_test.checkOptimality(), "Is the primal-dual solution pair really optimal?");
    93 
    94 
    94   /*
    95   /*
    95   check(  min_cost_flow_test.run(s,t,k) == 1 && min_cost_flow_test.totalLength() == 19,"One path, total cost should be 19");
    96   check(  min_cost_flow_test.run(s,t,k) == 1 && min_cost_flow_test.totalLength() == 19,"One path, total cost should be 19");
    96 
    97 
    97   check(min_cost_flow_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
    98   check(min_cost_flow_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
   107 
   108 
   108   check(  min_cost_flow_test.run(s,t,k) == 3 && min_cost_flow_test.totalLength() == 64,"Three paths, total cost should be 64");
   109   check(  min_cost_flow_test.run(s,t,k) == 3 && min_cost_flow_test.totalLength() == 64,"Three paths, total cost should be 64");
   109 
   110 
   110   check(min_cost_flow_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
   111   check(min_cost_flow_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
   111 
   112 
   112 
   113   */
   113   cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
   114   cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
   114        << endl;
   115        << endl;
   115 
   116 
   116   return passed ? 0 : 1;
   117   return passed ? 0 : 1;
   117   */
   118   
   118 }
   119 }