# HG changeset patch # User marci # Date 1095671119 0 # Node ID cc3590763f7f02ff171d7d1dc73f1fa188749db0 # Parent ec6a528dafd2a7aa6f0ee4f58be10c165a1bc5f9 diff -r ec6a528dafd2 -r cc3590763f7f src/demo/sub_graph_wrapper_demo.cc --- a/src/demo/sub_graph_wrapper_demo.cc Mon Sep 20 08:27:34 2004 +0000 +++ b/src/demo/sub_graph_wrapper_demo.cc Mon Sep 20 09:05:19 2004 +0000 @@ -14,7 +14,7 @@ #include #include #include -#include +#include using namespace hugo; diff -r ec6a528dafd2 -r cc3590763f7f src/demo/tight_edge_filter_map.h --- a/src/demo/tight_edge_filter_map.h Mon Sep 20 08:27:34 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -// -*- C++ -*- -#ifndef HUGO_TIGHT_EDGE_FILTER_MAP_H -#define HUGO_TIGHT_EDGE_FILTER_MAP_H - -// /// \file -// /// \brief Maximum flow algorithms. -// /// \ingroup galgs - -namespace hugo { - - /// \brief A map for filtering the edge-set to those edges - /// which are tight w.r.t. some node_potential map and - /// edge_distance map. - /// - /// A node-map node_potential is said to be a potential w.r.t. - /// an edge-map edge_distance - /// if and only if for each edge e, node_potential[g.head(e)] - /// <= edge_distance[e]+node_potential[g.tail(e)] - /// (or the reverse inequality holds for each edge). - /// An edge is said to be tight if this inequality holds with equality, - /// and the map returns true exactly for those edges. - /// To avoid rounding errors, it is recommended to use this class with exact - /// types, e.g. with int. - template - class TightEdgeFilterMap { - protected: - const Graph* g; - NodePotentialMap* node_potential; - EdgeDistanceMap* edge_distance; - public: - TightEdgeFilterMap(Graph& _g, NodePotentialMap& _node_potential, - EdgeDistanceMap& _edge_distance) : - g(&_g), node_potential(&_node_potential), - edge_distance(&_edge_distance) { } - bool operator[](const typename Graph::Edge& e) const { - return ((*node_potential)[g->head(e)] == - (*edge_distance)[e]+(*node_potential)[g->tail(e)]); - } - }; - -} //namespace hugo - -#endif //HUGO_TIGHT_EDGE_FILTER_MAP_H - - diff -r ec6a528dafd2 -r cc3590763f7f src/hugo/graph_wrapper.h --- a/src/hugo/graph_wrapper.h Mon Sep 20 08:27:34 2004 +0000 +++ b/src/hugo/graph_wrapper.h Mon Sep 20 09:05:19 2004 +0000 @@ -1096,8 +1096,8 @@ public: typedef Number ValueType; typedef Edge KeyType; - ResCap(const ResGraphWrapper& _res_graph) : - res_graph(&_res_graph) { } + ResCap(const ResGraphWrapper& + _res_graph) : res_graph(&_res_graph) { } Number operator[](const Edge& e) const { if (res_graph->forward(e)) return (*(res_graph->capacity))[e]-(*(res_graph->flow))[e]; diff -r ec6a528dafd2 -r cc3590763f7f src/hugo/tight_edge_filter_map.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hugo/tight_edge_filter_map.h Mon Sep 20 09:05:19 2004 +0000 @@ -0,0 +1,46 @@ +// -*- C++ -*- +#ifndef HUGO_TIGHT_EDGE_FILTER_MAP_H +#define HUGO_TIGHT_EDGE_FILTER_MAP_H + +// /// \file +// /// \brief Maximum flow algorithms. +// /// \ingroup galgs + +namespace hugo { + + /// \brief A map for filtering the edge-set to those edges + /// which are tight w.r.t. some node_potential map and + /// edge_distance map. + /// + /// A node-map node_potential is said to be a potential w.r.t. + /// an edge-map edge_distance + /// if and only if for each edge e, node_potential[g.head(e)] + /// <= edge_distance[e]+node_potential[g.tail(e)] + /// (or the reverse inequality holds for each edge). + /// An edge is said to be tight if this inequality holds with equality, + /// and the map returns true exactly for those edges. + /// To avoid rounding errors, it is recommended to use this class with exact + /// types, e.g. with int. + template + class TightEdgeFilterMap { + protected: + const Graph* g; + NodePotentialMap* node_potential; + EdgeDistanceMap* edge_distance; + public: + TightEdgeFilterMap(Graph& _g, NodePotentialMap& _node_potential, + EdgeDistanceMap& _edge_distance) : + g(&_g), node_potential(&_node_potential), + edge_distance(&_edge_distance) { } + bool operator[](const typename Graph::Edge& e) const { + return ((*node_potential)[g->head(e)] == + (*edge_distance)[e]+(*node_potential)[g->tail(e)]); + } + }; + +} //namespace hugo + +#endif //HUGO_TIGHT_EDGE_FILTER_MAP_H + + diff -r ec6a528dafd2 -r cc3590763f7f src/work/marci/augmenting_flow.h --- a/src/work/marci/augmenting_flow.h Mon Sep 20 08:27:34 2004 +0000 +++ b/src/work/marci/augmenting_flow.h Mon Sep 20 09:05:19 2004 +0000 @@ -9,7 +9,7 @@ #include #include #include -#include +#include /// \file /// \brief Maximum flow algorithms. @@ -247,6 +247,8 @@ bool AugmentingFlow::augmentOnShortestPath() { ResGW res_graph(*g, *capacity, *flow); + typename ResGW::ResCap res_cap(res_graph); + bool _augment=false; //ReachedMap level(res_graph); @@ -267,9 +269,9 @@ Node w=res_graph.head(e); pred.set(w, e); if (pred[v]!=INVALID) { - free.set(w, std::min(free[v], res_graph.resCap(e))); + free.set(w, std::min(free[v], res_cap[e])); } else { - free.set(w, res_graph.resCap(e)); + free.set(w, res_cap[e]); } if (res_graph.head(e)==t) { _augment=true; break; } } @@ -295,6 +297,8 @@ bool AugmentingFlow::augmentOnShortestPath2() { ResGW res_graph(*g, *capacity, *flow); + typename ResGW::ResCap res_cap(res_graph); + bool _augment=false; if (status!=AFTER_FAST_AUGMENTING) { @@ -324,9 +328,9 @@ Node w=res_graph.head(e); pred.set(w, e); if (pred[v]!=INVALID) { - free.set(w, std::min(free[v], res_graph.resCap(e))); + free.set(w, std::min(free[v], res_cap[e])); } else { - free.set(w, res_graph.resCap(e)); + free.set(w, res_cap[e]); } if (res_graph.head(e)==t) { _augment=true; break; } } @@ -357,6 +361,7 @@ bool _augment=false; ResGW res_graph(*g, *capacity, *flow); + typename ResGW::ResCap res_cap(res_graph); //bfs for distances on the residual graph //ReachedMap level(res_graph); @@ -392,7 +397,7 @@ //original_edge.update(); original_edge.set(f, e); //residual_capacity.update(); - residual_capacity.set(f, res_graph.resCap(e)); + residual_capacity.set(f, res_cap[e]); } else { if (dist[res_graph.head(e)]==(dist[res_graph.tail(e)]+1)) { typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.tail(e)], @@ -400,7 +405,7 @@ //original_edge.update(); original_edge.set(f, e); //residual_capacity.update(); - residual_capacity.set(f, res_graph.resCap(e)); + residual_capacity.set(f, res_cap[e]); } } } @@ -472,6 +477,7 @@ bool _augment=false; ResGW res_graph(*g, *capacity, *flow); + typename ResGW::ResCap res_cap(res_graph); //Potential map, for distances from s typename ResGW::template NodeMap potential(res_graph, 0); @@ -549,12 +555,12 @@ pred.set(w, typename ErasingResGW::Edge(dfs)); if (pred[v]!=INVALID) { free1.set - (w, std::min(free1[v], res_graph.resCap - (typename ErasingResGW::Edge(dfs)))); + (w, std::min(free1[v], res_cap + [typename ErasingResGW::Edge(dfs)])); } else { free1.set - (w, res_graph.resCap - (typename ErasingResGW::Edge(dfs))); + (w, res_cap + [typename ErasingResGW::Edge(dfs)]); } if (w==t) { @@ -576,7 +582,7 @@ typename ErasingResGW::Edge e=pred[n]; res_graph.augment(e, augment_value); n=erasing_res_graph.tail(e); - if (res_graph.resCap(e)==0) + if (res_cap[e]==0) erasing_res_graph.erase(e); } } diff -r ec6a528dafd2 -r cc3590763f7f src/work/marci/lp/lp_solver_wrapper.h --- a/src/work/marci/lp/lp_solver_wrapper.h Mon Sep 20 08:27:34 2004 +0000 +++ b/src/work/marci/lp/lp_solver_wrapper.h Mon Sep 20 09:05:19 2004 +0000 @@ -339,9 +339,10 @@ double lo, double up) { lpx_set_row_bnds(lp, row_iter_map[row_it], bound_type, lo, up); } -// void setObjCoef(const RowIt& row_it, double obj_coef) { -// lpx_set_obj_coef(lp, row_iter_map[row_it], obj_coef); -// } + ///. + void setObjCoef(const ColIt& col_it, double obj_coef) { + lpx_set_obj_coef(lp, col_iter_map[col_it], obj_coef); + } ///. void solveSimplex() { lpx_simplex(lp); } ///.