From 0c1ecbf0796b20e920a0fbb5e4aac63bc0dfcc50 Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Thu, 20 Nov 2025 08:00:32 +0100 Subject: [PATCH] Directly lift solutions of SerialContainer To avoid the impression of starvation, directly lift solutions instead of enumerating and sorting them first. Sorting is handled in the parent's container too. --- core/src/container.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/core/src/container.cpp b/core/src/container.cpp index c1fc23f11..fa60a2ece 100644 --- a/core/src/container.cpp +++ b/core/src/container.cpp @@ -534,24 +534,24 @@ void SerialContainer::onNewSolution(const SolutionBase& current) { SolutionCollector incoming(num_before, current); SolutionCollector outgoing(num_after, current); - // collect (and sort) all solutions spanning from start to end of this container - ordered sorted; + // collect (and lift) all solutions spanning from start to end of this container for (auto& in : incoming.solutions) { for (auto& out : outgoing.solutions) { InterfaceState::Priority prio = in.second + InterfaceState::Priority(1u, current.cost()) + out.second; assert(prio.enabled()); // found a complete solution path connecting start to end? if (prio.depth() == children.size()) { - SolutionSequence::container_type solution; - solution.reserve(children.size()); + SolutionSequence::container_type seq; + seq.reserve(children.size()); // insert incoming solutions in reverse order - solution.insert(solution.end(), in.first.rbegin(), in.first.rend()); + seq.insert(seq.end(), in.first.rbegin(), in.first.rend()); // insert current solution - solution.push_back(¤t); + seq.push_back(¤t); // insert outgoing solutions in normal order - solution.insert(solution.end(), out.first.begin(), out.first.end()); - // store solution in sorted list - sorted.insert(std::make_shared(std::move(solution), prio.cost(), this)); + seq.insert(seq.end(), out.first.begin(), out.first.end()); + // create SolutionSequence and lift it to external interface + auto solution = std::make_shared(std::move(seq), prio.cost(), this); + impl->liftSolution(solution, solution->internalStart(), solution->internalEnd()); } if (prio.depth() > 1) { // update state priorities along the whole partial solution path @@ -561,10 +561,6 @@ void SerialContainer::onNewSolution(const SolutionBase& current) { } } // printChildrenInterfaces(*this->pimpl(), true, *current.creator()); - - // finally, store + announce new solutions to external interface - for (const auto& solution : sorted) - impl->liftSolution(solution, solution->internalStart(), solution->internalEnd()); } SerialContainer::SerialContainer(SerialContainerPrivate* impl) : ContainerBase(impl) {}