From 69a9deb6bae8fb4713d4d8c45af23b0d5a64cee4 Mon Sep 17 00:00:00 2001 From: Romain BERNARD <romain.bernard@uca.fr> Date: Thu, 20 Jun 2024 16:57:17 +0200 Subject: [PATCH] remove const identifier in BestRequestInsertion to use those values in insertion algorithm --- src/routes/vehicle/BestRequestInsertion.h | 10 +++++----- src/routes/vehicle/SAEVRoute.cpp | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/routes/vehicle/BestRequestInsertion.h b/src/routes/vehicle/BestRequestInsertion.h index 0a19ab7..232421d 100644 --- a/src/routes/vehicle/BestRequestInsertion.h +++ b/src/routes/vehicle/BestRequestInsertion.h @@ -13,8 +13,8 @@ class BestRequestInsertion { private: - const SAEVKeyPoint* _originInsertionKP; - const SAEVKeyPoint* _destinationInsertionKP; + SAEVKeyPoint* _originInsertionKP; + SAEVKeyPoint* _destinationInsertionKP; double _score{ std::numeric_limits<double>::max() }; public: @@ -28,11 +28,11 @@ public: * @param destinationInsertionKP Index of insertion for the destination of the request in the route * @param score */ - BestRequestInsertion(const SAEVKeyPoint *originInsertionKP, const SAEVKeyPoint *destinationInsertionKP, double score) + BestRequestInsertion(SAEVKeyPoint *originInsertionKP, SAEVKeyPoint *destinationInsertionKP, double score) : _originInsertionKP(originInsertionKP), _destinationInsertionKP(destinationInsertionKP), _score(score) {}; - [[nodiscard]] const SAEVKeyPoint *getOriginInsertionKp() const { + [[nodiscard]] SAEVKeyPoint *getOriginInsertionKp() { return _originInsertionKP; } @@ -40,7 +40,7 @@ public: _originInsertionKP = originInsertionKp; } - [[nodiscard]] const SAEVKeyPoint *getDestinationInsertionKp() const { + [[nodiscard]] SAEVKeyPoint *getDestinationInsertionKp() { return _destinationInsertionKP; } diff --git a/src/routes/vehicle/SAEVRoute.cpp b/src/routes/vehicle/SAEVRoute.cpp index 08d2579..7d15347 100644 --- a/src/routes/vehicle/SAEVRoute.cpp +++ b/src/routes/vehicle/SAEVRoute.cpp @@ -369,20 +369,20 @@ BestInsertionQueue SAEVRoute::getBestInsertionsQueue(size_t requestId, size_t ve //Init variables used during iteration double score; - SAEVKeyPoint const* originKeyPoint = &getOriginDepot(vehicleId); - SAEVKeyPoint const* destinationKeyPoint = originKeyPoint; + SAEVKeyPoint * originInsertionKeyPoint = &getOriginDepot(vehicleId); + SAEVKeyPoint * destinationInsertionKeyPoint = originInsertionKeyPoint; //iterate over possible origin/destination pairs for the given vehicle - while(originKeyPoint->getSuccessor() != nullptr) { - while(destinationKeyPoint->getSuccessor() != nullptr) { - score = getDetourScore(requestId, *originKeyPoint, *destinationKeyPoint); - bestInsertionQueue.emplace(originKeyPoint, destinationKeyPoint, score); - destinationKeyPoint = destinationKeyPoint->getSuccessor(); + while(originInsertionKeyPoint->getSuccessor() != nullptr) { + while(destinationInsertionKeyPoint->getSuccessor() != nullptr) { + score = getDetourScore(requestId, *originInsertionKeyPoint, *destinationInsertionKeyPoint); + bestInsertionQueue.emplace(originInsertionKeyPoint, destinationInsertionKeyPoint, score); + destinationInsertionKeyPoint = destinationInsertionKeyPoint->getSuccessor(); } //Iterate over possible origins and reset destination to being the same point as the origin - originKeyPoint = originKeyPoint->getSuccessor(); - destinationKeyPoint = originKeyPoint; + originInsertionKeyPoint = originInsertionKeyPoint->getSuccessor(); + destinationInsertionKeyPoint = originInsertionKeyPoint; } return bestInsertionQueue; -- GitLab