Changeset 1104:a78e5b779b69 in lemon-main
- Timestamp:
- 10/17/13 15:08:41 (11 years ago)
- Branch:
- default
- Parents:
- 1101:15e233f588da (diff), 1103:c0c2f5c87aa6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Phase:
- public
- Location:
- lemon
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/capacity_scaling.h
r1092 r1104 164 164 165 165 // Parameters of the problem 166 bool _ha ve_lower;166 bool _has_lower; 167 167 Value _sum_supply; 168 168 … … 357 357 template <typename LowerMap> 358 358 CapacityScaling& lowerMap(const LowerMap& map) { 359 _ha ve_lower = true;359 _has_lower = true; 360 360 for (ArcIt a(_graph); a != INVALID; ++a) { 361 361 _lower[_arc_idf[a]] = map[a]; 362 _lower[_arc_idb[a]] = map[a];363 362 } 364 363 return *this; … … 544 543 _cost[j] = _forward[j] ? 1 : -1; 545 544 } 546 _ha ve_lower = false;545 _has_lower = false; 547 546 return *this; 548 547 } … … 755 754 const Value MAX = std::numeric_limits<Value>::max(); 756 755 int last_out; 757 if (_ha ve_lower) {756 if (_has_lower) { 758 757 for (int i = 0; i != _root; ++i) { 759 758 last_out = _first_out[i+1]; … … 840 839 } 841 840 842 // Check if the upper bound is greater or equal to the lower bound843 // on each arc.841 // Check if the upper bound is greater than or equal to the lower bound 842 // on each forward arc. 844 843 bool checkBoundMaps() { 845 844 for (int j = 0; j != _res_arc_num; ++j) { 846 if (_ upper[j] < _lower[j]) return false;845 if (_forward[j] && _upper[j] < _lower[j]) return false; 847 846 } 848 847 return true; … … 858 857 859 858 // Handle non-zero lower bounds 860 if (_ha ve_lower) {859 if (_has_lower) { 861 860 int limit = _first_out[_root]; 862 861 for (int j = 0; j != limit; ++j) { 863 if ( !_forward[j]) _res_cap[j] += _lower[j];862 if (_forward[j]) _res_cap[_reverse[j]] += _lower[j]; 864 863 } 865 864 } -
lemon/capacity_scaling.h
r1103 r1104 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-201 05 * Copyright (C) 2003-2013 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 67 67 /// \ref CapacityScaling implements the capacity scaling version 68 68 /// of the successive shortest path algorithm for finding a 69 /// \ref min_cost_flow "minimum cost flow" \ref amo93networkflows, 70 /// \ref edmondskarp72theoretical. It is an efficient dual 71 /// solution method. 69 /// \ref min_cost_flow "minimum cost flow" \cite amo93networkflows, 70 /// \cite edmondskarp72theoretical. It is an efficient dual 71 /// solution method, which runs in polynomial time 72 /// \f$O(m\log U (n+m)\log n)\f$, where <i>U</i> denotes the maximum 73 /// of node supply and arc capacity values. 72 74 /// 73 75 /// This algorithm is typically slower than \ref CostScaling and … … 117 119 typedef typename TR::Heap Heap; 118 120 119 /// The \ref CapacityScalingDefaultTraits "traits class" of the algorithm 121 /// \brief The \ref lemon::CapacityScalingDefaultTraits "traits class" 122 /// of the algorithm 120 123 typedef TR Traits; 121 124 … … 643 646 /// 644 647 /// This function returns the total cost of the found flow. 645 /// Its complexity is O( e).648 /// Its complexity is O(m). 646 649 /// 647 650 /// \note The return type of the function can be specified as a … … 835 838 return OPTIMAL; 836 839 } 837 840 838 841 // Check if the upper bound is greater than or equal to the lower bound 839 842 // on each forward arc. -
lemon/cost_scaling.h
r1093 r1104 257 257 258 258 // Parameters of the problem 259 bool _ha ve_lower;259 bool _has_lower; 260 260 Value _sum_supply; 261 261 int _sup_node_num; … … 373 373 template <typename LowerMap> 374 374 CostScaling& lowerMap(const LowerMap& map) { 375 _ha ve_lower = true;375 _has_lower = true; 376 376 for (ArcIt a(_graph); a != INVALID; ++a) { 377 377 _lower[_arc_idf[a]] = map[a]; 378 _lower[_arc_idb[a]] = map[a];379 378 } 380 379 return *this; … … 569 568 _scost[_reverse[j]] = 0; 570 569 } 571 _ha ve_lower = false;570 _has_lower = false; 572 571 return *this; 573 572 } … … 781 780 const Value MAX = std::numeric_limits<Value>::max(); 782 781 int last_out; 783 if (_ha ve_lower) {782 if (_has_lower) { 784 783 for (int i = 0; i != _root; ++i) { 785 784 last_out = _first_out[i+1]; … … 838 837 sup[n] = _supply[_node_id[n]]; 839 838 } 840 if (_ha ve_lower) {839 if (_has_lower) { 841 840 for (ArcIt a(_graph); a != INVALID; ++a) { 842 841 int j = _arc_idf[a]; … … 908 907 } 909 908 910 // Check if the upper bound is greater or equal to the lower bound911 // on each arc.909 // Check if the upper bound is greater than or equal to the lower bound 910 // on each forward arc. 912 911 bool checkBoundMaps() { 913 912 for (int j = 0; j != _res_arc_num; ++j) { 914 if (_ upper[j] < _lower[j]) return false;913 if (_forward[j] && _upper[j] < _lower[j]) return false; 915 914 } 916 915 return true; … … 992 991 993 992 // Handle non-zero lower bounds 994 if (_ha ve_lower) {993 if (_has_lower) { 995 994 int limit = _first_out[_root]; 996 995 for (int j = 0; j != limit; ++j) { 997 if ( !_forward[j]) _res_cap[j] += _lower[j];996 if (_forward[j]) _res_cap[_reverse[j]] += _lower[j]; 998 997 } 999 998 } -
lemon/cost_scaling.h
r1103 r1104 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-201 05 * Copyright (C) 2003-2013 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 92 92 /// \ref CostScaling implements a cost scaling algorithm that performs 93 93 /// push/augment and relabel operations for finding a \ref min_cost_flow 94 /// "minimum cost flow" \ref amo93networkflows, \ref goldberg90approximation, 95 /// \ref goldberg97efficient, \ref bunnagel98efficient. 94 /// "minimum cost flow" \cite amo93networkflows, 95 /// \cite goldberg90approximation, 96 /// \cite goldberg97efficient, \cite bunnagel98efficient. 96 97 /// It is a highly efficient primal-dual solution method, which 97 98 /// can be viewed as the generalization of the \ref Preflow 98 99 /// "preflow push-relabel" algorithm for the maximum flow problem. 100 /// It is a polynomial algorithm, its running time complexity is 101 /// \f$O(n^2m\log(nK))\f$, where <i>K</i> denotes the maximum arc cost. 99 102 /// 100 103 /// In general, \ref NetworkSimplex and \ref CostScaling are the fastest … … 151 154 typedef typename TR::LargeCost LargeCost; 152 155 153 /// The \ref CostScalingDefaultTraits "traits class" of the algorithm 156 /// \brief The \ref lemon::CostScalingDefaultTraits "traits class" 157 /// of the algorithm 154 158 typedef TR Traits; 155 159 … … 211 215 typedef std::vector<LargeCost> LargeCostVector; 212 216 typedef std::vector<char> BoolVector; 213 // Note: vector<char> is used instead of vector<bool> for efficiency reasons 217 // Note: vector<char> is used instead of vector<bool> 218 // for efficiency reasons 214 219 215 220 private: … … 667 672 /// 668 673 /// This function returns the total cost of the found flow. 669 /// Its complexity is O( e).674 /// Its complexity is O(m). 670 675 /// 671 676 /// \note The return type of the function can be specified as a … … 901 906 return OPTIMAL; 902 907 } 903 908 904 909 // Check if the upper bound is greater than or equal to the lower bound 905 910 // on each forward arc. … … 1282 1287 _buckets[r] = _bucket_next[u]; 1283 1288 1284 // Search the incom ming arcs of u1289 // Search the incoming arcs of u 1285 1290 LargeCost pi_u = _pi[u]; 1286 1291 int last_out = _first_out[u+1]; -
lemon/cycle_canceling.h
r1092 r1104 196 196 197 197 // Parameters of the problem 198 bool _ha ve_lower;198 bool _has_lower; 199 199 Value _sum_supply; 200 200 … … 279 279 template <typename LowerMap> 280 280 CycleCanceling& lowerMap(const LowerMap& map) { 281 _ha ve_lower = true;281 _has_lower = true; 282 282 for (ArcIt a(_graph); a != INVALID; ++a) { 283 283 _lower[_arc_idf[a]] = map[a]; 284 _lower[_arc_idb[a]] = map[a];285 284 } 286 285 return *this; … … 472 471 _cost[_reverse[j]] = 0; 473 472 } 474 _ha ve_lower = false;473 _has_lower = false; 475 474 return *this; 476 475 } … … 685 684 const Value MAX = std::numeric_limits<Value>::max(); 686 685 int last_out; 687 if (_ha ve_lower) {686 if (_has_lower) { 688 687 for (int i = 0; i != _root; ++i) { 689 688 last_out = _first_out[i+1]; … … 728 727 sup[n] = _supply[_node_id[n]]; 729 728 } 730 if (_ha ve_lower) {729 if (_has_lower) { 731 730 for (ArcIt a(_graph); a != INVALID; ++a) { 732 731 int j = _arc_idf[a]; … … 785 784 } 786 785 787 // Check if the upper bound is greater or equal to the lower bound788 // on each arc.786 // Check if the upper bound is greater than or equal to the lower bound 787 // on each forward arc. 789 788 bool checkBoundMaps() { 790 789 for (int j = 0; j != _res_arc_num; ++j) { 791 if (_ upper[j] < _lower[j]) return false;790 if (_forward[j] && _upper[j] < _lower[j]) return false; 792 791 } 793 792 return true; … … 836 835 837 836 // Handle non-zero lower bounds 838 if (_ha ve_lower) {837 if (_has_lower) { 839 838 int limit = _first_out[_root]; 840 839 for (int j = 0; j != limit; ++j) { 841 if ( !_forward[j]) _res_cap[j] += _lower[j];840 if (_forward[j]) _res_cap[_reverse[j]] += _lower[j]; 842 841 } 843 842 } -
lemon/cycle_canceling.h
r1103 r1104 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-201 05 * Copyright (C) 2003-2013 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 48 48 /// \ref CycleCanceling implements three different cycle-canceling 49 49 /// algorithms for finding a \ref min_cost_flow "minimum cost flow" 50 /// \ ref amo93networkflows, \refklein67primal,51 /// \ refgoldberg89cyclecanceling.50 /// \cite amo93networkflows, \cite klein67primal, 51 /// \cite goldberg89cyclecanceling. 52 52 /// The most efficent one is the \ref CANCEL_AND_TIGHTEN 53 53 /// "Cancel-and-Tighten" algorithm, thus it is the default method. 54 /// It runs in strongly polynomial time , but in practice, it is typically55 /// orders of magnitude slower than the scaling algorithms and56 /// \ref NetworkSimplex.54 /// It runs in strongly polynomial time \f$O(n^2 m^2 \log n)\f$, 55 /// but in practice, it is typically orders of magnitude slower than 56 /// the scaling algorithms and \ref NetworkSimplex. 57 57 /// (For more information, see \ref min_cost_flow_algs "the module page".) 58 58 /// … … 132 132 /// The "Minimum Mean Cycle-Canceling" algorithm, which is a 133 133 /// well-known strongly polynomial method 134 /// \ refgoldberg89cyclecanceling. It improves along a134 /// \cite goldberg89cyclecanceling. It improves along a 135 135 /// \ref min_mean_cycle "minimum mean cycle" in each iteration. 136 /// Its running time complexity is O(n<sup>2</sup>e<sup>3</sup>log(n)).136 /// Its running time complexity is \f$O(n^2 m^3 \log n)\f$. 137 137 MINIMUM_MEAN_CYCLE_CANCELING, 138 138 /// The "Cancel-and-Tighten" algorithm, which can be viewed as an 139 139 /// improved version of the previous method 140 /// \ refgoldberg89cyclecanceling.140 /// \cite goldberg89cyclecanceling. 141 141 /// It is faster both in theory and in practice, its running time 142 /// complexity is O(n<sup>2</sup>e<sup>2</sup>log(n)).142 /// complexity is \f$O(n^2 m^2 \log n)\f$. 143 143 CANCEL_AND_TIGHTEN 144 144 }; … … 576 576 /// 577 577 /// This function returns the total cost of the found flow. 578 /// Its complexity is O( e).578 /// Its complexity is O(m). 579 579 /// 580 580 /// \note The return type of the function can be specified as a … … 783 783 return OPTIMAL; 784 784 } 785 785 786 786 // Check if the upper bound is greater than or equal to the lower bound 787 787 // on each forward arc. … … 960 960 buildResidualNetwork(); 961 961 while (true) { 962 962 963 963 typename HwMmc::TerminationCause hw_tc = 964 964 hw_mmc.findCycleMean(hw_iter_limit); … … 976 976 hw_mmc.findCycle(); 977 977 } 978 978 979 979 // Compute delta value 980 980 Value delta = INF; -
lemon/network_simplex.h
r1092 r1104 199 199 200 200 // Parameters of the problem 201 bool _ha ve_lower;201 bool _has_lower; 202 202 SupplyType _stype; 203 203 Value _sum_supply; … … 683 683 template <typename LowerMap> 684 684 NetworkSimplex& lowerMap(const LowerMap& map) { 685 _ha ve_lower = true;685 _has_lower = true; 686 686 for (ArcIt a(_graph); a != INVALID; ++a) { 687 687 _lower[_arc_id[a]] = map[a]; … … 880 880 _cost[i] = 1; 881 881 } 882 _ha ve_lower = false;882 _has_lower = false; 883 883 _stype = GEQ; 884 884 return *this; … … 1073 1073 1074 1074 // Remove non-zero lower bounds 1075 if (_ha ve_lower) {1075 if (_has_lower) { 1076 1076 for (int i = 0; i != _arc_num; ++i) { 1077 1077 Value c = _lower[i]; … … 1236 1236 } 1237 1237 1238 // Check if the upper bound is greater or equal to the lower bound1238 // Check if the upper bound is greater than or equal to the lower bound 1239 1239 // on each arc. 1240 1240 bool checkBoundMaps() { … … 1613 1613 1614 1614 // Transform the solution and the supply map to the original form 1615 if (_ha ve_lower) {1615 if (_has_lower) { 1616 1616 for (int i = 0; i != _arc_num; ++i) { 1617 1617 Value c = _lower[i]; -
lemon/network_simplex.h
r1103 r1104 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-201 05 * Copyright (C) 2003-2013 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 42 42 /// \ref NetworkSimplex implements the primal Network Simplex algorithm 43 43 /// for finding a \ref min_cost_flow "minimum cost flow" 44 /// \ ref amo93networkflows, \refdantzig63linearprog,45 /// \ refkellyoneill91netsimplex.44 /// \cite amo93networkflows, \cite dantzig63linearprog, 45 /// \cite kellyoneill91netsimplex. 46 46 /// This algorithm is a highly efficient specialized version of the 47 47 /// linear programming simplex method directly for the minimum cost … … 974 974 /// 975 975 /// This function returns the total cost of the found flow. 976 /// Its complexity is O( e).976 /// Its complexity is O(m). 977 977 /// 978 978 /// \note The return type of the function can be specified as a … … 1235 1235 return true; 1236 1236 } 1237 1237 1238 1238 // Check if the upper bound is greater than or equal to the lower bound 1239 1239 // on each arc. … … 1517 1517 } 1518 1518 } else { 1519 // Find the min. cost incom ming arc for each demand node1519 // Find the min. cost incoming arc for each demand node 1520 1520 for (int i = 0; i != int(demand_nodes.size()); ++i) { 1521 1521 Node v = demand_nodes[i];
Note: See TracChangeset
for help on using the changeset viewer.