Merge branch 'main' of https://git.etud.insa-toulouse.fr/bezza/BE-Graphe
This commit is contained in:
commit
30c07907c1
2 changed files with 38 additions and 14 deletions
|
|
@ -18,14 +18,4 @@ public class LabelProblemeOuvert extends Label {
|
|||
public void setAutonomieRestante(double autonomieRestante) {
|
||||
this.autonomieRestante = autonomieRestante;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTotalCost() { //normalement pas besoin
|
||||
return this.getCoutRealise();
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public int compareTo(LabelProblemeOuvert other) {
|
||||
return Double.compare(this.getTotalCost(), other.getTotalCost());
|
||||
}*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
|
|||
return new LabelProblemeOuvert(node, false, Double.POSITIVE_INFINITY, null, MAX_BATTERY);
|
||||
}
|
||||
|
||||
protected void tryUpdateLabel(LabelProblemeOuvert[] labels, BinaryHeap<Label> heap, Node node,
|
||||
/*protected void tryUpdateLabel(LabelProblemeOuvert[] labels, BinaryHeap<Label> heap, Node node,
|
||||
double newCost, double newBatteryLeft, Arc pere, Arc[] tableauArcs) {
|
||||
|
||||
LabelProblemeOuvert label = labels[node.getId()];
|
||||
|
|
@ -145,6 +145,7 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
|
|||
}
|
||||
|
||||
label.setCoutRealise(newCost);
|
||||
succLabel.setPere(arc);
|
||||
label.setAutonomieRestante(newBatteryLeft);
|
||||
label.setPere(pere);
|
||||
|
||||
|
|
@ -155,7 +156,7 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
/*@Override
|
||||
protected void fonctionProblemeOuvert(RoadType typeDeRoute,LabelProblemeOuvert[] labels, BinaryHeap<LabelProblemeOuvert> heap, Node node,
|
||||
|
|
@ -224,12 +225,45 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
|
|||
double newBatteryLeft = batteryLeft - arcCost;
|
||||
|
||||
// 1. On fais le test d'avant qui vérfie si le coût avec ce chemin est meilleur
|
||||
tryUpdateLabel(labels, heap, succ, newCost, newBatteryLeft, arc,predecessorArcs);
|
||||
//tryUpdateLabel(labels, heap, succ, newCost, newBatteryLeft, arc,predecessorArcs);
|
||||
|
||||
|
||||
if (newCost < succLabel.getCoutRealise()) {
|
||||
if (succLabel.getCoutRealise() != Double.POSITIVE_INFINITY) {
|
||||
heap.remove(succLabel);
|
||||
//System.out.println(succLabel.getTotalCost());// print de confirmation , pour verif si tous les couts qui sortent du tas sont croissant. getTotalcost pas croissant!!
|
||||
}
|
||||
succLabel.setCoutRealise(newCost);
|
||||
succLabel.setPere(arc);
|
||||
succLabel.setAutonomieRestante(newBatteryLeft);
|
||||
predecessorArcs[succ.getId()] = arc;
|
||||
|
||||
// Insertion dans le tas car on est sûr qu'il n'est pas
|
||||
|
||||
heap.insert(succLabel);
|
||||
|
||||
notifyNodeReached(succ);
|
||||
}
|
||||
|
||||
// 2. On fait aussi le test avec une autonmie pleine pour voir si la solution est meilleure (il faudra rajouter 2mn au temps de trajet)
|
||||
//si on recharge effectivement et détecter cette recharge
|
||||
if (arc.getRoadInformation().getType() == RoadType.MOTORWAY) {
|
||||
tryUpdateLabel(labels, heap, succ, newCost, MAX_BATTERY, arc,predecessorArcs);
|
||||
if (newCost < succLabel.getCoutRealise()) {
|
||||
if (succLabel.getCoutRealise() != Double.POSITIVE_INFINITY) {
|
||||
heap.remove(succLabel);
|
||||
//System.out.println(succLabel.getTotalCost());// print de confirmation , pour verif si tous les couts qui sortent du tas sont croissant. getTotalcost pas croissant!!
|
||||
}
|
||||
succLabel.setCoutRealise(newCost);
|
||||
succLabel.setPere(arc);
|
||||
succLabel.setAutonomieRestante(MAX_BATTERY);
|
||||
predecessorArcs[succ.getId()] = arc;
|
||||
|
||||
// Insertion dans le tas car on est sûr qu'il n'est pas
|
||||
|
||||
heap.insert(succLabel);
|
||||
|
||||
notifyNodeReached(succ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue