COIN-OR::LEMON - Graph Library

Changeset 1169:774349a16ba0 in lemon for tools/dimacs-solver.cc


Ignore:
Timestamp:
11/07/12 18:13:26 (12 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
1.2
Parents:
1161:08712a8c3afe (diff), 1167:c5990f454032 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge bugfix #440 to branch 1.2

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tools/dimacs-solver.cc

    r956 r1169  
    118118  if (report) std::cerr << "Read the file: " << ti << '\n';
    119119
    120   ti.restart();
    121   NetworkSimplex<Digraph, Value> ns(g);
     120  typedef NetworkSimplex<Digraph, Value> MCF;
     121  ti.restart();
     122  MCF ns(g);
    122123  ns.lowerMap(lower).upperMap(cap).costMap(cost).supplyMap(sup);
    123124  if (sum_sup > 0) ns.supplyType(ns.LEQ);
    124125  if (report) std::cerr << "Setup NetworkSimplex class: " << ti << '\n';
    125126  ti.restart();
    126   bool res = ns.run();
     127  typename MCF::ProblemType res = ns.run();
    127128  if (report) {
    128129    std::cerr << "Run NetworkSimplex: " << ti << "\n\n";
    129     std::cerr << "Feasible flow: " << (res ? "found" : "not found") << '\n';
     130    std::cerr << "Feasible flow: " << (res == MCF::OPTIMAL ? "found" : "not found") << '\n';
    130131    if (res) std::cerr << "Min flow cost: "
    131132                       << ns.template totalCost<LargeValue>() << '\n';
     
    188189
    189190int main(int argc, const char *argv[]) {
    190   typedef SmartDigraph Digraph;
    191 
    192   typedef Digraph::Arc Arc;
    193191
    194192  std::string inputName;
  • tools/dimacs-solver.cc

    r1167 r1169  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2010
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    8989  pre.run();
    9090  if(report) std::cerr << "Run Preflow: " << ti << '\n';
    91   if(report) std::cerr << "\nMax flow value: " << pre.flowValue() << '\n'; 
    92 }
    93 
    94 template<class Value>
     91  if(report) std::cerr << "\nMax flow value: " << pre.flowValue() << '\n';
     92}
     93
     94template<class Value, class LargeValue>
    9595void solve_min(ArgParser &ap, std::istream &is, std::ostream &,
    9696               Value infty, DimacsDescriptor &desc)
     
    129129    std::cerr << "Run NetworkSimplex: " << ti << "\n\n";
    130130    std::cerr << "Feasible flow: " << (res == MCF::OPTIMAL ? "found" : "not found") << '\n';
    131     if (res) std::cerr << "Min flow cost: " << ns.totalCost() << '\n';
     131    if (res) std::cerr << "Min flow cost: "
     132                       << ns.template totalCost<LargeValue>() << '\n';
    132133  }
    133134}
     
    149150  if(report) std::cerr << "Run MaxMatching: " << ti << '\n';
    150151  if(report) std::cerr << "\nCardinality of max matching: "
    151                        << mat.matchingSize() << '\n'; 
    152 }
    153 
    154 
    155 template<class Value>
     152                       << mat.matchingSize() << '\n';
     153}
     154
     155
     156template<class Value, class LargeValue>
    156157void solve(ArgParser &ap, std::istream &is, std::ostream &os,
    157158           DimacsDescriptor &desc)
     
    167168      exit(1);
    168169    }
    169  
     170
    170171  switch(desc.type)
    171172    {
    172173    case DimacsDescriptor::MIN:
    173       solve_min<Value>(ap,is,os,infty,desc);
     174      solve_min<Value, LargeValue>(ap,is,os,infty,desc);
    174175      break;
    175176    case DimacsDescriptor::MAX:
     
    236237
    237238  DimacsDescriptor desc = dimacsType(is);
    238  
     239
    239240  if(!ap.given("q"))
    240241    {
     
    261262      std::cout << "\n\n";
    262263    }
    263    
     264
    264265  if(ap.given("double"))
    265     solve<double>(ap,is,os,desc);
     266    solve<double, double>(ap,is,os,desc);
    266267  else if(ap.given("ldouble"))
    267     solve<long double>(ap,is,os,desc);
     268    solve<long double, long double>(ap,is,os,desc);
    268269#ifdef LEMON_HAVE_LONG_LONG
    269270  else if(ap.given("long"))
    270     solve<long long>(ap,is,os,desc);
     271    solve<long long, long long>(ap,is,os,desc);
     272  else solve<int, long long>(ap,is,os,desc);
     273#else
     274  else solve<int, long>(ap,is,os,desc);
    271275#endif
    272   else solve<int>(ap,is,os,desc);
    273276
    274277  return 0;
Note: See TracChangeset for help on using the changeset viewer.