COIN-OR::LEMON - Graph Library

source: lemon-benchmark/tests/circulation.cc @ 11:cf6519daa7fa

Last change on this file since 11:cf6519daa7fa was 11:cf6519daa7fa, checked in by Alpar Juttner <alpar@…>, 8 years ago

Refactoring and test instance in test logs

File size: 1.5 KB
Line 
1#include <benchmark_tools.h>
2#include <lemon/circulation.h>
3#include <lemon/smart_graph.h>
4#include <lemon/lgf_reader.h>
5#include <lemon/dimacs.h>
6#include <lemon/error.h>
7#include <istream>
8
9std::string test_name = "circulation";
10
11using namespace lemon;
12
13int testMain(std::istream &input)
14{
15  typedef int Value;
16 
17  SmartDigraph g;
18 
19  SmartDigraph::ArcMap<Value> lo_cap(g);
20  SmartDigraph::ArcMap<Value> up_cap(g);
21  SmartDigraph::ArcMap<Value> cost(g);
22  SmartDigraph::NodeMap<Value> sup(g);
23 
24  Timer ti;
25  try {
26    readDimacsMin(input, g, lo_cap, up_cap, cost, sup);
27  } catch (FormatError& error) {
28    std::cerr << error.what() << std::endl;
29    return 1;
30  }
31  logTime("fread",ti);
32
33  Timer tf;
34  ti.restart();
35  Circulation<SmartDigraph,
36    SmartDigraph::ArcMap<Value>,SmartDigraph::ArcMap<Value>,
37    SmartDigraph::NodeMap<Value> > circ(g,lo_cap,up_cap,sup);
38  logTime("setup",ti);
39  ti.restart();
40  bool res = circ.run();
41  logTime("alg",ti);
42  logTime("full",tf);
43  if(res)
44    {
45      std::cerr << "A feasible circulation is found\n";
46      std::cerr << "Checking...\n";
47      ti.restart();
48      bool res2 = circ.checkFlow();
49      logTime("check",ti);
50      if(res2)
51        std::cerr << "Success!\n";
52      else
53        std::cerr << "Oops!!!!\n";
54    }
55  else
56    {
57      std::cerr << "A dual solution is found\n";
58      std::cerr << "Checking...\n";
59      ti.restart();
60      bool res2 = circ.checkBarrier();
61      logTime("check",ti);
62      if(res2)
63        std::cerr << "Success!\n";
64      else
65        std::cerr << "Dual-Oops!!!!\n";
66
67    }
68}
69
Note: See TracBrowser for help on using the repository browser.