|
1 #include <benchmark_tools.h> |
1 #include <lemon/circulation.h> |
2 #include <lemon/circulation.h> |
2 #include <lemon/smart_graph.h> |
3 #include <lemon/smart_graph.h> |
3 #include <lemon/lgf_reader.h> |
4 #include <lemon/lgf_reader.h> |
4 #include <lemon/dimacs.h> |
5 #include <lemon/dimacs.h> |
5 #include <lemon/time_measure.h> |
|
6 #include <lemon/error.h> |
6 #include <lemon/error.h> |
7 |
7 |
8 const char test_name[] = "circulation"; |
8 const char test_name[] = "circulation"; |
9 |
9 |
10 using namespace lemon; |
10 using namespace lemon; |
11 |
11 |
12 int main(int argc, char **argv) |
12 int testMain(int argc, char **argv) |
13 { |
13 { |
14 if(argc!=2) exit(1); |
14 if(argc!=2) exit(1); |
15 |
15 |
16 typedef int Value; |
16 typedef int Value; |
17 |
17 |
29 readDimacsMin(input, g, lo_cap, up_cap, cost, sup); |
29 readDimacsMin(input, g, lo_cap, up_cap, cost, sup); |
30 } catch (FormatError& error) { |
30 } catch (FormatError& error) { |
31 std::cerr << error.what() << std::endl; |
31 std::cerr << error.what() << std::endl; |
32 return 1; |
32 return 1; |
33 } |
33 } |
34 std::cerr << "Read the file: " << ti << '\n'; |
34 logTime("file-read",ti); |
|
35 |
|
36 Timer tf; |
35 ti.restart(); |
37 ti.restart(); |
36 |
|
37 Circulation<SmartDigraph, |
38 Circulation<SmartDigraph, |
38 SmartDigraph::ArcMap<Value>,SmartDigraph::ArcMap<Value>, |
39 SmartDigraph::ArcMap<Value>,SmartDigraph::ArcMap<Value>, |
39 SmartDigraph::NodeMap<Value> > circ(g,lo_cap,up_cap,sup); |
40 SmartDigraph::NodeMap<Value> > circ(g,lo_cap,up_cap,sup); |
40 std::cerr << "Setup Circulation class: " << ti << '\n'; |
41 logTime("setup",ti); |
41 ti.restart(); |
42 ti.restart(); |
42 bool res = circ.run(); |
43 bool res = circ.run(); |
|
44 logTime("alg",ti); |
|
45 logTime("full",tf); |
43 if(res) |
46 if(res) |
44 { |
47 { |
45 std::cerr << "A feasible circulation is found: " << ti << "\n"; |
48 std::cerr << "A feasible circulation is found\n"; |
|
49 std::cerr << "Checking...\n"; |
46 ti.restart(); |
50 ti.restart(); |
47 bool res2 = circ.checkFlow(); |
51 bool res2 = circ.checkFlow(); |
48 std::cerr << "Checked in time " << ti << "\n"; |
52 logTime("check",ti); |
49 if(res2) |
53 if(res2) |
50 std::cerr << "Success!\nn"; |
54 std::cerr << "Success!\n"; |
51 else |
55 else |
52 std::cerr << "Oops!!!!\n\n"; |
56 std::cerr << "Oops!!!!\n"; |
53 } |
57 } |
54 else |
58 else |
55 { |
59 { |
56 std::cerr << "A dual solution is found: " << ti << "\n"; |
60 std::cerr << "A dual solution is found\n"; |
|
61 std::cerr << "Checking...\n"; |
57 ti.restart(); |
62 ti.restart(); |
58 bool res2 = circ.checkBarrier(); |
63 bool res2 = circ.checkBarrier(); |
59 std::cerr << "Checked in time " << ti << "\n"; |
64 logTime("check",ti); |
60 if(res2) |
65 if(res2) |
61 std::cerr << "Success!\nn"; |
66 std::cerr << "Success!\n"; |
62 else |
67 else |
63 std::cerr << "Dual-Oops!!!!\n\n"; |
68 std::cerr << "Dual-Oops!!!!\n"; |
64 |
69 |
65 } |
70 } |
66 } |
71 } |
67 |
72 |