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

test de la fonction solutionFractionnelle avec un exemple

parent 81be7dad
No related branches found
No related tags found
1 merge request!3Dev1
No preview for this file type
No preview for this file type
...@@ -2,8 +2,9 @@ import java.util.List; ...@@ -2,8 +2,9 @@ import java.util.List;
public class App { public class App {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Backpack backpack= new InstanceReader().read("src/sac0"); Backpack backpack= new InstanceReader().read("src/sacTest");
backpack.sortByRatio(); backpack.sortByRatio();
System.out.println(backpack); backpack.solutionFractionnelle();
System.out.println("solution fractionnelle :" + backpack.getSfValuee());
} }
} }
...@@ -29,7 +29,7 @@ public class Backpack { ...@@ -29,7 +29,7 @@ public class Backpack {
for(Loot loot : loots){ for(Loot loot : loots){
if(loot.getWeight() > this.capacity){ if(loot.getWeight() > this.capacity){
sfValuee += (loot.getValue() * loot.getWeight()) / (capacity - sfWeight); sfValuee += (loot.getValue() * loot.getWeight()) / (capacity - sfWeight);
sfWeight += capacity; sfWeight += capacity - sfWeight;
} }
else { else {
sfValuee += loot.getWeight(); sfValuee += loot.getWeight();
......
15
5 40
8 48
4 36
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment