[Lemon-commits] Peter Kovacs: Use 'long long' flow cost in dimac...
Lemon HG
hg at lemon.cs.elte.hu
Sun Feb 28 20:17:11 CET 2010
details: http://lemon.cs.elte.hu/hg/lemon/rev/9d380bf27194
changeset: 919:9d380bf27194
user: Peter Kovacs <kpeter [at] inf.elte.hu>
date: Sat Feb 20 16:51:43 2010 +0100
description:
Use 'long long' flow cost in dimacs-solver.cc (#347)
diffstat:
tools/dimacs-solver.cc | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diffs (61 lines):
diff --git a/tools/dimacs-solver.cc b/tools/dimacs-solver.cc
--- a/tools/dimacs-solver.cc
+++ b/tools/dimacs-solver.cc
@@ -91,7 +91,7 @@
if(report) std::cerr << "\nMax flow value: " << pre.flowValue() << '\n';
}
-template<class Value>
+template<class Value, class LargeValue>
void solve_min(ArgParser &ap, std::istream &is, std::ostream &,
Value infty, DimacsDescriptor &desc)
{
@@ -127,7 +127,8 @@
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';
+ if (res) std::cerr << "Min flow cost: "
+ << ns.template totalCost<LargeValue>() << '\n';
}
}
@@ -151,7 +152,7 @@
}
-template<class Value>
+template<class Value, class LargeValue>
void solve(ArgParser &ap, std::istream &is, std::ostream &os,
DimacsDescriptor &desc)
{
@@ -169,7 +170,7 @@
switch(desc.type)
{
case DimacsDescriptor::MIN:
- solve_min<Value>(ap,is,os,infty,desc);
+ solve_min<Value, LargeValue>(ap,is,os,infty,desc);
break;
case DimacsDescriptor::MAX:
solve_max<Value>(ap,is,os,infty,desc);
@@ -264,14 +265,16 @@
}
if(ap.given("double"))
- solve<double>(ap,is,os,desc);
+ solve<double, double>(ap,is,os,desc);
else if(ap.given("ldouble"))
- solve<long double>(ap,is,os,desc);
+ solve<long double, long double>(ap,is,os,desc);
#ifdef LEMON_HAVE_LONG_LONG
else if(ap.given("long"))
- solve<long long>(ap,is,os,desc);
+ solve<long long, long long>(ap,is,os,desc);
+ else solve<int, long long>(ap,is,os,desc);
+#else
+ else solve<int, long>(ap,is,os,desc);
#endif
- else solve<int>(ap,is,os,desc);
return 0;
}
More information about the Lemon-commits
mailing list