fusion
This commit is contained in:
commit
9de19549ae
6 changed files with 208 additions and 9 deletions
|
|
@ -21,7 +21,13 @@ public class MyArcInspector implements ArcInspector {
|
||||||
boolean result=true;
|
boolean result=true;
|
||||||
if (this.restreint){
|
if (this.restreint){
|
||||||
RoadInformation.RoadType type=arc.getRoadInformation().getType();
|
RoadInformation.RoadType type=arc.getRoadInformation().getType();
|
||||||
if (type==RoadInformation.RoadType.PEDESTRIAN || type==RoadInformation.RoadType.CYCLEWAY ) {
|
if (type != RoadInformation.RoadType.MOTORWAY &&
|
||||||
|
type != RoadInformation.RoadType.TRUNK &&
|
||||||
|
type != RoadInformation.RoadType.PRIMARY &&
|
||||||
|
type != RoadInformation.RoadType.SECONDARY &&
|
||||||
|
type != RoadInformation.RoadType.TERTIARY &&
|
||||||
|
type != RoadInformation.RoadType.RESIDENTIAL &&
|
||||||
|
type != RoadInformation.RoadType.UNCLASSIFIED ) {
|
||||||
result=false;
|
result=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ public class AStarAlgorithm extends DijkstraAlgorithm {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LabelStar createLabel(Node node) {
|
protected LabelStar createLabel(Node node) {
|
||||||
return new LabelStar(node, false, Double.POSITIVE_INFINITY, null, getInputData().getDestination());
|
ShortestPathData data = getInputData(); //pour récupérer la vitesse maximale du graphe, la destination et si on est en fastestpath ou shortestpath
|
||||||
|
return new LabelStar(node, false, Double.POSITIVE_INFINITY,null,data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package org.insa.graphs.algorithm.shortestpath;
|
||||||
|
|
||||||
import org.insa.graphs.model.Arc;
|
import org.insa.graphs.model.Arc;
|
||||||
import org.insa.graphs.model.Node;
|
import org.insa.graphs.model.Node;
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
public class LabelProblemeOuvert extends Label {
|
public class LabelProblemeOuvert extends Label {
|
||||||
private double batteryLeft; //double pour la cohérence avec les autres couts qui sont en double eux aussi
|
private double batteryLeft; //double pour la cohérence avec les autres couts qui sont en double eux aussi
|
||||||
|
|
@ -23,4 +24,31 @@ public class LabelProblemeOuvert extends Label {
|
||||||
public double getTotalCost() { //pourquoi getTotalCost ? psq il est utilisé dans le compareTo
|
public double getTotalCost() { //pourquoi getTotalCost ? psq il est utilisé dans le compareTo
|
||||||
return this.getCoutRealise();
|
return this.getCoutRealise();
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
public class LabelProblemeOuvert extends Label {
|
||||||
|
private double autonomieRestante; //double pour la cohérence avec les autres couts qui sont en double eux aussi
|
||||||
|
|
||||||
|
public LabelProblemeOuvert(Node sommet, boolean marque, double cout, Arc pere, double autonomieRestante) {
|
||||||
|
super(sommet, marque, cout, pere);
|
||||||
|
this.autonomieRestante = autonomieRestante;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getAutonomieRestante() {
|
||||||
|
return autonomieRestante;
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}*/
|
||||||
|
>>>>>>> 1aee5a57c3b4966b14ac38a33ed9e52af7a882d0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package org.insa.graphs.algorithm.shortestpath;
|
package org.insa.graphs.algorithm.shortestpath;
|
||||||
|
|
||||||
|
import org.insa.graphs.algorithm.AbstractInputData;
|
||||||
import org.insa.graphs.model.Arc;
|
import org.insa.graphs.model.Arc;
|
||||||
import org.insa.graphs.model.Node;
|
import org.insa.graphs.model.Node;
|
||||||
import org.insa.graphs.model.Point;
|
import org.insa.graphs.model.Point;
|
||||||
|
|
@ -7,30 +8,70 @@ import org.insa.graphs.model.Point;
|
||||||
|
|
||||||
|
|
||||||
public class LabelStar extends Label {
|
public class LabelStar extends Label {
|
||||||
|
;
|
||||||
private Node destination;
|
private ShortestPathData pathData;
|
||||||
public LabelStar(Node sommetCourant, Boolean marque, double coutRealise, Arc pere,Node destination) {
|
public LabelStar(Node sommetCourant, Boolean marque, double coutRealise, Arc pere, ShortestPathData data) {
|
||||||
super(sommetCourant, marque, coutRealise, pere);
|
super(sommetCourant, marque, coutRealise, pere);
|
||||||
this.destination=destination;
|
this.pathData = data; //pour récupérer la vitesse maximale du graphe, la destination et si on est en fastestpath ou shortestpath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//pour optimiser l'algo : ATTENTION PAS à L'initialisation pas le faire sinon ça va le faire pr tout les pts
|
//pour optimiser l'algo : ATTENTION PAS à L'initialisation pas le faire sinon ça va le faire pr tout les pts
|
||||||
//on rajoute un paremètre distance ds le label et quand on passe sur le label si c'est linfini on le calcule
|
//on rajoute un paremètre distance ds le label et quand on passe sur le label si c'est linfini on le calcule
|
||||||
|
|
||||||
@Override
|
/*@Override
|
||||||
public double getTotalCost() { //pourquoi getTotalCost ? psq il est utilisé dans le compareTo
|
public double getTotalCost() { //pourquoi getTotalCost ? psq il est utilisé dans le compareTo
|
||||||
//System.out.println("cout realise : " + getCoutRealise()+ "\n distance : "distance(getSommetCourant().getPoint(),this.destination.getPoint()));
|
//System.out.println("cout realise : " + getCoutRealise()+ "\n distance : "distance(getSommetCourant().getPoint(),this.destination.getPoint()));
|
||||||
double cout=getCoutRealise();
|
double cout=getCoutRealise();
|
||||||
Point calcul = this.destination.getPoint();
|
Point calcul = this.pathData.getDestination().getPoint();
|
||||||
cout+=calcul.distanceTo(this.getSommetCourant().getPoint());
|
cout+=calcul.distanceTo(this.getSommetCourant().getPoint());
|
||||||
return (cout);
|
return (cout);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//pas nécessaire normalement
|
//pas nécessaire normalement
|
||||||
/*public int compareTo(LabelStar other) {
|
/*public int compareTo(LabelStar other) {
|
||||||
return Double.compare(this.getTotalCost(), other.getTotalCost());
|
return Double.compare(this.getTotalCost(), other.getTotalCost());
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calcule le coût total estimé (f = g + h) pour l'algorithme A*.
|
||||||
|
* g (getCoutRealise()) est le coût actuel depuis le départ.
|
||||||
|
* h est l'heuristique :
|
||||||
|
* - En mode DISTANCE: distance à vol d'oiseau (via distanceTo) jusqu'à la destination.
|
||||||
|
* - En mode TEMPS: distance à vol d'oiseau (via distanceTo) / vitesse maximale sur le graphe.
|
||||||
|
* @return Le coût total estimé.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public double getTotalCost() {
|
||||||
|
double gCost = getCoutRealise(); // Coût actuel depuis l'origine (distance ou temps)
|
||||||
|
double hCost = 0.0;
|
||||||
|
|
||||||
|
Node current = getSommetCourant();
|
||||||
|
Node destinationNode = this.pathData.getDestination(); // Obtention de la destination depuis pathData
|
||||||
|
Point currentPoint = current.getPoint();
|
||||||
|
Point destinationPoint = destinationNode.getPoint();
|
||||||
|
if (currentPoint == null || destinationPoint == null) {
|
||||||
|
return gCost; // Heuristique nulle si points non valides
|
||||||
|
}
|
||||||
|
|
||||||
|
//calcul vol d'oiseau
|
||||||
|
double distanceToDestinationMeters = currentPoint.distanceTo(destinationPoint);
|
||||||
|
|
||||||
|
//différencier TIME et DISTANCE
|
||||||
|
if (this.pathData.getMode() == AbstractInputData.Mode.TIME) {
|
||||||
|
int maxSpeedKmH = this.pathData.getGraph().getGraphInformation().getMaximumSpeed();
|
||||||
|
|
||||||
|
// Conversion de la vitesse max en mètres par seconde (m/s)
|
||||||
|
double maxSpeedMpS = maxSpeedKmH / 3.6;
|
||||||
|
hCost = distanceToDestinationMeters / maxSpeedMpS; // hCost est maintenant en secondes
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Heuristique pour le mode DISTANCE (ou par défaut)
|
||||||
|
hCost = distanceToDestinationMeters; // hCost est en mètres
|
||||||
|
}
|
||||||
|
|
||||||
|
return gCost + hCost;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,13 +105,25 @@ gérer le problème de la recharge, quand la faire ?
|
||||||
|
|
||||||
package org.insa.graphs.algorithm.shortestpath;
|
package org.insa.graphs.algorithm.shortestpath;
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
>>>>>>> 1aee5a57c3b4966b14ac38a33ed9e52af7a882d0
|
||||||
import org.insa.graphs.algorithm.AbstractSolution.Status;
|
import org.insa.graphs.algorithm.AbstractSolution.Status;
|
||||||
import org.insa.graphs.algorithm.utils.BinaryHeap;
|
import org.insa.graphs.algorithm.utils.BinaryHeap;
|
||||||
import org.insa.graphs.model.Arc;
|
import org.insa.graphs.model.Arc;
|
||||||
import org.insa.graphs.model.Graph;
|
import org.insa.graphs.model.Graph;
|
||||||
import org.insa.graphs.model.Node;
|
import org.insa.graphs.model.Node;
|
||||||
|
<<<<<<< HEAD
|
||||||
import org.insa.graphs.model.RoadInformation.RoadType;
|
import org.insa.graphs.model.RoadInformation.RoadType;
|
||||||
|
|
||||||
|
=======
|
||||||
|
import org.insa.graphs.model.Path;
|
||||||
|
import org.insa.graphs.model.RoadInformation.RoadType;
|
||||||
|
//import org.insa.graphs.algorithm.shortestpath.ProblemeOuvert;
|
||||||
|
>>>>>>> 1aee5a57c3b4966b14ac38a33ed9e52af7a882d0
|
||||||
|
|
||||||
public class ProblemeOuvert extends DijkstraAlgorithm {
|
public class ProblemeOuvert extends DijkstraAlgorithm {
|
||||||
|
|
||||||
|
|
@ -127,6 +139,7 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
|
||||||
return new LabelProblemeOuvert(node, false, Double.POSITIVE_INFINITY, null, MAX_BATTERY);
|
return new LabelProblemeOuvert(node, false, Double.POSITIVE_INFINITY, null, MAX_BATTERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
// Surcharge pour compatibilité avec DijkstraAlgorithm
|
// Surcharge pour compatibilité avec DijkstraAlgorithm
|
||||||
@Override
|
@Override
|
||||||
protected void tryUpdateLabel(Label[] labels, BinaryHeap<Label> heap, Node node,
|
protected void tryUpdateLabel(Label[] labels, BinaryHeap<Label> heap, Node node,
|
||||||
|
|
@ -151,11 +164,20 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
|
||||||
if (newBatteryLeft < 0) return;
|
if (newBatteryLeft < 0) return;
|
||||||
|
|
||||||
if (newCost < label.getCoutRealise() || (Math.abs(newCost - label.getCoutRealise()) < 1e-6 && newBatteryLeft > label.getBatteryLeft())) {
|
if (newCost < label.getCoutRealise() || (Math.abs(newCost - label.getCoutRealise()) < 1e-6 && newBatteryLeft > label.getBatteryLeft())) {
|
||||||
|
=======
|
||||||
|
protected void tryUpdateLabel(LabelProblemeOuvert[] labels, BinaryHeap<Label> heap, Node node,
|
||||||
|
double newCost, double newBatteryLeft, Arc pere, Arc[] tableauArcs) {
|
||||||
|
|
||||||
|
LabelProblemeOuvert label = labels[node.getId()];
|
||||||
|
|
||||||
|
if (newCost < label.getCoutRealise()) {
|
||||||
|
>>>>>>> 1aee5a57c3b4966b14ac38a33ed9e52af7a882d0
|
||||||
if (label.getCoutRealise() != Double.POSITIVE_INFINITY) {
|
if (label.getCoutRealise() != Double.POSITIVE_INFINITY) {
|
||||||
heap.remove(label);
|
heap.remove(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
label.setCoutRealise(newCost);
|
label.setCoutRealise(newCost);
|
||||||
|
<<<<<<< HEAD
|
||||||
label.setBatteryLeft(newBatteryLeft);
|
label.setBatteryLeft(newBatteryLeft);
|
||||||
label.setPere(pere);
|
label.setPere(pere);
|
||||||
|
|
||||||
|
|
@ -185,11 +207,38 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
=======
|
||||||
|
label.setAutonomieRestante(newBatteryLeft);
|
||||||
|
label.setPere(pere);
|
||||||
|
|
||||||
|
tableauArcs[pere.getDestination().getId()] = pere;
|
||||||
|
|
||||||
|
heap.insert(label);
|
||||||
|
notifyNodeReached(node);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@Override
|
||||||
|
protected void fonctionProblemeOuvert(RoadType typeDeRoute,LabelProblemeOuvert[] labels, BinaryHeap<LabelProblemeOuvert> heap, Node node,
|
||||||
|
double newCost, Arc pere){
|
||||||
|
if (typeDeRoute == RoadType.MOTORWAY) {
|
||||||
|
tryUpdateLabel(labels, heap,node, newCost, MAX_BATTERY, pere);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
>>>>>>> 1aee5a57c3b4966b14ac38a33ed9e52af7a882d0
|
||||||
@Override
|
@Override
|
||||||
protected ShortestPathSolution doRun() {
|
protected ShortestPathSolution doRun() {
|
||||||
|
|
||||||
final ShortestPathData data = getInputData();
|
final ShortestPathData data = getInputData();
|
||||||
ShortestPathSolution solution = null;
|
ShortestPathSolution solution = null;
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
// accès au graphe
|
||||||
|
>>>>>>> 1aee5a57c3b4966b14ac38a33ed9e52af7a882d0
|
||||||
Graph graph = data.getGraph();
|
Graph graph = data.getGraph();
|
||||||
int nbNodes = graph.size();
|
int nbNodes = graph.size();
|
||||||
|
|
||||||
|
|
@ -200,11 +249,18 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
|
||||||
|
|
||||||
// Initialisation des labels
|
// Initialisation des labels
|
||||||
for (Node node : graph.getNodes()) {
|
for (Node node : graph.getNodes()) {
|
||||||
|
<<<<<<< HEAD
|
||||||
labels[node.getId()] = createLabel(node);
|
labels[node.getId()] = createLabel(node);
|
||||||
}
|
}
|
||||||
// Origine : coût 0, batterie pleine
|
// Origine : coût 0, batterie pleine
|
||||||
labels[data.getOrigin().getId()].setCoutRealise(0);
|
labels[data.getOrigin().getId()].setCoutRealise(0);
|
||||||
labels[data.getOrigin().getId()].setBatteryLeft(MAX_BATTERY);
|
labels[data.getOrigin().getId()].setBatteryLeft(MAX_BATTERY);
|
||||||
|
=======
|
||||||
|
labels[node.getId()] =createLabel(node);
|
||||||
|
}
|
||||||
|
// Origine : coût 0, non marqué, pas de père
|
||||||
|
labels[data.getOrigin().getId()].setCoutRealise(0);
|
||||||
|
>>>>>>> 1aee5a57c3b4966b14ac38a33ed9e52af7a882d0
|
||||||
|
|
||||||
BinaryHeap<Label> heap = new BinaryHeap<>();
|
BinaryHeap<Label> heap = new BinaryHeap<>();
|
||||||
heap.insert(labels[data.getOrigin().getId()]);
|
heap.insert(labels[data.getOrigin().getId()]);
|
||||||
|
|
@ -212,6 +268,7 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
|
||||||
notifyOriginProcessed(data.getOrigin());
|
notifyOriginProcessed(data.getOrigin());
|
||||||
|
|
||||||
while (!heap.isEmpty()) {
|
while (!heap.isEmpty()) {
|
||||||
|
<<<<<<< HEAD
|
||||||
LabelProblemeOuvert currentLabel = (LabelProblemeOuvert) heap.deleteMin();
|
LabelProblemeOuvert currentLabel = (LabelProblemeOuvert) heap.deleteMin();
|
||||||
Node currentNode = currentLabel.getSommetCourant();
|
Node currentNode = currentLabel.getSommetCourant();
|
||||||
|
|
||||||
|
|
@ -221,10 +278,22 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
|
||||||
// On a atteint la destination on s'arrête
|
// On a atteint la destination on s'arrête
|
||||||
if (currentNode.equals(data.getDestination())) {
|
if (currentNode.equals(data.getDestination())) {
|
||||||
notifyDestinationReached(currentNode);
|
notifyDestinationReached(currentNode);
|
||||||
|
=======
|
||||||
|
Label LabelActuel = heap.deleteMin();
|
||||||
|
Node NodeActuel = LabelActuel.getSommetCourant();
|
||||||
|
|
||||||
|
// sommet traité
|
||||||
|
LabelActuel.setMarque(true);
|
||||||
|
|
||||||
|
// On a atteint la destination on s'arrête
|
||||||
|
if (NodeActuel.equals(data.getDestination())) {
|
||||||
|
notifyDestinationReached(NodeActuel);
|
||||||
|
>>>>>>> 1aee5a57c3b4966b14ac38a33ed9e52af7a882d0
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pour chaque successeur
|
// Pour chaque successeur
|
||||||
|
<<<<<<< HEAD
|
||||||
for (Arc arc : currentNode.getSuccessors()) {
|
for (Arc arc : currentNode.getSuccessors()) {
|
||||||
if (!data.isAllowed(arc)) continue;
|
if (!data.isAllowed(arc)) continue;
|
||||||
|
|
||||||
|
|
@ -272,15 +341,47 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
|
||||||
notifyNodeReached(succ);
|
notifyNodeReached(succ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
for (Arc arc : NodeActuel.getSuccessors()) {
|
||||||
|
if (!data.isAllowed(arc)) continue; // ici c'est pour l'amélioration voiture ou a pied
|
||||||
|
|
||||||
|
|
||||||
|
Node succ = arc.getDestination();
|
||||||
|
LabelProblemeOuvert succLabel = labels[succ.getId()];
|
||||||
|
|
||||||
|
if (succLabel.getMarque()) continue;
|
||||||
|
|
||||||
|
double arcCost = data.getCost(arc);
|
||||||
|
double batteryLeft = ((LabelProblemeOuvert) LabelActuel).getAutonomieRestante();
|
||||||
|
|
||||||
|
if (batteryLeft < arcCost) continue; // Pas assez de batterie pour ce chemin
|
||||||
|
|
||||||
|
double newCost = LabelActuel.getCoutRealise() + arcCost;
|
||||||
|
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);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
>>>>>>> 1aee5a57c3b4966b14ac38a33ed9e52af7a882d0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construction de la solution
|
// Construction de la solution
|
||||||
|
<<<<<<< HEAD
|
||||||
if (labels[data.getDestination().getId()].getPere() == null) {
|
if (labels[data.getDestination().getId()].getPere() == null) {
|
||||||
|
=======
|
||||||
|
if (predecessorArcs[data.getDestination().getId()] == null) {
|
||||||
|
>>>>>>> 1aee5a57c3b4966b14ac38a33ed9e52af7a882d0
|
||||||
solution = new ShortestPathSolution(data, Status.INFEASIBLE);
|
solution = new ShortestPathSolution(data, Status.INFEASIBLE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Reconstruire le chemin
|
// Reconstruire le chemin
|
||||||
|
<<<<<<< HEAD
|
||||||
java.util.ArrayList<Arc> arcs = new java.util.ArrayList<>();
|
java.util.ArrayList<Arc> arcs = new java.util.ArrayList<>();
|
||||||
Arc arc = labels[data.getDestination().getId()].getPere();
|
Arc arc = labels[data.getDestination().getId()].getPere();
|
||||||
while (arc != null) {
|
while (arc != null) {
|
||||||
|
|
@ -289,6 +390,16 @@ public class ProblemeOuvert extends DijkstraAlgorithm {
|
||||||
}
|
}
|
||||||
java.util.Collections.reverse(arcs);
|
java.util.Collections.reverse(arcs);
|
||||||
solution = new ShortestPathSolution(data, Status.OPTIMAL, new org.insa.graphs.model.Path(graph, arcs));
|
solution = new ShortestPathSolution(data, Status.OPTIMAL, new org.insa.graphs.model.Path(graph, arcs));
|
||||||
|
=======
|
||||||
|
ArrayList<Arc> arcs = new ArrayList<>();
|
||||||
|
Arc arc = predecessorArcs[data.getDestination().getId()];
|
||||||
|
while (arc != null) {
|
||||||
|
arcs.add(arc);
|
||||||
|
arc = predecessorArcs[arc.getOrigin().getId()];
|
||||||
|
}
|
||||||
|
Collections.reverse(arcs);// on inverse le chemin
|
||||||
|
solution = new ShortestPathSolution(data, Status.OPTIMAL,new Path(graph, arcs));
|
||||||
|
>>>>>>> 1aee5a57c3b4966b14ac38a33ed9e52af7a882d0
|
||||||
}
|
}
|
||||||
|
|
||||||
return solution;
|
return solution;
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,11 @@ import org.insa.graphs.algorithm.shortestpath.BellmanFordAlgorithm;
|
||||||
import org.insa.graphs.algorithm.shortestpath.DijkstraAlgorithm;
|
import org.insa.graphs.algorithm.shortestpath.DijkstraAlgorithm;
|
||||||
import org.insa.graphs.algorithm.shortestpath.ShortestPathData;
|
import org.insa.graphs.algorithm.shortestpath.ShortestPathData;
|
||||||
import org.insa.graphs.algorithm.shortestpath.ShortestPathSolution;
|
import org.insa.graphs.algorithm.shortestpath.ShortestPathSolution;
|
||||||
|
<<<<<<< HEAD:be-graphes-gui/src/main/java/org/insa/graphs/gui/simple/TestDijkstra.java
|
||||||
import org.insa.graphs.gui.drawing.Drawing;
|
import org.insa.graphs.gui.drawing.Drawing;
|
||||||
import org.insa.graphs.gui.simple.Launch;
|
import org.insa.graphs.gui.simple.Launch;
|
||||||
|
=======
|
||||||
|
>>>>>>> 1aee5a57c3b4966b14ac38a33ed9e52af7a882d0:be-graphes-gui/src/test/java/TestDijkstra.java
|
||||||
import org.insa.graphs.model.Arc;
|
import org.insa.graphs.model.Arc;
|
||||||
import org.insa.graphs.model.Graph;
|
import org.insa.graphs.model.Graph;
|
||||||
import org.insa.graphs.model.Node;
|
import org.insa.graphs.model.Node;
|
||||||
|
|
@ -159,6 +162,7 @@ public class TestDijkstra {
|
||||||
|
|
||||||
// System.out.println("== Test bug dijkstra temps ==");
|
// System.out.println("== Test bug dijkstra temps ==");
|
||||||
// testScenario("paris.mapgr", 27361, 36108, Mode.TIME, true,false,false); // ce test mettait en lumière un problème d'arrondi qui est mtn résolu.
|
// testScenario("paris.mapgr", 27361, 36108, Mode.TIME, true,false,false); // ce test mettait en lumière un problème d'arrondi qui est mtn résolu.
|
||||||
|
<<<<<<< HEAD:be-graphes-gui/src/main/java/org/insa/graphs/gui/simple/TestDijkstra.java
|
||||||
|
|
||||||
//System.out.println("== Trajet impossible (piste cyclable) ==");
|
//System.out.println("== Trajet impossible (piste cyclable) ==");
|
||||||
//testScenario("insa.mapgr",90,922 , Mode.LENGTH, false,false,true);
|
//testScenario("insa.mapgr",90,922 , Mode.LENGTH, false,false,true);
|
||||||
|
|
@ -171,5 +175,13 @@ public class TestDijkstra {
|
||||||
testScenario("paris.mapgr", 27361, 36108, Mode.TIME, true,true,false);
|
testScenario("paris.mapgr", 27361, 36108, Mode.TIME, true,true,false);
|
||||||
|
|
||||||
|
|
||||||
|
=======
|
||||||
|
|
||||||
|
System.out.println("== Trajet impossible (piste cyclable) ==");
|
||||||
|
testScenario("insa.mapgr",90,922 , Mode.LENGTH, false,false,true);
|
||||||
|
System.out.println("== Trajet impossible (piste cyclable) == sans restriction");
|
||||||
|
testScenario("insa.mapgr",90,922 , Mode.LENGTH, false,false,false); //marche pas
|
||||||
|
|
||||||
|
>>>>>>> 1aee5a57c3b4966b14ac38a33ed9e52af7a882d0:be-graphes-gui/src/test/java/TestDijkstra.java
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue