diff --git a/lemon/network_simplex.h b/lemon/network_simplex.h --- a/lemon/network_simplex.h +++ b/lemon/network_simplex.h @@ -1147,6 +1147,7 @@ // Run Circulation to check if a feasible solution exists typedef ConstMap ConstArcMap; + ConstArcMap zero_arc_map(0), inf_arc_map(inf_cap); FlowNodeMap *csup = NULL; bool local_csup = false; if (_psupply) { @@ -1167,17 +1168,17 @@ circ_result = circ.run(); } else { Circulation - circ(_graph, *_plower, ConstArcMap(inf_cap), *csup); + circ(_graph, *_plower, inf_arc_map, *csup); circ_result = circ.run(); } } else { if (_pupper) { Circulation - circ(_graph, ConstArcMap(0), *_pupper, *csup); + circ(_graph, zero_arc_map, *_pupper, *csup); circ_result = circ.run(); } else { Circulation - circ(_graph, ConstArcMap(0), ConstArcMap(inf_cap), *csup); + circ(_graph, zero_arc_map, inf_arc_map, *csup); circ_result = circ.run(); } } @@ -1194,17 +1195,17 @@ circ_result = circ.run(); } else { Circulation - circ(rgraph, *_plower, ConstArcMap(inf_cap), neg_csup); + circ(rgraph, *_plower, inf_arc_map, neg_csup); circ_result = circ.run(); } } else { if (_pupper) { Circulation - circ(rgraph, ConstArcMap(0), *_pupper, neg_csup); + circ(rgraph, zero_arc_map, *_pupper, neg_csup); circ_result = circ.run(); } else { Circulation - circ(rgraph, ConstArcMap(0), ConstArcMap(inf_cap), neg_csup); + circ(rgraph, zero_arc_map, inf_arc_map, neg_csup); circ_result = circ.run(); } } diff --git a/test/min_cost_flow_test.cc b/test/min_cost_flow_test.cc --- a/test/min_cost_flow_test.cc +++ b/test/min_cost_flow_test.cc @@ -233,12 +233,7 @@ { typedef int Flow; typedef int Cost; - // TODO: This typedef should be enabled if the standard maps are - // reference maps in the graph concepts (See #190). -/**/ - //typedef concepts::Digraph GR; - typedef ListDigraph GR; -/**/ + typedef concepts::Digraph GR; checkConcept< McfClassConcept, NetworkSimplex >(); } diff --git a/tools/dimacs-solver.cc b/tools/dimacs-solver.cc --- a/tools/dimacs-solver.cc +++ b/tools/dimacs-solver.cc @@ -93,24 +93,42 @@ template void solve_min(ArgParser &ap, std::istream &is, std::ostream &, - DimacsDescriptor &desc) + Value infty, DimacsDescriptor &desc) { bool report = !ap.given("q"); Digraph g; Digraph::ArcMap lower(g), cap(g), cost(g); Digraph::NodeMap sup(g); Timer ti; + ti.restart(); - readDimacsMin(is, g, lower, cap, cost, sup, 0, desc); + readDimacsMin(is, g, lower, cap, cost, sup, infty, desc); + ti.stop(); + Value sum_sup = 0; + for (Digraph::NodeIt n(g); n != INVALID; ++n) { + sum_sup += sup[n]; + } + if (report) { + std::cerr << "Sum of supply values: " << sum_sup << "\n"; + if (sum_sup <= 0) + std::cerr << "GEQ supply contraints are used for NetworkSimplex\n\n"; + else + std::cerr << "LEQ supply contraints are used for NetworkSimplex\n\n"; + } if (report) std::cerr << "Read the file: " << ti << '\n'; + ti.restart(); NetworkSimplex ns(g); ns.lowerMap(lower).capacityMap(cap).costMap(cost).supplyMap(sup); + if (sum_sup > 0) ns.problemType(ns.LEQ); if (report) std::cerr << "Setup NetworkSimplex class: " << ti << '\n'; ti.restart(); - ns.run(); - if (report) std::cerr << "Run NetworkSimplex: " << ti << '\n'; - if (report) std::cerr << "\nMin flow cost: " << ns.totalCost() << '\n'; + bool res = ns.run(); + if (report) { + std::cerr << "Run NetworkSimplex: " << ti << "\n\n"; + std::cerr << "Feasible flow: " << (res ? "found" : "not found") << '\n'; + if (res) std::cerr << "Min flow cost: " << ns.totalCost() << '\n'; + } } void solve_mat(ArgParser &ap, std::istream &is, std::ostream &, @@ -151,7 +169,7 @@ switch(desc.type) { case DimacsDescriptor::MIN: - solve_min(ap,is,os,desc); + solve_min(ap,is,os,infty,desc); break; case DimacsDescriptor::MAX: solve_max(ap,is,os,infty,desc);