création de label marathon et presque fin de marathon
This commit is contained in:
parent
42cc651834
commit
b798f06053
4 changed files with 48 additions and 4 deletions
|
|
@ -0,0 +1,41 @@
|
|||
package org.insa.graphs.algorithm.shortestpath;
|
||||
|
||||
|
||||
import org.insa.graphs.model.Arc;
|
||||
import org.insa.graphs.model.Node;
|
||||
|
||||
public class LabelMarathon extends Label implements Comparable<Label> {
|
||||
|
||||
protected double coutDest;
|
||||
|
||||
public LabelMarathon(Node s, Boolean m, double c, Arc p, double cd) {
|
||||
super(s, m, c, p);
|
||||
this.coutDest = cd;
|
||||
}
|
||||
|
||||
public double getCoutDest() {
|
||||
return this.coutDest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTotalCost() {
|
||||
return this.coutDest + this.cout;
|
||||
}
|
||||
|
||||
public double difMarathon (double d) {
|
||||
return d - this.getTotalCost() ;
|
||||
}
|
||||
|
||||
public int compareTo(LabelMarathon l) {
|
||||
if (this.difMarathon (43)< l.difMarathon (43)) {
|
||||
return -1;
|
||||
}
|
||||
else if (this.difMarathon (43)> l.difMarathon (43)) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -16,15 +16,15 @@ public class Marathon extends ShortestPathAlgorithm {
|
|||
super(data);
|
||||
}
|
||||
|
||||
public Label newLabelMarathon(Node s) {
|
||||
return new LabelMarathon(s, false, Double.MAX_VALUE, null);
|
||||
public Label newLabelMarathon(Node s, ShortestPathData dataPath) {
|
||||
return new LabelMarathon(s, false, Integer.MAX_VALUE, null, s.getPoint().distanceTo(dataPath.getDestination().getPoint()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShortestPathSolution doRun() {
|
||||
|
||||
// retrieve data from the input problem (getInputData() is inherited from the
|
||||
// parent class ShortestPathAlgorithm)
|
||||
// parent class ShortestPathAlgorithm)@Override
|
||||
final ShortestPathData dataInput = getInputData();
|
||||
Graph graph = dataInput.getGraph();
|
||||
final int nbNodes = graph.size();
|
||||
|
|
@ -61,7 +61,7 @@ public class Marathon extends ShortestPathAlgorithm {
|
|||
if (dataInput.isAllowed(a)) {
|
||||
Node n = a.getDestination();
|
||||
if (listLabel[n.getId()] == null) {
|
||||
listLabel[n.getId()] = newLabelMarathon(n);
|
||||
listLabel[n.getId()] = newLabelMarathon(n, dataInput);
|
||||
}
|
||||
if (!listLabel[n.getId()].getMarque()) {
|
||||
possible = true ;
|
||||
|
|
@ -70,6 +70,9 @@ public class Marathon extends ShortestPathAlgorithm {
|
|||
if ((!n.equals(dest)) && (listLabel[n.getId()].getCost()) < 43){
|
||||
tas.insert(listLabel[n.getId()]) ;
|
||||
}
|
||||
if ((n.equals(dest)) && (42<listLabel[n.getId()].getCost()) && (listLabel[n.getId()].getCost()< 43)){
|
||||
fini = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue