Commit 6fefd6ad authored by Tong Li's avatar Tong Li

bug

parent b5060c05
...@@ -1189,7 +1189,8 @@ public class VariableNeighborhoodSearch { ...@@ -1189,7 +1189,8 @@ public class VariableNeighborhoodSearch {
if (rnd.nextDouble() < 0.7) { if (rnd.nextDouble() < 0.7) {
selectedOp = sortedCandidates.get(rnd.nextInt(Math.min(3, sortedCandidates.size()))); selectedOp = sortedCandidates.get(rnd.nextInt(Math.min(3, sortedCandidates.size())));
} else { } else {
selectedOp = sortedCandidates.get(3 + rnd.nextInt(sortedCandidates.size() - 3)); int otherCount = sortedCandidates.size() - 3;
selectedOp = sortedCandidates.get(3 + rnd.nextInt(otherCount));
} }
} }
...@@ -1661,7 +1662,8 @@ public class VariableNeighborhoodSearch { ...@@ -1661,7 +1662,8 @@ public class VariableNeighborhoodSearch {
if (rnd.nextDouble() < 0.7) { if (rnd.nextDouble() < 0.7) {
priorityGroupIndex = rnd.nextInt(Math.min(3, positionByPriority.size())); priorityGroupIndex = rnd.nextInt(Math.min(3, positionByPriority.size()));
} else { } else {
priorityGroupIndex = 3 + rnd.nextInt(positionByPriority.size() - 3); int otherCount = positionByPriority.size() - 3;
priorityGroupIndex = 3 + rnd.nextInt(otherCount);
} }
} }
...@@ -1704,7 +1706,7 @@ public class VariableNeighborhoodSearch { ...@@ -1704,7 +1706,7 @@ public class VariableNeighborhoodSearch {
int maxAttempts = 50; int maxAttempts = 50;
for (int attempt = 0; attempt < maxAttempts; attempt++) { for (int attempt = 0; attempt < maxAttempts; attempt++) {
// 优先选择前面的优先级组(订单数多的),使用加权随机 // 优先选择前面的优先级组(订单数多的),使用加权随机
int priorityGroupIndex; int priorityGroupIndex;
if (positionByPriority.size() <= 3) { if (positionByPriority.size() <= 3) {
priorityGroupIndex = rnd.nextInt(positionByPriority.size()); priorityGroupIndex = rnd.nextInt(positionByPriority.size());
...@@ -1713,7 +1715,8 @@ public class VariableNeighborhoodSearch { ...@@ -1713,7 +1715,8 @@ public class VariableNeighborhoodSearch {
if (rnd.nextDouble() < 0.7) { if (rnd.nextDouble() < 0.7) {
priorityGroupIndex = rnd.nextInt(Math.min(3, positionByPriority.size())); priorityGroupIndex = rnd.nextInt(Math.min(3, positionByPriority.size()));
} else { } else {
priorityGroupIndex = 3 + rnd.nextInt(positionByPriority.size() - 3); int otherCount = positionByPriority.size() - 3;
priorityGroupIndex = 3 + rnd.nextInt(otherCount);
} }
} }
...@@ -1785,7 +1788,8 @@ public class VariableNeighborhoodSearch { ...@@ -1785,7 +1788,8 @@ public class VariableNeighborhoodSearch {
if (rnd.nextDouble() < 0.7) { if (rnd.nextDouble() < 0.7) {
priorityGroupIndex = rnd.nextInt(Math.min(3, positionByPriority.size())); priorityGroupIndex = rnd.nextInt(Math.min(3, positionByPriority.size()));
} else { } else {
priorityGroupIndex = 3 + rnd.nextInt(positionByPriority.size() - 3); int otherCount = positionByPriority.size() - 3;
priorityGroupIndex = 3 + rnd.nextInt(otherCount);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment