From cda4a331e50639d6e6b5484cb11c94558120d9ea Mon Sep 17 00:00:00 2001 From: Romain BERNARD <romain.bernard@uca.fr> Date: Tue, 12 Mar 2024 18:06:11 +0100 Subject: [PATCH] prevent domination of a state compared with itself --- src/ShortestPath/Transit/TransitAlgorithmState.h | 3 ++- src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ShortestPath/Transit/TransitAlgorithmState.h b/src/ShortestPath/Transit/TransitAlgorithmState.h index 29ad87a..0bfbd83 100644 --- a/src/ShortestPath/Transit/TransitAlgorithmState.h +++ b/src/ShortestPath/Transit/TransitAlgorithmState.h @@ -152,7 +152,8 @@ public: * @return */ [[nodiscard]] bool strictlyDominates(const TransitAlgorithmState& rhs) const { - return this->getInstant() <= rhs.getInstant() && this->getConnections().size() <= rhs.getConnections().size(); + return (this->getInstant() < rhs.getInstant() && this->getConnections().size() <= rhs.getConnections().size()) + || (this->getInstant() == rhs.getInstant() && this->getConnections().size() < rhs.getConnections().size()); } /** diff --git a/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp b/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp index 4bcf332..543e70f 100644 --- a/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp +++ b/src/ShortestPath/Transit/TransitShortestPathPrecompute.cpp @@ -63,8 +63,7 @@ TransitStateContainer TransitShortestPathPrecompute::executeAlgorithm(const Grap DEBUG_MSG("Created new state " + newState.toString()); //Add new state to the solution container and the priority queue if it's not strictly dominated by an existing solution - if(!solutionsContainer.strictlyDominates(currentState)) { - DEBUG_MSG("Candidate state " + newState.toString() + " is being added to solution container and priority queue"); + if(newState.getNodeIndex() != -1 && !solutionsContainer.strictlyDominates(newState)) { DEBUG_MSG("Candidate state " + newState.toString() + " is being added to solution container and priority queue\n"); solutionsContainer.addNewState(nextNode, newState); statePriorityQueue.emplace(newState); -- GitLab