gravatar
alpar (Alpar Juttner)
alpar@cs.elte.hu
Merge #417
0 1 0
merge default
1 file changed with 2 insertions and 2 deletions:
↑ Collapse diff ↑
Ignore white space 48 line context
... ...
@@ -890,49 +890,49 @@
890 890
        }
891 891
      }
892 892

	
893 893
      return OPTIMAL;
894 894
    }
895 895

	
896 896
    // Execute the algorithm and transform the results
897 897
    void start(Method method) {
898 898
      // Maximum path length for partial augment
899 899
      const int MAX_PATH_LENGTH = 4;
900 900

	
901 901
      // Initialize data structures for buckets
902 902
      _max_rank = _alpha * _res_node_num;
903 903
      _buckets.resize(_max_rank);
904 904
      _bucket_next.resize(_res_node_num + 1);
905 905
      _bucket_prev.resize(_res_node_num + 1);
906 906
      _rank.resize(_res_node_num + 1);
907 907

	
908 908
      // Execute the algorithm
909 909
      switch (method) {
910 910
        case PUSH:
911 911
          startPush();
912 912
          break;
913 913
        case AUGMENT:
914
          startAugment();
914
          startAugment(_res_node_num - 1);
915 915
          break;
916 916
        case PARTIAL_AUGMENT:
917 917
          startAugment(MAX_PATH_LENGTH);
918 918
          break;
919 919
      }
920 920

	
921 921
      // Compute node potentials for the original costs
922 922
      _arc_vec.clear();
923 923
      _cost_vec.clear();
924 924
      for (int j = 0; j != _res_arc_num; ++j) {
925 925
        if (_res_cap[j] > 0) {
926 926
          _arc_vec.push_back(IntPair(_source[j], _target[j]));
927 927
          _cost_vec.push_back(_scost[j]);
928 928
        }
929 929
      }
930 930
      _sgr.build(_res_node_num, _arc_vec.begin(), _arc_vec.end());
931 931

	
932 932
      typename BellmanFord<StaticDigraph, LargeCostArcMap>
933 933
        ::template SetDistMap<LargeCostNodeMap>::Create bf(_sgr, _cost_map);
934 934
      bf.distMap(_pi_map);
935 935
      bf.init(0);
936 936
      bf.start();
937 937

	
938 938
      // Handle non-zero lower bounds
... ...
@@ -1067,49 +1067,49 @@
1067 1067
              }
1068 1068
            }
1069 1069
          }
1070 1070

	
1071 1071
          // Finish search if there are no more active nodes
1072 1072
          if (_excess[u] > 0) {
1073 1073
            total_excess -= _excess[u];
1074 1074
            if (total_excess <= 0) break;
1075 1075
          }
1076 1076
        }
1077 1077
        if (total_excess <= 0) break;
1078 1078
      }
1079 1079

	
1080 1080
      // Relabel nodes
1081 1081
      for (int u = 0; u != _res_node_num; ++u) {
1082 1082
        int k = std::min(_rank[u], r);
1083 1083
        if (k > 0) {
1084 1084
          _pi[u] -= _epsilon * k;
1085 1085
          _next_out[u] = _first_out[u];
1086 1086
        }
1087 1087
      }
1088 1088
    }
1089 1089

	
1090 1090
    /// Execute the algorithm performing augment and relabel operations
1091
    void startAugment(int max_length = std::numeric_limits<int>::max()) {
1091
    void startAugment(int max_length) {
1092 1092
      // Paramters for heuristics
1093 1093
      const int EARLY_TERM_EPSILON_LIMIT = 1000;
1094 1094
      const double GLOBAL_UPDATE_FACTOR = 3.0;
1095 1095

	
1096 1096
      const int global_update_freq = int(GLOBAL_UPDATE_FACTOR *
1097 1097
        (_res_node_num + _sup_node_num * _sup_node_num));
1098 1098
      int next_update_limit = global_update_freq;
1099 1099

	
1100 1100
      int relabel_cnt = 0;
1101 1101

	
1102 1102
      // Perform cost scaling phases
1103 1103
      std::vector<int> path;
1104 1104
      for ( ; _epsilon >= 1; _epsilon = _epsilon < _alpha && _epsilon > 1 ?
1105 1105
                                        1 : _epsilon / _alpha )
1106 1106
      {
1107 1107
        // Early termination heuristic
1108 1108
        if (_epsilon <= EARLY_TERM_EPSILON_LIMIT) {
1109 1109
          if (earlyTermination()) break;
1110 1110
        }
1111 1111

	
1112 1112
        // Initialize current phase
1113 1113
        initPhase();
1114 1114

	
1115 1115
        // Perform partial augment and relabel operations
0 comments (0 inline)