Skip to content

Commit

Permalink
#647 + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cprudhom committed Jan 7, 2020
1 parent c2e27a6 commit 13680ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -207,21 +206,21 @@ 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()) {
bp = power.getValue();
bw = scalar.getValue();
}
r.printShortStatistics();
Assert.assertEquals(bp, 6937);
Assert.assertEquals(bp, 8372);
Assert.assertEquals(bw, 1092);
}

Expand Down

0 comments on commit 13680ad

Please sign in to comment.