diff --git a/src/structures/cl_args.cpp b/src/structures/cl_args.cpp index caf7c08d..5dfeac31 100644 --- a/src/structures/cl_args.cpp +++ b/src/structures/cl_args.cpp @@ -10,6 +10,7 @@ All rights reserved (see LICENSE). #include #include "structures/cl_args.h" +#include "utils/helpers.h" namespace vroom::io { @@ -75,28 +76,10 @@ void update_port(Servers& servers, std::string_view value) { } } -unsigned CLArgs::get_depth(unsigned exploration_level) { - return exploration_level; -} - -unsigned CLArgs::get_nb_searches(unsigned exploration_level) { - assert(exploration_level <= MAX_EXPLORATION_LEVEL); - - unsigned nb_searches = 4 * (exploration_level + 1); - if (exploration_level >= 4) { - nb_searches += 4; - } - if (exploration_level == MAX_EXPLORATION_LEVEL) { - nb_searches += 4; - } - - return nb_searches; -} - void CLArgs::set_exploration_level(unsigned exploration_level) { - depth = get_depth(exploration_level); + depth = utils::get_depth(exploration_level); - nb_searches = get_nb_searches(exploration_level); + nb_searches = utils::get_nb_searches(exploration_level); } } // namespace vroom::io diff --git a/src/structures/cl_args.h b/src/structures/cl_args.h index 53f3c131..71b4ef9e 100644 --- a/src/structures/cl_args.h +++ b/src/structures/cl_args.h @@ -37,10 +37,6 @@ struct CLArgs { unsigned nb_searches; // derived from -x unsigned depth; // derived from -x - static unsigned get_depth(unsigned exploration_level); - - static unsigned get_nb_searches(unsigned exploration_level); - void set_exploration_level(unsigned exploration_level); }; diff --git a/src/structures/vroom/input/input.cpp b/src/structures/vroom/input/input.cpp index 6ac64d6d..74df05fd 100644 --- a/src/structures/vroom/input/input.cpp +++ b/src/structures/vroom/input/input.cpp @@ -1118,6 +1118,17 @@ std::unique_ptr Input::get_problem() const { return std::make_unique(*this); } +Solution Input::solve(unsigned exploration_level, + unsigned nb_thread, + const Timeout& timeout, + const std::vector& h_param) { + return solve(utils::get_nb_searches(exploration_level), + utils::get_depth(exploration_level), + nb_thread, + timeout, + h_param); +} + Solution Input::solve(unsigned nb_searches, unsigned depth, unsigned nb_thread, diff --git a/src/structures/vroom/input/input.h b/src/structures/vroom/input/input.h index 7f2478ed..c7122e2e 100644 --- a/src/structures/vroom/input/input.h +++ b/src/structures/vroom/input/input.h @@ -16,7 +16,6 @@ All rights reserved (see LICENSE). #include #include "routing/wrapper.h" -#include "structures/cl_args.h" #include "structures/generic/matrix.h" #include "structures/typedefs.h" #include "structures/vroom/matrices.h" @@ -194,23 +193,16 @@ class Input { // Returns true iff both vehicles have common job candidates. bool vehicle_ok_with_vehicle(Index v1_index, Index v2_index) const; - Solution solve(unsigned exploration_level, + Solution solve(unsigned nb_searches, + unsigned depth, unsigned nb_thread, const Timeout& timeout = Timeout(), const std::vector& h_param = - std::vector()) { - // Overload designed to expose the same interface as the `-x` - // command-line flag for out-of-the-box setup of exploration - // level. - return solve(io::CLArgs::get_nb_searches(exploration_level), - io::CLArgs::get_depth(exploration_level), - nb_thread, - timeout, - h_param); - } + std::vector()); - Solution solve(unsigned nb_searches, - unsigned depth, + // Overload designed to expose the same interface as the `-x` + // command-line flag for out-of-the-box setup of exploration level. + Solution solve(unsigned exploration_level, unsigned nb_thread, const Timeout& timeout = Timeout(), const std::vector& h_param = diff --git a/src/utils/helpers.h b/src/utils/helpers.h index 8a061ff3..e0917078 100644 --- a/src/utils/helpers.h +++ b/src/utils/helpers.h @@ -38,6 +38,24 @@ inline UserCost add_without_overflow(UserCost a, UserCost b) { return a + b; } +inline unsigned get_depth(unsigned exploration_level) { + return exploration_level; +} + +inline unsigned get_nb_searches(unsigned exploration_level) { + assert(exploration_level <= MAX_EXPLORATION_LEVEL); + + unsigned nb_searches = 4 * (exploration_level + 1); + if (exploration_level >= 4) { + nb_searches += 4; + } + if (exploration_level == MAX_EXPLORATION_LEVEL) { + nb_searches += 4; + } + + return nb_searches; +} + INIT get_init(std::string_view s); SORT get_sort(std::string_view s);