COIN-OR::LEMON - Graph Library

source: lemon-benchmark/tests/circulation.cc

Last change on this file was 12:4eab99ff2666, checked in by Alpar Juttner <alpar@…>, 13 years ago

Add Copyright headers

File size: 2.1 KB
Line 
1/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 *
3 * This file is a part of LEMON, a generic C++ optimization library.
4 *
5 * Copyright (C) 2003-2011
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 *
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
12 *
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
15 * purpose.
16 *
17 */
18
19#include <benchmark_tools.h>
20#include <lemon/circulation.h>
21#include <lemon/smart_graph.h>
22#include <lemon/lgf_reader.h>
23#include <lemon/dimacs.h>
24#include <lemon/error.h>
25#include <istream>
26
27std::string test_name = "circulation";
28
29using namespace lemon;
30
31int testMain(std::istream &input)
32{
33  typedef int Value;
34 
35  SmartDigraph g;
36 
37  SmartDigraph::ArcMap<Value> lo_cap(g);
38  SmartDigraph::ArcMap<Value> up_cap(g);
39  SmartDigraph::ArcMap<Value> cost(g);
40  SmartDigraph::NodeMap<Value> sup(g);
41 
42  Timer ti;
43  try {
44    readDimacsMin(input, g, lo_cap, up_cap, cost, sup);
45  } catch (FormatError& error) {
46    std::cerr << error.what() << std::endl;
47    return 1;
48  }
49  logTime("fread",ti);
50
51  Timer tf;
52  ti.restart();
53  Circulation<SmartDigraph,
54    SmartDigraph::ArcMap<Value>,SmartDigraph::ArcMap<Value>,
55    SmartDigraph::NodeMap<Value> > circ(g,lo_cap,up_cap,sup);
56  logTime("setup",ti);
57  ti.restart();
58  bool res = circ.run();
59  logTime("alg",ti);
60  logTime("full",tf);
61  if(res)
62    {
63      std::cerr << "A feasible circulation is found\n";
64      std::cerr << "Checking...\n";
65      ti.restart();
66      bool res2 = circ.checkFlow();
67      logTime("check",ti);
68      if(res2)
69        std::cerr << "Success!\n";
70      else
71        std::cerr << "Oops!!!!\n";
72    }
73  else
74    {
75      std::cerr << "A dual solution is found\n";
76      std::cerr << "Checking...\n";
77      ti.restart();
78      bool res2 = circ.checkBarrier();
79      logTime("check",ti);
80      if(res2)
81        std::cerr << "Success!\n";
82      else
83        std::cerr << "Dual-Oops!!!!\n";
84
85    }
86}
87
Note: See TracBrowser for help on using the repository browser.