# HG changeset patch
# User Peter Kovacs <kpeter@inf.elte.hu>
# Date 1363447241 -3600
# Node ID ee9bac10f58e04dfc86f266cae4a1ad968cd8d20
# Parent 1bafdbd2fc464a095fd0db4494bf42b0344ade84
Debug checking for capacity bounds in min cost flow algorithms (#454)
diff --git a/lemon/capacity_scaling.h b/lemon/capacity_scaling.h
|
a
|
b
|
|
| 737 | 737 | } |
| 738 | 738 | if (_sum_supply > 0) return INFEASIBLE; |
| 739 | 739 | |
| | 740 | // Check lower and upper bounds |
| | 741 | LEMON_DEBUG(checkBoundMaps(), |
| | 742 | "Upper bounds must be greater or equal to the lower bounds"); |
| | 743 | |
| | 744 | |
| 740 | 745 | // Initialize vectors |
| 741 | 746 | for (int i = 0; i != _root; ++i) { |
| 742 | 747 | _pi[i] = 0; |
| … |
… |
|
| 830 | 835 | |
| 831 | 836 | return OPTIMAL; |
| 832 | 837 | } |
| | 838 | |
| | 839 | // Check if the upper bound is greater or equal to the lower bound |
| | 840 | // on each arc. |
| | 841 | bool checkBoundMaps() { |
| | 842 | for (int j = 0; j != _res_arc_num; ++j) { |
| | 843 | if (_upper[j] < _lower[j]) return false; |
| | 844 | } |
| | 845 | return true; |
| | 846 | } |
| 833 | 847 | |
| 834 | 848 | ProblemType start() { |
| 835 | 849 | // Execute the algorithm |
diff --git a/lemon/cost_scaling.h b/lemon/cost_scaling.h
|
a
|
b
|
|
| 761 | 761 | } |
| 762 | 762 | if (_sum_supply > 0) return INFEASIBLE; |
| 763 | 763 | |
| | 764 | // Check lower and upper bounds |
| | 765 | LEMON_DEBUG(checkBoundMaps(), |
| | 766 | "Upper bounds must be greater or equal to the lower bounds"); |
| | 767 | |
| 764 | 768 | |
| 765 | 769 | // Initialize vectors |
| 766 | 770 | for (int i = 0; i != _res_node_num; ++i) { |
| … |
… |
|
| 897 | 901 | |
| 898 | 902 | return OPTIMAL; |
| 899 | 903 | } |
| | 904 | |
| | 905 | // Check if the upper bound is greater or equal to the lower bound |
| | 906 | // on each arc. |
| | 907 | bool checkBoundMaps() { |
| | 908 | for (int j = 0; j != _res_arc_num; ++j) { |
| | 909 | if (_upper[j] < _lower[j]) return false; |
| | 910 | } |
| | 911 | return true; |
| | 912 | } |
| 900 | 913 | |
| 901 | 914 | // Execute the algorithm and transform the results |
| 902 | 915 | void start(Method method) { |
diff --git a/lemon/cycle_canceling.h b/lemon/cycle_canceling.h
|
a
|
b
|
|
| 670 | 670 | } |
| 671 | 671 | if (_sum_supply > 0) return INFEASIBLE; |
| 672 | 672 | |
| | 673 | // Check lower and upper bounds |
| | 674 | LEMON_DEBUG(checkBoundMaps(), |
| | 675 | "Upper bounds must be greater or equal to the lower bounds"); |
| | 676 | |
| 673 | 677 | |
| 674 | 678 | // Initialize vectors |
| 675 | 679 | for (int i = 0; i != _res_node_num; ++i) { |
| … |
… |
|
| 779 | 783 | |
| 780 | 784 | return OPTIMAL; |
| 781 | 785 | } |
| | 786 | |
| | 787 | // Check if the upper bound is greater or equal to the lower bound |
| | 788 | // on each arc. |
| | 789 | bool checkBoundMaps() { |
| | 790 | for (int j = 0; j != _res_arc_num; ++j) { |
| | 791 | if (_upper[j] < _lower[j]) return false; |
| | 792 | } |
| | 793 | return true; |
| | 794 | } |
| 782 | 795 | |
| 783 | 796 | // Build a StaticDigraph structure containing the current |
| 784 | 797 | // residual network |
diff --git a/lemon/network_simplex.h b/lemon/network_simplex.h
|
a
|
b
|
|
| 1067 | 1067 | if ( !((_stype == GEQ && _sum_supply <= 0) || |
| 1068 | 1068 | (_stype == LEQ && _sum_supply >= 0)) ) return false; |
| 1069 | 1069 | |
| | 1070 | // Check lower and upper bounds |
| | 1071 | LEMON_DEBUG(checkBoundMaps(), |
| | 1072 | "Upper bounds must be greater or equal to the lower bounds"); |
| | 1073 | |
| 1070 | 1074 | // Remove non-zero lower bounds |
| 1071 | 1075 | if (_have_lower) { |
| 1072 | 1076 | for (int i = 0; i != _arc_num; ++i) { |
| … |
… |
|
| 1230 | 1234 | |
| 1231 | 1235 | return true; |
| 1232 | 1236 | } |
| | 1237 | |
| | 1238 | // Check if the upper bound is greater or equal to the lower bound |
| | 1239 | // on each arc. |
| | 1240 | bool checkBoundMaps() { |
| | 1241 | for (int j = 0; j != _arc_num; ++j) { |
| | 1242 | if (_upper[j] < _lower[j]) return false; |
| | 1243 | } |
| | 1244 | return true; |
| | 1245 | } |
| 1233 | 1246 | |
| 1234 | 1247 | // Find the join node |
| 1235 | 1248 | void findJoinNode() { |