COIN-OR::LEMON - Graph Library

Changeset 658:85cb3aa71cce in lemon for tools/dimacs-solver.cc


Ignore:
Timestamp:
04/21/09 16:18:54 (15 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Children:
659:0c8e5c688440, 660:b1811c363299, 666:ec817dfc2cb7
Parents:
647:0ba8dfce7259 (diff), 657:dacc2cee2b4c (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 and fix

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tools/dimacs-solver.cc

    r641 r658  
    4444#include <lemon/preflow.h>
    4545#include <lemon/matching.h>
     46#include <lemon/network_simplex.h>
    4647
    4748using namespace lemon;
     
    9192}
    9293
     94template<class Value>
     95void solve_min(ArgParser &ap, std::istream &is, std::ostream &,
     96               DimacsDescriptor &desc)
     97{
     98  bool report = !ap.given("q");
     99  Digraph g;
     100  Digraph::ArcMap<Value> lower(g), cap(g), cost(g);
     101  Digraph::NodeMap<Value> sup(g);
     102  Timer ti;
     103  ti.restart();
     104  readDimacsMin(is, g, lower, cap, cost, sup, 0, desc);
     105  if (report) std::cerr << "Read the file: " << ti << '\n';
     106  ti.restart();
     107  NetworkSimplex<Digraph, Value> ns(g);
     108  ns.lowerMap(lower).capacityMap(cap).costMap(cost).supplyMap(sup);
     109  if (report) std::cerr << "Setup NetworkSimplex class: " << ti << '\n';
     110  ti.restart();
     111  ns.run();
     112  if (report) std::cerr << "Run NetworkSimplex: " << ti << '\n';
     113  if (report) std::cerr << "\nMin flow cost: " << ns.totalCost() << '\n';
     114}
     115
    93116void solve_mat(ArgParser &ap, std::istream &is, std::ostream &,
    94117              DimacsDescriptor &desc)
     
    129152    {
    130153    case DimacsDescriptor::MIN:
    131       std::cerr <<
    132         "\n\n Sorry, the min. cost flow solver is not yet available.\n";
     154      solve_min<Value>(ap,is,os,desc);
    133155      break;
    134156    case DimacsDescriptor::MAX:
  • tools/dimacs-solver.cc

    r652 r658  
    2424///
    2525/// See
    26 /// \verbatim
    27 ///  dimacs-solver --help
    28 /// \endverbatim
     26/// \code
     27///   dimacs-solver --help
     28/// \endcode
    2929/// for more info on usage.
    30 ///
    3130
    3231#include <iostream>
     
    4443#include <lemon/dijkstra.h>
    4544#include <lemon/preflow.h>
    46 #include <lemon/max_matching.h>
     45#include <lemon/matching.h>
    4746#include <lemon/network_simplex.h>
    4847
     
    7473template<class Value>
    7574void solve_max(ArgParser &ap, std::istream &is, std::ostream &,
    76               DimacsDescriptor &desc)
     75               Value infty, DimacsDescriptor &desc)
    7776{
    7877  bool report = !ap.given("q");
     
    8281  Timer ti;
    8382  ti.restart();
    84   readDimacsMax(is, g, cap, s, t, desc);
     83  readDimacsMax(is, g, cap, s, t, infty, desc);
    8584  if(report) std::cerr << "Read the file: " << ti << '\n';
    8685  ti.restart();
     
    103102  Timer ti;
    104103  ti.restart();
    105   readDimacsMin(is, g, lower, cap, cost, sup, desc);
     104  readDimacsMin(is, g, lower, cap, cost, sup, 0, desc);
    106105  if (report) std::cerr << "Read the file: " << ti << '\n';
    107106  ti.restart();
     
    139138           DimacsDescriptor &desc)
    140139{
     140  std::stringstream iss(static_cast<std::string>(ap["infcap"]));
     141  Value infty;
     142  iss >> infty;
     143  if(iss.fail())
     144    {
     145      std::cerr << "Cannot interpret '"
     146                << static_cast<std::string>(ap["infcap"]) << "' as infinite"
     147                << std::endl;
     148      exit(1);
     149    }
     150 
    141151  switch(desc.type)
    142152    {
     
    145155      break;
    146156    case DimacsDescriptor::MAX:
    147       solve_max<Value>(ap,is,os,desc);
     157      solve_max<Value>(ap,is,os,infty,desc);
    148158      break;
    149159    case DimacsDescriptor::SP:
     
    182192    .optionGroup("datatype","ldouble")
    183193    .onlyOneGroup("datatype")
     194    .stringOption("infcap","Value used for 'very high' capacities","0")
    184195    .run();
    185196
Note: See TracChangeset for help on using the changeset viewer.