27 #include "../../util/Metrics.h"
51 std::numeric_limits<Ice::Float>::infinity(),
58 AdaptiveDynamicDomainParameters {1, 1, 1},
66 const FullIceTree& iceTree,
67 AdaptiveDynamicDomainParameters newaddParams,
68 std::size_t newWorkerId
71 addParams = newaddParams;
72 workerId = newWorkerId;
80 appliedUpdateIds.clear();
81 appliedUpdateIds = iceTree.updateIds;
87 for (
const auto& workerNodes : iceTree.nodes)
89 nodeCount += workerNodes.size();
91 nodes.back().resize(workerNodes.size());
97 for (std::size_t wId = 0; wId < nodes.size(); ++wId)
99 for (std::size_t nId = 0; nId < nodes.at(wId).size(); ++nId)
101 NodeType& localNode = nodes.at(wId).at(nId);
102 const FullNodeData& iceNode = iceTree.nodes.at(wId).at(nId);
103 localNode.
config = iceNode.config;
104 localNode.
parent = iceNode.parent;
105 localNode.
radius = iceNode.radius;
108 getNode(localNode.
parent).children.insert(NodeId
117 getNode(ROOT_ID).children.erase(ROOT_ID);
129 if (
nodes.size() < count)
140 for (std::size_t i = 0; i < u.dependetOnUpdateIds.size(); ++i)
153 const auto workerId = getUpdatesWorkerId(u);
166 for (
const auto& nodeCreationUpdate : u.nodes)
172 for (
const auto& rewireUpdate : u.rewires)
178 for (
const auto& radiusUpdate : u.radii)
215 const NodeId& child = rewireUpdate.child;
216 const NodeId& newParent = rewireUpdate.newParent;
223 ((costOld == costNew) && (rewireUpdate.newParent.workerId >
getNode(child).parent.workerId))
254 for (
const auto& child :
getNode(root).children)
264 auto& parentNode =
getNode(parent);
270 std::numeric_limits<float>::infinity(),
276 parentNode.children.insert(
id);
281 void Tree::doSetNodeParent(
const NodeId& child,
const NodeId& newParent,
float fromParentCost,
bool updateFromStartCost)
291 if (updateFromStartCost)
300 if (
getNode(
id).radius < std::numeric_limits<float>::infinity())
316 std::vector<std::pair<NodeId, float>> idDistanceVector {};
317 idDistanceVector.reserve(
size());
319 for (std::size_t workerLevelIndex = 0; workerLevelIndex <
nodes.size(); ++workerLevelIndex)
321 for (std::size_t nodeLevelIndex = 0; nodeLevelIndex <
nodes.at(workerLevelIndex).
size(); ++nodeLevelIndex)
328 idDistanceVector.emplace_back(
id, dist);
335 if (k < idDistanceVector.size())
338 idDistanceVector.begin(),
339 idDistanceVector.begin() + (k - 1),
340 idDistanceVector.end(),
341 [](
const std::pair<NodeId, float>& lhs,
const std::pair<NodeId, float>& rhs)
343 return lhs.second < rhs.second;
346 idDistanceVector.resize(k);
348 idDistanceVector.shrink_to_fit();
351 return idDistanceVector;
356 const auto worker =
static_cast<std::size_t
>(
id.workerId);
357 const auto node =
static_cast<std::size_t
>(
id.numberOfNode);
360 return nodes.at(worker).at(node);
365 const auto worker =
static_cast<std::size_t
>(
id.workerId);
366 const auto node =
static_cast<std::size_t
>(
id.numberOfNode);
369 return nodes.at(worker).at(node);
376 throw std::out_of_range {
"index >= size"};
381 for (
const auto& workerNodes :
nodes)
383 if (
index < workerNodes.size())
390 index -= workerNodes.size();
396 throw std::logic_error {
"Tree size decreased during id calculation!"};
402 return ((min_elem ==
goalNodes.end()) ? std::numeric_limits<float>::infinity() :
getNode(min_elem->node).
fromStartCost + min_elem->costToGoToGoal);
410 const auto id = min_elem->node;
429 const auto& node =
getNode(
id);
430 pathIds.emplace_back(
id);
447 const auto& node =
getNode(
id);
448 path.emplace_back(node.config);
460 FullNodeDataListList allNodes {};
461 allNodes.resize(
nodes.size());
463 for (std::size_t workerLevelIndex = 0; workerLevelIndex <
nodes.size(); ++workerLevelIndex)
465 FullNodeDataList& iceWorkerNodes = allNodes.at(workerLevelIndex);
466 const auto& workerNodes =
nodes.at(workerLevelIndex);
467 iceWorkerNodes.resize(workerNodes.size());
469 for (std::size_t nodeLevelIndex = 0; nodeLevelIndex < iceWorkerNodes.size(); ++nodeLevelIndex)
471 const auto& localNode = workerNodes.at(nodeLevelIndex);
472 FullNodeData& iceNode = iceWorkerNodes.at(nodeLevelIndex);
473 iceNode.config = localNode.config;
474 iceNode.parent = localNode.parent;
475 iceNode.radius = localNode.radius;
476 iceNode.fromParentCost = localNode.fromParentCost;
487 const auto nodeId = getUpdatesWorkerId(u);
488 const auto updateSubId = getUpdatesSubId(u);