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 { 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) { public ProblemeOuvert(ShortestPathData data) {
super(data); super(data);
@ -164,21 +164,38 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
} }
} else { } else {
// Assez de batterie // Assez de batterie
double newBatteryLeft = batteryLeft - arc.getLength(); //avant on faisait arcCost mais qui était en temps (on fait tous nos test en temps) double newBatteryLeft;
if (newCost < succLabel.getCoutRealise()) { if (arc.getRoadInformation().getType() == RoadType.MOTORWAY) {
if (succLabel.getCoutRealise() != Double.POSITIVE_INFINITY) {
heap.remove(succLabel); 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); }else{
succLabel.setPere(arc); newBatteryLeft = batteryLeft - arc.getLength(); //avant on faisait arcCost mais qui était en temps (on fait tous nos test en temps)
succLabel.setAutonomieRestante(newBatteryLeft);
predecessorArcs[succ.getId()] = arc;
heap.insert(succLabel);
notifyNodeReached(succ);
}
}
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 { public static void main(String[] args) throws Exception {
//cartes non routières // //cartes non routières
System.out.println("== Chemin de longueur nulle =="); // System.out.println("== Chemin de longueur nulle ==");
testScenario("carre.mapgr", 9, 9, Mode.LENGTH, true,0,false); // testScenario("carre.mapgr", 9, 9, Mode.LENGTH, true,0,false);
System.out.println("== Sommet hors du graphe =="); // System.out.println("== Sommet hors du graphe ==");
testScenario("carre.mapgr", 0, 9999, Mode.LENGTH, true,0,false); // testScenario("carre.mapgr", 0, 9999, Mode.LENGTH, true,0,false);
//cartes routières // //cartes routières
System.out.println("== Test en distance =="); // System.out.println("== Test en distance ==");
testScenario("insa.mapgr", 369, 838, Mode.LENGTH, true,0,false); // testScenario("insa.mapgr", 369, 838, Mode.LENGTH, true,0,false);
System.out.println("== Test en temps =="); // System.out.println("== Test en temps ==");
testScenario("insa.mapgr", 369, 838, Mode.TIME, true,0,false); // 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) =="); // System.out.println("== Trajet long (et pénible avec les enfants) ==");
testScenario("bretagne.mapgr",564429,602395 , Mode.LENGTH, false,0,false); // testScenario("bretagne.mapgr",564429,602395 , Mode.LENGTH, false,0,false);
System.out.println("== Trajet impossible (piste cyclable) =="); // System.out.println("== Trajet impossible (piste cyclable) ==");
testScenario("insa.mapgr",90,922 , Mode.LENGTH, false,0,true); // testScenario("insa.mapgr",90,922 , Mode.LENGTH, false,0,true);
//tests probleme ouvert // //tests probleme ouvert
System.out.println("== Test Probleme Ouvert =="); System.out.println("== Test Probleme Ouvert ==");
testScenario("toulouse.mapgr",33056,16303 , Mode.TIME, false,2,false); testScenario("toulouse.mapgr",33056,16303 , Mode.TIME, false,2,false);
System.out.println("== Test Probleme Ouvert =="); 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 =="); //System.out.println("== Test Probleme Ouvert ==");
//testScenario("bretagne.mapgr",165317,74644 , Mode.TIME, false,2,false); //testScenario("bretagne.mapgr",165317,74644 , Mode.TIME, false,2,false);