ajustement ProblemeOuvert à tête reposée (quelques félonies ont été effectuées dans le code d'avant, normalement il y en a moins dans celui-ci)
這個提交存在於:
父節點
d6bd57d709
當前提交
b89e741861
共有 2 個檔案被更改,包括 13 行新增 和 12 行删除
|
|
@ -28,7 +28,7 @@ public class LabelStar extends Label {
|
||||||
@Override
|
@Override
|
||||||
public double getTotalCost() {
|
public double getTotalCost() {
|
||||||
double gCost = getCoutRealise(); // Coût actuel depuis l'origine (distance ou temps)
|
double gCost = getCoutRealise(); // Coût actuel depuis l'origine (distance ou temps)
|
||||||
double hCost = 0.0;
|
double hCost = 0.0;
|
||||||
|
|
||||||
Node current = getSommetCourant();
|
Node current = getSommetCourant();
|
||||||
Node destinationNode = this.pathData.getDestination(); // Obtention de la destination depuis pathData
|
Node destinationNode = this.pathData.getDestination(); // Obtention de la destination depuis pathData
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import org.insa.graphs.model.RoadInformation.RoadType;
|
||||||
public class ProblemeOuvert extends DijkstraAlgorithm {
|
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) {
|
public ProblemeOuvert(ShortestPathData data) {
|
||||||
super(data);
|
super(data);
|
||||||
|
|
@ -105,7 +105,7 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
|
||||||
double batteryLeft = ((LabelProblemeOuvert) LabelActuel).getAutonomieRestante();
|
double batteryLeft = ((LabelProblemeOuvert) LabelActuel).getAutonomieRestante();
|
||||||
|
|
||||||
double newCost = LabelActuel.getCoutRealise() + arcCost;
|
double newCost = LabelActuel.getCoutRealise() + arcCost;
|
||||||
|
/*
|
||||||
if (newCost < succLabel.getCoutRealise()) {
|
if (newCost < succLabel.getCoutRealise()) {
|
||||||
if (succLabel.getCoutRealise() != Double.POSITIVE_INFINITY) {
|
if (succLabel.getCoutRealise() != Double.POSITIVE_INFINITY) {
|
||||||
heap.remove(succLabel);
|
heap.remove(succLabel);
|
||||||
|
|
@ -113,7 +113,7 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
|
||||||
}
|
}
|
||||||
succLabel.setCoutRealise(newCost);
|
succLabel.setCoutRealise(newCost);
|
||||||
succLabel.setPere(arc);
|
succLabel.setPere(arc);
|
||||||
succLabel.setAutonomieRestante(batteryLeft);
|
succLabel.setAutonomieRestante(batteryLeft); //pb on updatais pas la batterie
|
||||||
predecessorArcs[succ.getId()] = arc;
|
predecessorArcs[succ.getId()] = arc;
|
||||||
|
|
||||||
// Insertion dans le tas car on est sûr qu'il n'est pas
|
// 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);
|
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
|
// Recharge possible uniquement sur autoroute
|
||||||
if (arc.getRoadInformation().getType() == RoadType.MOTORWAY) {
|
if (arc.getRoadInformation().getType() == RoadType.MOTORWAY) {
|
||||||
double rechargeCost = newCost + 120; // 2 minutes de recharge
|
double rechargeCost = newCost + 120; // 2 minutes de recharge
|
||||||
//if (rechargeCost < succLabel.getCoutRealise()) {
|
if (rechargeCost < succLabel.getCoutRealise()) {
|
||||||
if (succLabel.getCoutRealise() != Double.POSITIVE_INFINITY) {
|
if (succLabel.getCoutRealise() != Double.POSITIVE_INFINITY) {
|
||||||
heap.remove(succLabel);
|
heap.remove(succLabel);
|
||||||
}
|
}
|
||||||
succLabel.setCoutRealise(rechargeCost);
|
succLabel.setCoutRealise(rechargeCost);
|
||||||
succLabel.setPere(arc);
|
succLabel.setPere(arc);
|
||||||
succLabel.setAutonomieRestante(MAX_BATTERY);
|
succLabel.setAutonomieRestante(MAX_BATTERY-arc.getLength());
|
||||||
predecessorArcs[succ.getId()] = arc;
|
predecessorArcs[succ.getId()] = arc;
|
||||||
heap.insert(succLabel);
|
heap.insert(succLabel);
|
||||||
notifyNodeReached(succ);
|
notifyNodeReached(succ);
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Assez de batterie
|
// 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 (newCost < succLabel.getCoutRealise()) {
|
||||||
if (succLabel.getCoutRealise() != Double.POSITIVE_INFINITY) {
|
if (succLabel.getCoutRealise() != Double.POSITIVE_INFINITY) {
|
||||||
heap.remove(succLabel);
|
heap.remove(succLabel);
|
||||||
|
|
@ -175,7 +176,7 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
|
||||||
heap.insert(succLabel);
|
heap.insert(succLabel);
|
||||||
notifyNodeReached(succ);
|
notifyNodeReached(succ);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
載入中…
新增問題並參考