Loading...
Searching...
No Matches
SearchQueue.cpp
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2014, University of Toronto
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the University of Toronto nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34
35/* Authors: Jonathan Gammell, Marlin Strub */
36
37// My definition:
38#include "ompl/geometric/planners/informedtrees/bitstar/SearchQueue.h"
39
40// For std::lexicographical_compare and the std::*_heap functions.
41#include <algorithm>
42// For std::advance.
43#include <iterator>
44// For std::move.
45#include <utility>
46
47// OMPL:
48// For OMPL_INFORM et al.
49#include "ompl/util/Console.h"
50// For exceptions:
51#include "ompl/util/Exception.h"
52
53// BIT*:
54// A collection of common helper functions
55#include "ompl/geometric/planners/informedtrees/bitstar/HelperFunctions.h"
56// The vertex class:
57#include "ompl/geometric/planners/informedtrees/bitstar/Vertex.h"
58// The cost-helper class:
59#include "ompl/geometric/planners/informedtrees/bitstar/CostHelper.h"
60// The implicit graph:
61#include "ompl/geometric/planners/informedtrees/bitstar/ImplicitGraph.h"
62
63// Debug macros
64#ifdef BITSTAR_DEBUG
66#define ASSERT_SETUP this->assertSetup();
67#else
68#define ASSERT_SETUP
69#endif // BITSTAR_DEBUG
70
71using namespace std::string_literals;
72
73namespace ompl
74{
75 namespace geometric
76 {
78 // Public functions:
80 : nameFunc_(std::move(nameFunc))
81 , edgeQueue_(
82 [this](const SortKeyAndVertexPtrPair &lhs, const SortKeyAndVertexPtrPair &rhs)
83 { return lexicographicalBetterThan(lhs.first, rhs.first); }) // This tells the edgeQueue_ to use
84 // lexicographical comparison for sorting.
85 , searchId_(std::make_shared<unsigned int>(1u))
86 {
87 }
88
90 {
91 // Store that I am setup.
92 isSetup_ = true;
93
94 // Get access to the cost helper and the graph.
95 costHelpPtr_ = costHelpPtr;
96 graphPtr_ = graphPtr;
97
98 // Set the the cost threshold to infinity to start.
99 solutionCost_ = costHelpPtr_->infiniteCost();
100 }
101
103 {
104 // Reset everything to the state of construction except for the planner name.
105 // Keep this in the order of the constructors for easy verification.
106
107 // The queue is not ready for handling data after resetting.
108 isSetup_ = false;
109
110 // Reset the pointers to external information.
111 costHelpPtr_ = nullptr;
112 graphPtr_ = nullptr;
113
114 // Clear the queue.
115 edgeQueue_.clear();
116
117 // Clear the set of inconsistent vertices.
118 inconsistentVertices_.clear();
119
120 // Reset the inflation factor.
121 inflationFactor_ = 1.0;
122
123 // Reset the number of queues that have been searched.
124 *searchId_ = 1u;
125
126 // Reset the cost threshold to infinite cost.
127 solutionCost_ = ompl::base::Cost(std::numeric_limits<double>::infinity());
128
129 // Make sure the queue doesn't think it has a solution.
130 hasExactSolution_ = false;
131
132 // Finally, reset the progress info.
133 numEdgesPopped_ = 0u;
134 }
135
137 {
138 isCascadingOfRewiringsEnabled_ = enable;
139 }
140
141 void BITstar::SearchQueue::enqueueEdge(const VertexPtrPair &edge)
142 {
143 ASSERT_SETUP
144
145 // Create convenience aliases.
146 const VertexPtr &parent = edge.first;
147 const VertexPtr &child = edge.second;
148
149 // If we already have the edge in the queue, we need to update its value.
150 EdgeQueueElemPtr updateEdge = nullptr;
151 for (auto it = child->edgeQueueInLookupConstBegin(); it != child->edgeQueueInLookupConstEnd(); ++it)
152 {
153 if ((*it)->data.second.first->getId() == parent->getId())
154 {
155 updateEdge = (*it);
156 break;
157 }
158 }
159
160 if (updateEdge) // The edge is already in the queue, we need to update it's sort key (presumably because
161 // the cost-to-come to the source changed).
162 {
163#ifdef BITSTAR_DEBUG
164 if (updateEdge->data.second.first->getId() != edge.first->getId() ||
165 updateEdge->data.second.second->getId() != edge.second->getId())
166 {
167 throw ompl::Exception("Updating the wrong edge.");
168 }
169#endif // BITSTAR_DEBUG
170 updateEdge->data.first = this->createSortKey(edge);
171 edgeQueue_.update(updateEdge);
172 }
173 else // This edge is not yet in the queue.
174 {
175 // The iterator to the new edge in the queue:
176 EdgeQueueElemPtr edgeElemPtr;
177
178 // Insert into the edge queue, getting the element pointer
179 edgeElemPtr = edgeQueue_.insert(std::make_pair(this->createSortKey(edge), edge));
180
181 // Push the newly created edge back on the vector of edges from the parent.
182 parent->insertInEdgeQueueOutLookup(edgeElemPtr);
183
184 // Push the newly created edge back on the vector of edges to the child.
185 child->insertInEdgeQueueInLookup(edgeElemPtr);
186 }
187 }
188
190 {
191 ASSERT_SETUP
192
193#ifdef BITSTAR_DEBUG
194 if (edgeQueue_.empty())
195 {
196 throw ompl::Exception("Attempted to access the first element in an empty SearchQueue.");
197 }
198#endif // BITSTAR_DEBUG
199
200 // Return the a copy of the front edge.
201 return edgeQueue_.top()->data.second;
202 }
203
205 {
206 ASSERT_SETUP
207
208#ifdef BITSTAR_DEBUG
209 if (edgeQueue_.empty())
210 {
211 throw ompl::Exception("Attempted to access the first element in an empty SearchQueue.");
212 }
213#endif // BITSTAR_DEBUG
214
215 // Return a copy of the front value.
216 return edgeQueue_.top()->data.first;
217 }
218
220 {
221 ASSERT_SETUP
222#ifdef BITSTAR_DEBUG
223 if (edgeQueue_.empty())
224 {
225 throw ompl::Exception("Attempted to pop an empty SearchQueue.");
226 }
227#endif // BITSTAR_DEBUG
228
229 // Increment the counter of popped edges.
230 ++numEdgesPopped_;
231
232 // Get the front element in the edge queue.
233 EdgeQueueElemPtr frontEdgeQueueElement = edgeQueue_.top();
234 VertexPtrPair frontEdge = frontEdgeQueueElement->data.second;
235
236#ifdef BITSTAR_DEBUG
237 if (frontEdge.first->isPruned() || frontEdge.second->isPruned())
238 {
239 throw ompl::Exception("The edge queue contains an edge with a pruned vertex.");
240 }
241#endif // BITSTAR_DEBUG
242
243 // Remove the edge from the respective vertex lookups.
244 frontEdge.first->removeFromEdgeQueueOutLookup(frontEdgeQueueElement);
245 frontEdge.second->removeFromEdgeQueueInLookup(frontEdgeQueueElement);
246
247 // Remove it from the queue.
248 edgeQueue_.pop();
249
250 // Return the edge.
251 return frontEdge;
252 }
253
255 {
256 ASSERT_SETUP
257
258 // Flag
259 hasExactSolution_ = true;
260
261 // Store
262 solutionCost_ = solutionCost;
263 }
264
266 {
267 ASSERT_SETUP
268
269 if (!edgeQueue_.empty())
270 {
271 // Iterate over the vector of incoming edges to this vertex and remove them from the queue (and clean up
272 // their other lookup).
273 for (auto it = vertex->edgeQueueInLookupConstBegin(); it != vertex->edgeQueueInLookupConstEnd(); ++it)
274 {
275 // Remove the edge from the *other* lookup (by value since this is NOT an iter to THAT container).
276 // No need to remove from this lookup, as that's being cleared.
277 (*it)->data.second.first->removeFromEdgeQueueOutLookup(*it);
278
279 // Finally remove it from the queue
280 edgeQueue_.remove(*it);
281 }
282
283 // Clear the list.
284 vertex->clearEdgeQueueInLookup();
285 }
286 // No else, nothing to remove from.
287 }
288
290 {
291 ASSERT_SETUP
292
293 if (!edgeQueue_.empty())
294 {
295 // Iterate over the vector of outgoing edges to this vertex and remove them from the queue (and clean up
296 // their other lookup).
297 for (auto it = vertex->edgeQueueOutLookupConstBegin(); it != vertex->edgeQueueOutLookupConstEnd(); ++it)
298 {
299 // Remove the edge from the *other* lookup (by value since this is NOT an iter to THAT container).
300 // No need to remove from this lookup, as that's being cleared.
301 (*it)->data.second.second->removeFromEdgeQueueInLookup(*it);
302
303 // Finally, remove it from the queue.
304 edgeQueue_.remove(*it);
305 }
306
307 // Clear the list.
308 vertex->clearEdgeQueueOutLookup();
309 }
310 // No else, nothing to remove from.
311 }
312
318
320 {
321#ifdef BITSTAR_DEBUG
322 if (vertex->isConsistent())
323 {
324 throw ompl::Exception("Attempting to remove a consistent vertex from the set of inconsistent "
325 "vertices.");
326 }
327#endif // BITSTAR_DEBUG
328 inconsistentVertices_.erase(std::remove_if(inconsistentVertices_.begin(), inconsistentVertices_.end(),
329 [vertex](const VertexPtr &element)
330 { return vertex->getId() == element->getId(); }),
331 inconsistentVertices_.end());
332 }
333
335 {
336 ASSERT_SETUP
337
338 // Clear the edge queue.
339 edgeQueue_.clear();
340
341 // Increment the queue processing number.
342 ++(*searchId_);
343 }
344
346 {
347 ASSERT_SETUP
348
349 // Insert the outgoing edges of the start vertices.
350 for (auto it = graphPtr_->startVerticesBeginConst(); it != graphPtr_->startVerticesEndConst(); ++it)
351 {
352#ifdef BITSTAR_DEBUG
353 if ((*it)->isPruned())
354 {
355 throw ompl::Exception("Inserting outgoing edges of a pruned start vertex.");
356 }
357#endif // BITSTAR_DEBUG
358 this->insertOutgoingEdges(*it);
359 }
360 }
361
363 {
364 inflationFactor_ = factor;
365 }
366
368 {
369 return inflationFactor_;
370 }
371
372 std::shared_ptr<const unsigned int> BITstar::SearchQueue::getSearchId() const
373 {
374 return searchId_;
375 }
376
378 {
379 ASSERT_SETUP
380
381#ifdef BITSTAR_DEBUG
382 if (state->isPruned())
383 {
384 throw ompl::Exception("Asking whether pruned state can possibly improve current solution.");
385 }
386#endif // BITSTAR_DEBUG
387
388 // Threshold should always be g_t(x_g)
389
390 // Can it ever be a better solution?
391 // Just in case we're using a vertex that is exactly optimally connected
392 // g^(v) + h^(v) <= g_t(x_g)?
393 return costHelpPtr_->isCostBetterThanOrEquivalentTo(costHelpPtr_->lowerBoundHeuristicVertex(state),
394 solutionCost_);
395 }
396
398 {
399 ASSERT_SETUP
400
401 // Can it ever be a better solution? Less-than-equal to just in case we're using an edge that is exactly
402 // optimally connected
403 // g^(v) + c^(v,x) + h^(x) <= g_t(x_g)?
404 bool canImprove = costHelpPtr_->isCostBetterThanOrEquivalentTo(costHelpPtr_->lowerBoundHeuristicEdge(edge),
405 solutionCost_);
406
407 // If the child is connected already, we need to check if we could do better than it's current connection.
408 // But only if we're inserting the edge
409 if (edge.second->hasParent() && canImprove)
410 {
411 // Can it ever be a better path to the vertex? Less-than-equal to just in case we're using an edge that
412 // is exactly optimally connected
413 // g^(v) + c^(v,x) <= g_t(x)?
414 canImprove = costHelpPtr_->isCostBetterThanOrEquivalentTo(
415 costHelpPtr_->lowerBoundHeuristicToTarget(edge), edge.second->getCost()); // Ever rewire?
416 }
417
418 return canImprove;
419 }
420
422 {
423 ASSERT_SETUP
424
425 return edgeQueue_.size();
426 }
427
429 {
430 ASSERT_SETUP
431
432 return edgeQueue_.empty();
433 }
434
436 {
437 ASSERT_SETUP
438
439 // Clear the inout argument.
440 edgeQueue->clear();
441
442 // Get the contents on the binary heap (key and edge).
443 std::vector<SortKeyAndVertexPtrPair> queueContents;
444 edgeQueue_.getContent(queueContents);
445
446 // Fill the inout argument.
447 for (const auto &queueElement : queueContents)
448 {
449 edgeQueue->push_back(queueElement.second);
450 }
451 }
452
454 {
455#ifdef BITSTAR_DEBUG
456 if (vertex->isPruned())
457 {
458 throw ompl::Exception("Inserting outgoing edges of pruned vertex.");
459 }
460#endif // BITSTAR_DEBUG
461 // Should we expand this vertex?
462 if (this->canPossiblyImproveCurrentSolution(vertex))
463 {
464 // Get the neighbouring samples.
465 VertexPtrVector neighbourSamples;
466 graphPtr_->nearestSamples(vertex, &neighbourSamples);
467
468 // Add all outgoing edges to neighbouring vertices and samples.
469 this->enqueueEdges(vertex, neighbourSamples);
470 }
471 // No else
472 }
473
475 {
476 // Insert all outgoing edges of the inconsistent vertices.
477 for (const auto &vertex : inconsistentVertices_)
478 {
479#ifdef BITSTAR_DEBUG
480 if (vertex->isPruned())
481 {
482 throw ompl::Exception("Attempting to insert outgoing edges of an inconsistent "
483 "vertex that has been pruned.");
484 }
485#endif // BITSTAR_DEBUG
486 this->insertOutgoingEdges(vertex);
487 }
488 }
489
491 {
492 inconsistentVertices_.clear();
493 }
494
496 {
497 // Ok this is going to be kinda dirty. We would like to have access to the actual underlying
498 // std::vector of the binary heap, holding pointers to the elements in the heap.
499 // Unfortunately, the binary heap interface only provides access to a copy. Now, we can still
500 // access get the pointers to the elements because we stored them upon insertion. But it's a mess
501 // (and suggests a flawed encapsulation or incomplete interface of the bin heap class?).
502
503 // Get a copy of the contents.
504 std::vector<SortKeyAndVertexPtrPair> contentCopy;
505 edgeQueue_.getContent(contentCopy);
506
507 // Now, get the parent vertices of all the edges still in the queue.
508 std::set<VertexPtr> parents;
509 for (const auto &element : contentCopy)
510 {
511 parents.insert(element.second.first);
512 }
513
514 // Update the sort keys of all outgoing edges of all vertices that have outgoing edges in the queue.
515 for (const auto &parent : parents)
516 {
517 for (auto it = parent->edgeQueueOutLookupConstBegin(); it != parent->edgeQueueOutLookupConstEnd(); ++it)
518 {
519 (*it)->data.first = this->createSortKey((*it)->data.second);
520 }
521 }
522
523 // All edges have an updated key, let's rebuild the queue. Presumably this is more efficient than calling
524 // EdgeQueue::update() on each edge individually while looping?
525 edgeQueue_.rebuild();
526 }
527
529 {
530 assert(elementPtr);
531
532 // Create the up-to-date sort key for this edge.
533 elementPtr->data.first = createSortKey(elementPtr->data.second);
534
535 // Update its position in the queue.
536 edgeQueue_.update(elementPtr);
537 }
538
540 {
541#ifdef BITSTAR_DEBUG
542 if (vertex->isConsistent())
543 {
544 ompl::Exception("Attempted to add a consistent vertex to the inconsistent set.");
545 }
546 if (!vertex->isExpandedOnCurrentSearch())
547 {
548 ompl::Exception("Attempted to add an unexpanded vertex to the inconsistent set.");
549 }
550#endif // BITSTAR_DEBUG
551
552 inconsistentVertices_.push_back(vertex);
553 }
554
555 void BITstar::SearchQueue::enqueueEdges(const VertexPtr &parent, const VertexPtrVector &possibleChildren)
556 {
557#ifdef BITSTAR_DEBUG
558 if (!parent->isInTree())
559 {
560 auto msg = "Trying to enqueue edges from a parent (" + std::to_string(parent->getId()) +
561 ") that's not in the tree."s;
562 throw std::runtime_error(msg);
563 }
564#endif
565 // Start with this vertex' current kiddos.
566 VertexPtrVector currentChildren;
567 parent->getChildren(&currentChildren);
568 for (const auto &child : currentChildren)
569 {
570 this->enqueueEdgeConditionally(parent, child);
571 }
572
573 // We need to store whether an outgoing edge is a rewiring.
574 bool isExpandedAsRewiring = false;
575
576 // Now consider all neighbouring vertices that are not already my kids.
577 for (auto &child : possibleChildren)
578 {
579 // If this sample is not connected to the search tree, just enqueue the edge if it's useful.
580 if (!child->isInTree())
581 {
582 this->enqueueEdgeConditionally(parent, child);
583 }
584 else // If this sample is part of the tree, we need to be a little more careful.
585 {
586 if (isCascadingOfRewiringsEnabled_ || !parent->hasEverBeenExpandedAsRewiring())
587 {
588 // Remember that this parent is expanded as a rewiring.
589 isExpandedAsRewiring = true;
590
591 // Make sure the child is not the root and distinct from this vertex (which is the parent).
592 if (!child->isRoot() && child->getId() != parent->getId())
593 {
594 // Make sure edges to kiddos aren't added twice.
595 if (child->getParent()->getId() != parent->getId())
596 {
597 // Make sure the neighbour vertex is not already my parent.
598 if (parent->isRoot() || child->getId() != parent->getParent()->getId())
599 {
600 // The neighbour is not my parent, attempt to queue the edge.
601 this->enqueueEdgeConditionally(parent, child);
602 }
603 // No else, this vertex is my parent.
604 }
605 // No else
606 }
607 // No else
608 }
609 }
610 }
611
612 // If the parent is expanded to a vertex in the tree, it is a rewiring. This needs to be registered.
613 if (isExpandedAsRewiring)
614 {
616 }
617 }
618
619 void BITstar::SearchQueue::enqueueEdgeConditionally(const VertexPtr &parent, const VertexPtr &child)
620 {
621 // Don't enqueue the edge if it's blacklisted.
622 if (parent->isBlacklistedAsChild(child))
623 {
624 return;
625 }
626 else
627 {
628 // Create the edge object.
629 VertexPtrPair newEdge = std::make_pair(parent, child);
630
631 // Enqueue the edge only if it can possibly improve the current solution.
632 if (this->canPossiblyImproveCurrentSolution(newEdge))
633 {
634 this->enqueueEdge(newEdge);
635 }
636 }
637 }
638
639 BITstar::SearchQueue::SortKey BITstar::SearchQueue::createSortKey(const VertexPtrPair &edge) const
640 {
641 // The sort key of an edge (u, v) is [ g_t(u) + c^hat(u, v) + epsilon_s * h^hat(v); g_t(u) + c^hat(u, v);
642 // g_t(u) ].
643 return {{costHelpPtr_->combineCosts(
644 costHelpPtr_->currentHeuristicToTarget(edge),
645 costHelpPtr_->inflateCost(costHelpPtr_->costToGoHeuristic(edge.second), inflationFactor_)),
646 costHelpPtr_->currentHeuristicToTarget(edge), edge.first->getCost()}};
647 }
648
649 bool BITstar::SearchQueue::lexicographicalBetterThan(const std::array<ompl::base::Cost, 3> &lhs,
650 const std::array<ompl::base::Cost, 3> &rhs) const
651 {
652 return std::lexicographical_compare(lhs.cbegin(), lhs.cend(), rhs.cbegin(), rhs.cend(),
653 [this](const ompl::base::Cost &a, const ompl::base::Cost &b)
654 { return costHelpPtr_->isCostBetterThan(a, b); });
655 }
656
657 void BITstar::SearchQueue::assertSetup() const
658 {
659 if (isSetup_ == false)
660 {
661 throw ompl::Exception("BITstar::SearchQueue was used before it was setup.");
662 }
663 }
664
666 {
667 return numEdgesPopped_;
668 }
669
670 } // namespace geometric
671} // namespace ompl
The exception type for ompl.
Definition Exception.h:47
Definition of a cost value. Can represent the cost of a motion or the cost of a state.
Definition Cost.h:48
A helper class to handle the various heuristic functions in one place.
Definition CostHelper.h:69
A conceptual representation of samples as an edge-implicit random geometric graph.
void reset()
Reset the queue to the state of construction.
VertexPtrPair popFrontEdge()
Pop the best edge off the queue, removing it from the front of the edge queue in the process.
void insertOutgoingEdges(const VertexPtr &vertex)
Update the edge queue by adding all the potential edges from the vertex to nearby states.
double getInflationFactor() const
Get the cost-to-go inflation factor.
void enableCascadingRewirings(bool enable)
Set whether cascading of rewirings is enabled.
void rebuildEdgeQueue()
Update all the sort keys of the edges in the queue and resort.
bool isEmpty()
Returns true if the queue is empty. In the case where the edge queue is empty but the vertex queue is...
std::array< ompl::base::Cost, 3u > SortKey
A triplet of costs, i.e., the edge queue sorting key.
Definition SearchQueue.h:72
VertexPtrPair getFrontEdge()
Get the best edge on the queue, leaving it at the front of the edge queue.
void removeInEdgesConnectedToVertexFromQueue(const VertexPtr &vertex)
Erase all edges in the edge queue that lead to the given vertex.
bool canPossiblyImproveCurrentSolution(const VertexPtr &state) const
The condition used to insert vertices into the queue. Compares lowerBoundHeuristicVertex to the given...
void setup(CostHelper *costHelpPtr, ImplicitGraph *graphPtr)
Setup the SearchQueue, must be called before use.
std::shared_ptr< const unsigned int > getSearchId() const
Allow access to the current search id.
void clear()
Finish the queue if it is sorted, if not resort the queue. Finishing the queue clears all the edge co...
void insertOutgoingEdgesOfStartVertices()
Insert the outgoing edges of all start vertices.
unsigned int numEdges()
Returns the number of edges in the queue. Will resort/expand the queue if necessary.
void insertOutgoingEdgesOfInconsistentVertices()
Insert the outgoing edges of all inconsistent vertices.
void registerSolutionCost(const ompl::base::Cost &solutionCost)
Mark that a solution has been found.
SortKey getFrontEdgeValue()
Get the value of the best edge on the queue, leaving it at the front of the edge queue.
void addToInconsistentSet(const VertexPtr &vertex)
Add a vertex to the set of inconsistent vertices.
void removeFromInconsistentSet(const VertexPtr &vertex)
Remove a vertex from the set of inconsistent vertices.
void removeOutEdgesConnectedToVertexFromQueue(const VertexPtr &vertex)
Erase all edges in the edge queue that leave from the given vertex.
unsigned int numEdgesPopped() const
The number of edges popped off the queue for processing (numEdgesPopped_).
void setInflationFactor(double factor)
Set the cost-to-go inflation factor.
SearchQueue(NameFunc nameFunc)
Construct a search queue. It must be setup before use.
void removeAllEdgesConnectedToVertexFromQueue(const VertexPtr &vertex)
Erase all edges in the edge queue that are connected to the given vertex.
EdgeQueue::Element * EdgeQueueElemPtr
An element pointer into the edge queue binary heap.
Definition SearchQueue.h:85
void getEdges(VertexConstPtrPairVector *edgeQueue)
Get a copy of the edge queue. This is expensive and is only meant for animations/debugging.
void update(const EdgeQueueElemPtr elementPtr)
Update the sort key of a particular edge and its position in the queue.
std::pair< SortKey, VertexPtrPair > SortKeyAndVertexPtrPair
The data stored in the edge-queue binary heap.
Definition SearchQueue.h:75
void clearInconsistentSet()
Clear the set of inconsistent vertices.
BITstar::SearchQueue::EdgeQueueElemPtrVector::const_iterator edgeQueueOutLookupConstEnd()
Get an iterator to the end of the outgoing edge queue entry vector. Will clear existing in/out lookup...
Definition Vertex.cpp:796
bool isConsistent() const
Whether the vertex is consistent.
Definition Vertex.cpp:491
BITstar::SearchQueue::EdgeQueueElemPtrVector::const_iterator edgeQueueInLookupConstBegin()
Get an iterator to the front of the incoming edge queue entry vector. Will clear existing in/out look...
Definition Vertex.cpp:651
void getChildren(VertexConstPtrVector *children) const
Get the children of a vertex as constant pointers.
Definition Vertex.cpp:303
void insertInEdgeQueueInLookup(const SearchQueue::EdgeQueueElemPtr &inEdge)
Add to the list of the edge queue entries that point in to this vertex. Will clear existing in/out lo...
Definition Vertex.cpp:546
bool isInTree() const
Get whether a vertex is in the search tree or a sample (i.e., a vertex of the RRG).
Definition Vertex.cpp:180
bool hasEverBeenExpandedAsRewiring() const
Returns whether the vertex has ever been expanded as a rewiring.
Definition Vertex.cpp:511
void clearEdgeQueueInLookup()
Clear the pointers to all of the incoming edge queue entries.
Definition Vertex.cpp:644
BITstar::SearchQueue::EdgeQueueElemPtrVector::const_iterator edgeQueueInLookupConstEnd()
Get an iterator to the end of the incoming edge queue entry vector. Will clear existing in/out lookup...
Definition Vertex.cpp:661
VertexConstPtr getParent() const
Get a const pointer to the parent of this vertex.
Definition Vertex.cpp:202
bool isPruned() const
Whether the vertex has been pruned.
Definition Vertex.cpp:496
bool isRoot() const
Returns whether the vertex is the root of the search tree.
Definition Vertex.cpp:166
BITstar::SearchQueue::EdgeQueueElemPtrVector::const_iterator edgeQueueOutLookupConstBegin()
Get an iterator to the front of the outgoing edge queue entry vector. Will clear existing in/out look...
Definition Vertex.cpp:786
void registerRewiringExpansion()
Mark expansion to vertices.
Definition Vertex.cpp:526
bool isExpandedOnCurrentSearch() const
Returns whether the vertex is expaned on current search.
Definition Vertex.cpp:506
void clearEdgeQueueOutLookup()
Clear the pointers to all of the outgoing edge queue entries.
Definition Vertex.cpp:779
BITstar::VertexId getId() const
The (unique) vertex ID.
Definition Vertex.cpp:142
std::vector< VertexPtr > VertexPtrVector
A vector of shared pointers to vertices.
Definition BITstar.h:125
std::pair< VertexPtr, VertexPtr > VertexPtrPair
A pair of vertices, i.e., an edge.
Definition BITstar.h:134
std::shared_ptr< Vertex > VertexPtr
A shared pointer to a vertex.
Definition BITstar.h:116
std::vector< VertexConstPtrPair > VertexConstPtrPairVector
A vector of pairs of const vertices, i.e., a vector of edges.
Definition BITstar.h:143
std::function< std::string()> NameFunc
A utility functor for ImplicitGraph and SearchQueue.
Definition BITstar.h:149
This namespace contains code that is specific to planning under geometric constraints.
Message namespace. This contains classes needed to output error messages (or logging) from within the...
Definition Console.h:82
Main namespace. Contains everything in this library.
STL namespace.