diff --git a/solver/src/main/java/org/chocosolver/solver/search/loop/lns/neighbors/ReversePropagationGuidedNeighborhood.java b/solver/src/main/java/org/chocosolver/solver/search/loop/lns/neighbors/ReversePropagationGuidedNeighborhood.java index 5b33f1c20e..4387423c6a 100644 --- a/solver/src/main/java/org/chocosolver/solver/search/loop/lns/neighbors/ReversePropagationGuidedNeighborhood.java +++ b/solver/src/main/java/org/chocosolver/solver/search/loop/lns/neighbors/ReversePropagationGuidedNeighborhood.java @@ -145,8 +145,7 @@ protected void update() throws ContradictionException { candidates = IntStream.range(0, n) .filter(i -> fragment.get(i) && all[i] > 0) .boxed() - .sorted(Comparator.comparingInt(i -> -all[(int) i])) - .sorted(Comparator.reverseOrder()) + .sorted(Comparator.comparingInt(i -> -all[i])) .limit(listSize) .collect(Collectors.toList()); } else { diff --git a/solver/src/test/java/org/chocosolver/solver/search/loop/LNSTest.java b/solver/src/test/java/org/chocosolver/solver/search/loop/LNSTest.java index c2c4c537d3..1f8abcbfb7 100644 --- a/solver/src/test/java/org/chocosolver/solver/search/loop/LNSTest.java +++ b/solver/src/test/java/org/chocosolver/solver/search/loop/LNSTest.java @@ -198,7 +198,6 @@ public void testLoadSolution() { model.scalar(objects, volumes, "=", scalar).post(); model.scalar(objects, energies, "=", power).post(); model.knapsack(objects, scalar, power, volumes, energies).post(); - model.setObjective(Model.MAXIMIZE, power); // ... end of modelling Solver r = model.getSolver(); @@ -207,13 +206,13 @@ public void testLoadSolution() { // let's start the reparation of the previous solution // so, reset the search r.reset(); + model.setObjective(Model.MAXIMIZE, power); // declaring a neighborhood for LNS, here a random one RandomNeighborhood rnd = new RandomNeighborhood(objects, 1, 0); // initialize it with the previous (best) solution // declare LNS r.setLNS(rnd, sol); - // limit search - r.limitNode(3000); + r.limitTime("2s"); // find the new best solution int bw = 0, bp = 0; while (r.solve()) { @@ -221,7 +220,7 @@ public void testLoadSolution() { bw = scalar.getValue(); } r.printShortStatistics(); - Assert.assertEquals(bp, 6937); + Assert.assertEquals(bp, 8372); Assert.assertEquals(bw, 1092); }