Warum gibt mein Ida* -Löser einen längeren Weg als mein A* -Löser?Java

Java-Forum
Anonymous
 Warum gibt mein Ida* -Löser einen längeren Weg als mein A* -Löser?

Post by Anonymous »

Das ist mein Code < /p>

Code: Select all

private boolean DFS(Vertex start) {

if (start.equals(end)) {
SO = SolverOutcome.SOLVED;
this.distance = distTo.get(end);
return true;
}

for (WeightedEdge e : input.neighbors(start)) {

Vertex to = e.to();
double distToV = distTo.get(start) + e.weight();
double h = input.estimatedDistanceToGoal(to, end);

if (!edgeTo.containsKey(to)) {

edgeTo.put(to, start);

/*
if the distance to the parent
plus the weight plus the estD is less than
the cost limit, put the distance
to the e.to() vertex, and make the DFS call
otherwise put it in the PQ
*/

if (distToV + h > costLimit) {
if (!PQ.contains(to)) {
PQ.add(to, distToV + h);
}
}
else {
distTo.put(to, distToV);
if (DFS(to)) {
return true;
}
}
}
}

return false;
}

i Das costlimit wird dem kleinsten Element in der pq zugewiesen, und ich habe den Abstand in die Hashmap genannt, die distto durch Subtrahieren des geschätzten Wertes von der geringsten Priorität, wenn der Gap diesen Code einen längeren Weg abhält. Ist es normal?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post