diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java index 0a1d727..798ccb8 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/LabelStar.java @@ -28,7 +28,7 @@ public class LabelStar extends Label { @Override public double getTotalCost() { double gCost = getCoutRealise(); // Coût actuel depuis l'origine (distance ou temps) - double hCost = 0.0; + double hCost = 0.0; Node current = getSommetCourant(); Node destinationNode = this.pathData.getDestination(); // Obtention de la destination depuis pathData diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/ProblemeOuvert.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/ProblemeOuvert.java index d074d5a..51c5308 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/ProblemeOuvert.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/shortestpath/ProblemeOuvert.java @@ -15,7 +15,7 @@ import org.insa.graphs.model.RoadInformation.RoadType; public class ProblemeOuvert extends DijkstraAlgorithm { - private double MAX_BATTERY = 200; + private double MAX_BATTERY = 200000; //on compare avec lenght ça doit être des mètres public ProblemeOuvert(ShortestPathData data) { super(data); @@ -105,7 +105,7 @@ public class ProblemeOuvert extends DijkstraAlgorithm { double batteryLeft = ((LabelProblemeOuvert) LabelActuel).getAutonomieRestante(); double newCost = LabelActuel.getCoutRealise() + arcCost; - + /* if (newCost < succLabel.getCoutRealise()) { if (succLabel.getCoutRealise() != Double.POSITIVE_INFINITY) { heap.remove(succLabel); @@ -113,7 +113,7 @@ public class ProblemeOuvert extends DijkstraAlgorithm { } succLabel.setCoutRealise(newCost); succLabel.setPere(arc); - succLabel.setAutonomieRestante(batteryLeft); + succLabel.setAutonomieRestante(batteryLeft); //pb on updatais pas la batterie predecessorArcs[succ.getId()] = arc; // Insertion dans le tas car on est sûr qu'il n'est pas @@ -142,28 +142,29 @@ public class ProblemeOuvert extends DijkstraAlgorithm { notifyNodeReached(succ); //} - } + }*/ + //if (arc.getLength()>200000){continue;} //sécurité - /* - if (batteryLeft < arcCost) { //si nous n'avons pas assez de batterie pour l'arc + + if (batteryLeft < arc.getLength()) { //si nous n'avons pas assez de batterie pour l'arc // Recharge possible uniquement sur autoroute if (arc.getRoadInformation().getType() == RoadType.MOTORWAY) { double rechargeCost = newCost + 120; // 2 minutes de recharge - //if (rechargeCost < succLabel.getCoutRealise()) { + if (rechargeCost < succLabel.getCoutRealise()) { if (succLabel.getCoutRealise() != Double.POSITIVE_INFINITY) { heap.remove(succLabel); } succLabel.setCoutRealise(rechargeCost); succLabel.setPere(arc); - succLabel.setAutonomieRestante(MAX_BATTERY); + succLabel.setAutonomieRestante(MAX_BATTERY-arc.getLength()); predecessorArcs[succ.getId()] = arc; heap.insert(succLabel); notifyNodeReached(succ); - //} + } } } else { // Assez de batterie - double newBatteryLeft = batteryLeft - arcCost; + double newBatteryLeft = batteryLeft - arc.getLength(); //avant on faisait arcCost mais qui était en temps (on fait tous nos test en temps) if (newCost < succLabel.getCoutRealise()) { if (succLabel.getCoutRealise() != Double.POSITIVE_INFINITY) { heap.remove(succLabel); @@ -175,7 +176,7 @@ public class ProblemeOuvert extends DijkstraAlgorithm { heap.insert(succLabel); notifyNodeReached(succ); } - }*/ + }