diff -r 708df4dc6ab6 -r 6c7bd0edd1d7 src/work/athos/mincostflow.h --- a/src/work/athos/mincostflow.h Tue Jun 01 11:00:24 2004 +0000 +++ b/src/work/athos/mincostflow.h Wed Jun 02 09:45:50 2004 +0000 @@ -99,8 +99,6 @@ //To store the potential (dual variables) typedef typename Graph::template NodeMap PotentialMap; PotentialMap potential; - //To store excess-deficit values - SupplyDemandMap excess_deficit; Cost total_cost; @@ -114,8 +112,7 @@ cost(_cost), supply_demand(_supply_demand), flow(_graph), - potential(_graph), - excess_deficit(_graph){ } + potential(_graph){ } ///Runs the algorithm. @@ -126,9 +123,13 @@ /// feasible primal-dual solution pair as well. void run() { + //To store excess-deficit values + SupplyDemandMap excess_deficit(graph); + //Resetting variables from previous runs //total_cost = 0; + typedef typename Graph::template NodeMap HeapMap; typedef BinHeap< Node, SupplyDemand, typename Graph::template NodeMap, std::greater > HeapType; @@ -196,6 +197,7 @@ //Let's construct the sugraph consisting only of the abundant edges typedef ConstMap< typename Graph::Node, bool > ConstNodeMap; + ConstNodeMap const_true_map(true); typedef SubGraphWrapper< const Graph, ConstNodeMap, typename Graph::template EdgeMap > @@ -320,7 +322,7 @@ Node s = excess_nodes.top(); - SupplyDemand max_excess = excess_nodes[s]; + max_excess = excess_nodes[s]; Node t = deficit_nodes.top(); if (max_excess < deficit_nodes[t]){ max_excess = deficit_nodes[t]; @@ -370,7 +372,7 @@ //Update the excess_nodes heap - if (delta >= excess_nodes[s]){ + if (delta > excess_nodes[s]){ if (delta > excess_nodes[s]) deficit_nodes.push(s,delta - excess_nodes[s]); excess_nodes.pop(); @@ -380,7 +382,7 @@ excess_nodes.set(s, excess_nodes[s] - delta); } //Update the deficit_nodes heap - if (delta >= deficit_nodes[t]){ + if (delta > deficit_nodes[t]){ if (delta > deficit_nodes[t]) excess_nodes.push(t,delta - deficit_nodes[t]); deficit_nodes.pop(); @@ -444,7 +446,7 @@ ///This function checks, whether the given solution is optimal ///Running after a \c run() should return with true - ///In this "state of the art" this only check optimality, doesn't bother with feasibility + ///In this "state of the art" this only checks optimality, doesn't bother with feasibility /// ///\todo Is this OK here? bool checkComplementarySlackness(){ @@ -455,20 +457,52 @@ mod_pot = cost[e]-potential[graph.head(e)]+potential[graph.tail(e)]; fl_e = flow[e]; // std::cout << fl_e << std::endl; - if (0 0 && fl_e != 0) - return false; - if (mod_pot < 0 && fl_e != capacity[e]) - return false; - } + if (mod_pot > 0 && fl_e != 0) + return false; + } return true; } - + + /* + //For testing purposes only + //Lists the node_properties + void write_property_vector(const SupplyDemandMap& a, + char* prop_name="property"){ + FOR_EACH_LOC(typename Graph::NodeIt, i, graph){ + cout<<"Node id.: "<