diff --git a/out/production/aroTP2/App.class b/out/production/aroTP2/App.class index ddc92ab5174f71e7f1974260537408a5c4b0286f..cd72d5fdbb17825ce855a1b9f61572d83d12126b 100644 Binary files a/out/production/aroTP2/App.class and b/out/production/aroTP2/App.class differ diff --git a/src/App.java b/src/App.java index 9fbf35526ee85d8b1d2724389cd5a14fa4aa2c22..7757906b6ba876c5e32882ed25c64f20c99cd93c 100644 --- a/src/App.java +++ b/src/App.java @@ -3,9 +3,7 @@ import java.util.List; public class App { public static void main(String[] args) throws Exception { - Backpack backpack= new InstanceReader().read("src/sac4"); + Backpack backpack= new InstanceReader().read("src/sacTest"); backpack.solve(); - System.out.println("meilleur solution :" + backpack.getBestValue()); - System.out.println("meilleur solution :" + Arrays.toString(backpack.getBestSolution())); } } diff --git a/src/Backpack.java b/src/Backpack.java index 7f57281797ce5511872b4a54a982ddc9ee9c7c70..b2878318e79947ca26107dbae16b9941e09da498 100644 --- a/src/Backpack.java +++ b/src/Backpack.java @@ -1,3 +1,4 @@ +import java.util.Arrays; import java.util.Comparator; import java.util.List; @@ -7,8 +8,8 @@ public class Backpack { private int bestValue = 0; private int currentWeight = 0; private int currentValue = 0; - private boolean[] currentSolution; - private boolean[] bestSolution; + private final boolean[] currentSolution; + private final boolean[] bestSolution; public Backpack(int capacity, List<Loot> loots) { this.capacity = capacity; @@ -21,8 +22,7 @@ public class Backpack { this.sortByRatio(); explore_from(0); System.out.println("La valeur optimale est : " + bestValue); - System.out.println("Objets inclus dans la solution optimale : " + bestSolution); - + System.out.println("Objets inclus dans la solution optimale : " + Arrays.toString(bestSolution)); } public String toString(){ diff --git a/src/Loot.java b/src/Loot.java index e0996e4bd577b524a3931ba00adf4b60f725c84e..ff7a6d54b361083055ec1a18d9c1f8ee601b9984 100644 --- a/src/Loot.java +++ b/src/Loot.java @@ -1,5 +1,5 @@ public class Loot { - private int weight, value; + private final int weight,value; private final float ratio; public Loot(int weight, int value) {