Почему мой решатель IDA* дает более длинный путь, чем мой решатель A*? [закрыто]JAVA

Программисты JAVA общаются здесь
Anonymous
Почему мой решатель IDA* дает более длинный путь, чем мой решатель A*? [закрыто]

Сообщение Anonymous »

Это мой код < /p>

Код: Выделить всё

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;
}
the ostlimit назначается наименьшему элементу в pq , и я помещаю расстояние в него в Hashmap, называемой Distto , вычитая оценочное значение из не наименьшего приоритета.
при выполнении этого кода вместе с* сольюрером, иногда изменяется, и он меняет более длительный путь. Это нормально?

Подробнее здесь: https://stackoverflow.com/questions/796 ... y-a-solver

Вернуться в «JAVA»