Changeset 1104:a78e5b779b69 in lemon-main for lemon/cost_scaling.h
- 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
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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];
Note: See TracChangeset
for help on using the changeset viewer.