59 Vertex::Vertex(
const std::shared_ptr<State> &state,
60 const std::shared_ptr<ompl::base::OptimizationObjective> &objective,
61 const Direction &direction)
63 , objective_(objective)
64 , edgeCost_(objective->infiniteCost())
66 , direction_(direction)
72 if (direction_ == Direction::FORWARD)
74 state_->setCurrentCostToCome(objective_->infiniteCost());
78 assert(direction_ == Direction::REVERSE);
79 state_->setAdmissibleCostToGo(objective_->infiniteCost());
80 state_->setEstimatedCostToGo(objective_->infiniteCost());
81 state_->setEstimatedEffortToGo(std::numeric_limits<std::size_t>::max());
106 Vertex::updateCurrentCostOfChildren(
const std::shared_ptr<ompl::base::OptimizationObjective> &objective)
108 std::vector<std::shared_ptr<Vertex>> accumulatedChildren = children_;
109 for (
auto &child : children_)
111 child->getState()->setCurrentCostToCome(
112 objective->combineCosts(state_->getCurrentCostToCome(), child->getEdgeCost()));
113 const auto childsAccumulatedChildren = child->updateCurrentCostOfChildren(objective);
114 accumulatedChildren.insert(accumulatedChildren.end(), childsAccumulatedChildren.cbegin(),
115 childsAccumulatedChildren.cend());
118 return accumulatedChildren;
129 void Vertex::removeChild(
const std::shared_ptr<Vertex> &vertex)
135 const auto it = std::find_if(children_.begin(), children_.end(), [&vertex](
const auto &child)
136 { return child->getId() == vertex->getId(); });
139 assert(it != children_.end());
142 std::iter_swap(it, children_.rbegin());
143 children_.pop_back();
176 void Vertex::updateParent(
const std::shared_ptr<Vertex> &vertex)
178 assert(std::find_if(children_.begin(), children_.end(), [&vertex](
const auto &child)
179 { return vertex->getId() == child->getId(); }) == children_.end());
182 if (
auto parent = parent_.lock())
184 parent->removeChild(shared_from_this());