20 setPartialPathLimit(-1);
22 expandSearchRadius =
true;
27 std::vector<node *> fromChain;
28 std::vector<node *> toChain;
34 setupSearch(_aMap, fromChain, from, toChain, to);
35 if (fromChain.size() == 0)
38 lastPth = buildNextAbstractPath(_aMap, lastPth, fromChain, toChain, _rp);
45 rp = _rp; start = s; end = e; aMap = _aMap;
48 setupSearch(aMap, startChain, start, endChain, end);
64 if (startChain.size() == 0)
66 lastPath = buildNextAbstractPath(aMap, lastPath, startChain, endChain, rp);
77 std::vector<node *> &fromChain,
node *from,
78 std::vector<node *> &toChain,
node *to)
83 if ((from == 0) || (to == 0) || (!_aMap->
Pathable(from, to)) || (from == to))
88 printf(
"spreadPRAStar: from == 0\n");
90 printf(
"spreadPRAStar: to == 0\n");
92 printf(
"spreadPRAStar: from == to\n");
93 if (from && to && (!_aMap->
Pathable(from, to)))
94 printf(
"spreadPRAStar: no path from %p to %p\n", (
void*)from, (
void*)to);
101 printf(
"At nodes #%d and %d\n", from->
GetNum(), to->
GetNum());
111 unsigned int previousSize = fromChain.size();
113 while ((fromChain.size() > 2) && ((fromChain.size() > (previousSize)/2) ||
117 fromChain.pop_back();
122 std::vector<node *> &fromChain,
123 std::vector<node *> &toChain,
126 node *to, *from, *hTarget = 0;
129 from = fromChain.back();
130 fromChain.pop_back();
136 printf(
"Building path from %d to %d (%ld/%ld)\n",
139 std::vector<node *> eligibleNodeParents;
144 if (partialLimit > 0)
146 path *trav = lastPth;
148 for (
int x = 0; x < partialLimit; x++)
157 hTarget = trav->
next->
n;
167 for (
path *trav = lastPth; trav; trav = trav->
next)
169 if (expandSearchRadius)
172 for (
edge *e = trav->n->edgeIterNext(ei); e; e = trav->n->edgeIterNext(ei)) {
173 if (e->getFrom() == trav->n->GetNum())
174 eligibleNodeParents.push_back(g->
GetNode(e->getTo()));
176 eligibleNodeParents.push_back(g->
GetNode(e->getFrom()));
179 eligibleNodeParents.push_back(trav->n);
182 cAStar.setCorridor(&eligibleNodeParents);
186 result = cAStar.getBestPath(_aMap, from, to, hTarget, _rp);
189 if (
verbose) printf(
"NULL result from getBestPath in spreadPRAStar\n");
193 result = cAStar.GetPath(_aMap, from, to, _rp);
196 if (
verbose) printf(
"NULL result from GetPath in spreadPRAStar\n");
199 nodesExpanded += cAStar.GetNodesExpanded();
200 nodesTouched += cAStar.GetNodesTouched();
206 if (partialLimit != -1)
209 path *change = 0, *last = 0;
210 for (
path *trav = lastPth; trav; trav = trav->
next)
212 if (trav->n == origDest)
214 if (trav->n->GetLabelL(
kParent) != parent)