From f7f83793c2d3f8f37b49bf1eab04f08f8118797e Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Wed, 21 Nov 2012 02:10:41 +1100 Subject: Bug fixes for stupid things. --- impl/Operator.hpp | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) (limited to 'impl/Operator.hpp') diff --git a/impl/Operator.hpp b/impl/Operator.hpp index 0b08866..d16152e 100644 --- a/impl/Operator.hpp +++ b/impl/Operator.hpp @@ -171,14 +171,20 @@ struct MinCostFlow : public Operator { _solver.ChgCost(i, costs[i].template as()); } _solver.SolveMCF(); - if (_solver.MCFGetStatus() == MCFClass::kUnfeasible){ + + if (_solver.MCFGetStatus() != MCFClass::kOK) { return -infinity(); - } else if (_solver.MCFGetFO() == MCFClass::Inf()) { - return infinity(); - } else if (_solver.MCFGetFO() == -MCFClass::Inf()) { - return -infinity(); } else { - return _solver.MCFGetFO(); + MCFClass::FONumber num = _solver.MCFGetFO(); + if (num == MCFClass::Inf()) { + return infinity(); + } else if (num == -MCFClass::Inf()) { + return -infinity(); + } else { + if (((int)num) == -2147483648) + return -infinity(); + return num; + } } } void print(std::ostream& cout) const { @@ -217,30 +223,6 @@ private: mutable MCFSimplex _solver; }; -/*#include "TemplateConstraintMatrix.hpp" - -template -struct MinimumCostFlow : public Operator { - MinimumCostFlow() { - } - Domain solve(const Domain& d) const { - - } - virtual Domain eval(const std::vector& arguments) const { - if (arguments.size() != 1) - throw "Incorrect number of arguments."; - return solve(arguments[0]); - } - void print(std::ostream& cout) const { - cout << "minCostFlow"; - } -private: - TemplateConstraintMatrix& constraint; // T - std::vector guard; // c - std::vector> multiplication; //A - unsigned int row; -};*/ - template std::ostream& operator<<(std::ostream& cout, const Operator& op) { op.print(cout); -- cgit v1.2.3