Skip to content
Snippets Groups Projects
Commit 67753d94 authored by OUATTARA Sie's avatar OUATTARA Sie
Browse files

on stoke recupere la liste des objets du sac optimal

parent f62f4c98
Branches
No related tags found
1 merge request!5on stoke recupere la liste des objets du sac optimal
No preview for this file type
......@@ -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()));
}
}
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(){
......
public class Loot {
private int weight, value;
private final int weight,value;
private final float ratio;
public Loot(int weight, int value) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment