chgt de tests prblm ouvert , version naive marche

This commit is contained in:
bezza 2025-06-03 00:47:08 +02:00
parent b89e741861
commit 3aef5448f0
2 changed files with 48 additions and 31 deletions

View file

@ -15,7 +15,7 @@ import org.insa.graphs.model.RoadInformation.RoadType;
public class ProblemeOuvert extends DijkstraAlgorithm {
private double MAX_BATTERY = 200000; //on compare avec lenght ça doit être des mètres
private final double MAX_BATTERY = 200000; //on compare avec lenght ça doit être des mètres
public ProblemeOuvert(ShortestPathData data) {
super(data);
@ -164,21 +164,38 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
}
} else {
// Assez de batterie
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);
double newBatteryLeft;
if (arc.getRoadInformation().getType() == RoadType.MOTORWAY) {
newBatteryLeft = MAX_BATTERY - arc.getLength();
double rechargeCost = newCost + 120; // 2 minutes de recharge
if (rechargeCost < succLabel.getCoutRealise()) {
if (succLabel.getCoutRealise() != Double.POSITIVE_INFINITY) {
heap.remove(succLabel);
}
succLabel.setCoutRealise(rechargeCost);
succLabel.setPere(arc);
succLabel.setAutonomieRestante(newBatteryLeft);
predecessorArcs[succ.getId()] = arc;
heap.insert(succLabel);
notifyNodeReached(succ);
}
succLabel.setCoutRealise(newCost);
succLabel.setPere(arc);
succLabel.setAutonomieRestante(newBatteryLeft);
predecessorArcs[succ.getId()] = arc;
heap.insert(succLabel);
notifyNodeReached(succ);
}
}
}else{
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);
}
succLabel.setCoutRealise(newCost);
succLabel.setPere(arc);
succLabel.setAutonomieRestante(newBatteryLeft);
predecessorArcs[succ.getId()] = arc;
heap.insert(succLabel);
notifyNodeReached(succ);
}
}
}
}

View file

@ -171,35 +171,35 @@ public class TestDijkstra {
public static void main(String[] args) throws Exception {
//cartes non routières
System.out.println("== Chemin de longueur nulle ==");
testScenario("carre.mapgr", 9, 9, Mode.LENGTH, true,0,false);
// //cartes non routières
// System.out.println("== Chemin de longueur nulle ==");
// testScenario("carre.mapgr", 9, 9, Mode.LENGTH, true,0,false);
System.out.println("== Sommet hors du graphe ==");
testScenario("carre.mapgr", 0, 9999, Mode.LENGTH, true,0,false);
// System.out.println("== Sommet hors du graphe ==");
// testScenario("carre.mapgr", 0, 9999, Mode.LENGTH, true,0,false);
//cartes routières
System.out.println("== Test en distance ==");
testScenario("insa.mapgr", 369, 838, Mode.LENGTH, true,0,false);
// //cartes routières
// System.out.println("== Test en distance ==");
// testScenario("insa.mapgr", 369, 838, Mode.LENGTH, true,0,false);
System.out.println("== Test en temps ==");
testScenario("insa.mapgr", 369, 838, Mode.TIME, true,0,false);
// System.out.println("== Test en temps ==");
// testScenario("insa.mapgr", 369, 838, Mode.TIME, true,0,false);
// autres scénarios
// // autres scénarios
System.out.println("== Trajet long (et pénible avec les enfants) ==");
testScenario("bretagne.mapgr",564429,602395 , Mode.LENGTH, false,0,false);
// System.out.println("== Trajet long (et pénible avec les enfants) ==");
// testScenario("bretagne.mapgr",564429,602395 , Mode.LENGTH, false,0,false);
System.out.println("== Trajet impossible (piste cyclable) ==");
testScenario("insa.mapgr",90,922 , Mode.LENGTH, false,0,true);
// System.out.println("== Trajet impossible (piste cyclable) ==");
// testScenario("insa.mapgr",90,922 , Mode.LENGTH, false,0,true);
//tests probleme ouvert
// //tests probleme ouvert
System.out.println("== Test Probleme Ouvert ==");
testScenario("toulouse.mapgr",33056,16303 , Mode.TIME, false,2,false);
System.out.println("== Test Probleme Ouvert ==");
testScenario("bretagne.mapgr",165317,74644 , Mode.TIME, false,2,false);
testScenario("bretagne.mapgr",281283,214878 , Mode.TIME, false,2,false);
//System.out.println("== Test Probleme Ouvert ==");
//testScenario("bretagne.mapgr",165317,74644 , Mode.TIME, false,2,false);