490 |
490 |
GvNode node, toNode, finalNode, bestNode; // , *pNodoProv;
|
491 |
491 |
GvEdge link;
|
492 |
492 |
boolean bExit = false;
|
493 |
|
double bestCost;
|
494 |
493 |
|
495 |
494 |
boolean bGiroProhibido;
|
496 |
495 |
ArrayList candidatos = new ArrayList();
|
497 |
496 |
|
498 |
|
GvTurn elGiro;
|
499 |
497 |
// char Mensaje[200];
|
500 |
498 |
|
501 |
499 |
IGraph graph = net.getGraph();
|
... | ... | |
531 |
529 |
candidatos.add(node);
|
532 |
530 |
node.setBestCost(0);
|
533 |
531 |
node.setStatus(GvNode.statNowInList);
|
534 |
|
node.calculateStimation(finalNode);
|
|
532 |
node.calculateStimation(finalNode, 0);
|
535 |
533 |
|
536 |
|
bestCost = Double.MAX_VALUE;
|
537 |
|
|
538 |
534 |
// Mientras que la lista de candidatosSTL no est? vac?a, procesamos
|
539 |
535 |
// Nodos
|
540 |
536 |
double bestStimation;
|
... | ... | |
543 |
539 |
// Buscamos el nodo con m?nimo coste
|
544 |
540 |
node = (GvNode) candidatos.get(0);
|
545 |
541 |
bestNode = node;
|
546 |
|
bestCost = node.getBestCost();
|
547 |
542 |
bestStimation = node.getStimation();
|
548 |
543 |
for (nodeNum = 1; nodeNum < candidatos.size(); nodeNum++) {
|
549 |
544 |
node = (GvNode) candidatos.get(nodeNum);
|
... | ... | |
600 |
595 |
// Miramos a ver si podemos mejorar su best_cost
|
601 |
596 |
newCost = node.getBestCost() + link.getWeight();
|
602 |
597 |
|
603 |
|
// Miramos la lista de Giros de ese nodo
|
604 |
|
bGiroProhibido = false;
|
605 |
|
for (int idGiro = 0; idGiro < node.getTurns().size(); idGiro++) {
|
606 |
|
// Si est? prohibido, a por otro
|
607 |
|
elGiro = (GvTurn) node.getTurns().get(idGiro);
|
608 |
|
// TODO: HABILITAR ESTO
|
609 |
|
// if ((elGiro.idTramoOrigen ==
|
610 |
|
// Arcos[pNodo->from_link].idTramo) &&
|
611 |
|
// (elGiro.idTramoDestino == pEnlace->idTramo))
|
612 |
|
// {
|
613 |
|
// if (elGiro.cost < 0)
|
614 |
|
// {
|
615 |
|
// bGiroProhibido = true;
|
616 |
|
// // No podemos inicializar por completo el nodo porque
|
617 |
|
// entonces
|
618 |
|
// // perdemos el fromLink (el arco desde donde hemos
|
619 |
|
// llegado hasta
|
620 |
|
// // este nodo, que es necesario para calcular los
|
621 |
|
// costes y generar
|
622 |
|
// // el shape recorriendo hacia atr?s el camino
|
623 |
|
// realizado.
|
624 |
|
// // Si hab?a m?s de un nodo con costes prohibidos,
|
625 |
|
// cab?a la posibilidad
|
626 |
|
// // de que perdieramos este enlace.
|
627 |
|
//
|
628 |
|
// // Para que pueda volver a entrar en c?lculos
|
629 |
|
// pNodo->status = statNotInList;
|
630 |
|
// pNodo->best_cost = INFINITO;
|
631 |
|
//
|
632 |
|
// }
|
633 |
|
// else
|
634 |
|
// newCost += elGiro.cost;
|
635 |
|
// break; // Salimos del for porque ya hemos encontrado
|
636 |
|
// el giro
|
637 |
|
// }
|
638 |
|
}
|
639 |
|
// Si est? prohibido, vamos a por otro enlace, PERO
|
640 |
|
// MARCAMOS EL NODO
|
641 |
|
// COMO NO VISITADO PARA QUE PUEDA VOLVER A ENTRAR EN LA
|
642 |
|
// LISTA DE CANDIDATOS
|
643 |
|
// SI VENIMOS POR OTRO LADO.
|
644 |
|
if (bGiroProhibido) {
|
645 |
|
continue;
|
646 |
|
}
|
647 |
|
|
648 |
598 |
if (newCost < toNode.getBestCost()) {
|
649 |
599 |
// Es una mejora, as? que actualizamos el vecino y
|
650 |
600 |
// lo a?adimos a los candidatosSTL
|
651 |
601 |
toNode.setBestCost(newCost);
|
652 |
602 |
toNode.setFromLink(link.getIdEdge());
|
653 |
603 |
|
654 |
|
toNode.calculateStimation(finalNode);
|
|
604 |
toNode.calculateStimation(finalNode, newCost);
|
655 |
605 |
|
656 |
606 |
if (toNode.getStatus() != GvNode.statNowInList) {
|
657 |
607 |
toNode.setStatus(GvNode.statNowInList);
|