COIN-OR::LEMON - Graph Library

source: lemon-benchmark/tests/circulation.cc @ 10:d7ce0311ece2

Last change on this file since 10:d7ce0311ece2 was 10:d7ce0311ece2, checked in by Alpar Juttner <alpar@…>, 13 years ago

Some common benchmarking tools added

File size: 1.6 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
8const char test_name[] = "circulation";
9
10using namespace lemon;
11
12int testMain(int argc, char **argv)
13{
14  if(argc!=2) exit(1);
15
16  typedef int Value;
17 
18  SmartDigraph g;
19 
20  SmartDigraph::ArcMap<Value> lo_cap(g);
21  SmartDigraph::ArcMap<Value> up_cap(g);
22  SmartDigraph::ArcMap<Value> cost(g);
23  SmartDigraph::NodeMap<Value> sup(g);
24 
25  Timer ti;
26  try {
27    std::ifstream input;
28    input.open(argv[1]);
29    readDimacsMin(input, g, lo_cap, up_cap, cost, sup);
30  } catch (FormatError& error) {
31    std::cerr << error.what() << std::endl;
32    return 1;
33  }
34  logTime("file-read",ti);
35
36  Timer tf;
37  ti.restart();
38  Circulation<SmartDigraph,
39    SmartDigraph::ArcMap<Value>,SmartDigraph::ArcMap<Value>,
40    SmartDigraph::NodeMap<Value> > circ(g,lo_cap,up_cap,sup);
41  logTime("setup",ti);
42  ti.restart();
43  bool res = circ.run();
44  logTime("alg",ti);
45  logTime("full",tf);
46  if(res)
47    {
48      std::cerr << "A feasible circulation is found\n";
49      std::cerr << "Checking...\n";
50      ti.restart();
51      bool res2 = circ.checkFlow();
52      logTime("check",ti);
53      if(res2)
54        std::cerr << "Success!\n";
55      else
56        std::cerr << "Oops!!!!\n";
57    }
58  else
59    {
60      std::cerr << "A dual solution is found\n";
61      std::cerr << "Checking...\n";
62      ti.restart();
63      bool res2 = circ.checkBarrier();
64      logTime("check",ti);
65      if(res2)
66        std::cerr << "Success!\n";
67      else
68        std::cerr << "Dual-Oops!!!!\n";
69
70    }
71}
72
Note: See TracBrowser for help on using the repository browser.