From 407be6f63116791eddb799ea53edd0333a3a4ed2 Mon Sep 17 00:00:00 2001 From: Romain BERNARD <romain.bernard@uca.fr> Date: Mon, 24 Jun 2024 17:39:45 +0200 Subject: [PATCH] replace vehicle weight macro with a constexpr --- CMakeLists.txt | 1 + src/instance/SAEVehicle.h | 6 ++---- src/utils/Constants.h | 15 +++++++++++++++ test/CMakeLists.txt | 2 ++ 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/utils/Constants.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d6e9993..0423a97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,7 @@ add_executable(GreedyAlgorithm "src/utils/Instance Generation/Graph/OSRMGraphGenerator.h" src/routes/vehicle/BestRequestInsertion.h src/routes/vehicle/BestInsertionQueue.h + src/utils/Constants.h ) add_executable(RequestGenerator diff --git a/src/instance/SAEVehicle.h b/src/instance/SAEVehicle.h index 2efee9e..c7e5ceb 100644 --- a/src/instance/SAEVehicle.h +++ b/src/instance/SAEVehicle.h @@ -5,13 +5,11 @@ #ifndef GREEDYALGORITHM_SAEVEHICLE_H #define GREEDYALGORITHM_SAEVEHICLE_H -#define VEHICLE_CAPACITY 6 - - +#include "../utils/Constants.h" class SAEVehicle { private: - static const int _capacity{VEHICLE_CAPACITY}; + static const int _capacity{Constants::VEHICLE_CAPACITY}; public: SAEVehicle() = default; diff --git a/src/utils/Constants.h b/src/utils/Constants.h new file mode 100644 index 0000000..47f3b51 --- /dev/null +++ b/src/utils/Constants.h @@ -0,0 +1,15 @@ +// +// Created by romain on 24/06/24. +// + +#ifndef GREEDYALGORITHM_CONSTANTS_H +#define GREEDYALGORITHM_CONSTANTS_H + + +class Constants { +public: + static constexpr int VEHICLE_CAPACITY = 4; +}; + + +#endif //GREEDYALGORITHM_CONSTANTS_H diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 59926f7..5d97ecd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -70,6 +70,7 @@ add_executable(Constraint_Propag_DEB "../src/utils/Instance Generation/Requests/RequestsGenerator.h" "../src/utils/Instance Generation/Requests/RequestGenerationParameters.h" "../src/utils/Instance Generation/Graph/OSRMGraphGenerator.h" + ../src/utils/Constants.h ) add_executable(BestInsertionHeuristic_DEB @@ -104,6 +105,7 @@ add_executable(BestInsertionHeuristic_DEB ../src/routes/vehicle/BestInsertionQueue.h ../src/algorithm/DARP/Heuristics/BestInsertionHeuristic.cpp ../src/algorithm/DARP/Heuristics/BestInsertionHeuristic.h + ../src/utils/Constants.h ) target_link_libraries(Line_UT gtest gtest_main) -- GitLab