diff --git a/src/main.cpp b/src/main.cpp index cd265ff29..d6989604d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,7 +31,6 @@ int main(int argc, char** argv) { std::string router_arg; std::string limit_arg; std::string output_file; - std::vector heuristic_params_arg; unsigned exploration_level; cxxopts::Options options("vroom", @@ -85,22 +84,10 @@ int main(int argc, char** argv) { cxxopts::value(cl_args.input)); // we don't want to print debug args on --help - std::optional debug_depth; - std::optional debug_nb_searches; - options.add_options("debug_group") - ("e,heuristic-param", - "Heuristic parameter", - cxxopts::value>(heuristic_params_arg)) ("f,apply-tsp-fix", "apply experimental TSPFix local search operator", - cxxopts::value(cl_args.apply_TSPFix)->default_value("false")) - ("d,depth", - "search depth", - cxxopts::value>(debug_depth)) - ("s,nb-searches", - "number of searches to perform in parallel", - cxxopts::value>(debug_nb_searches)); + cxxopts::value(cl_args.apply_TSPFix)->default_value("false")); // clang-format on try { @@ -164,12 +151,6 @@ int main(int argc, char** argv) { } exploration_level = std::min(exploration_level, vroom::MAX_EXPLORATION_LEVEL); cl_args.set_exploration_level(exploration_level); - if (debug_depth) { - cl_args.depth = debug_depth.value(); - } - if (debug_nb_searches) { - cl_args.nb_searches = debug_nb_searches.value(); - } // Determine routing engine (defaults to ROUTER::OSRM). if (router_arg == "libosrm") { @@ -188,21 +169,6 @@ int main(int argc, char** argv) { cl_args.router = vroom::ROUTER::OSRM; } - try { - // Force heuristic parameters from the command-line, useful for - // debugging. - std::ranges::transform(heuristic_params_arg, - std::back_inserter(cl_args.h_params), - [](const auto& str_param) { - return vroom::utils::str_to_heuristic_param( - str_param); - }); - } catch (const vroom::Exception& e) { - std::cerr << "[Error] " << e.message << std::endl; - vroom::io::write_to_json(e, cl_args.output_file); - exit(e.error_code); - } - // Get input problem from first input file, then positional arg, // then stdin. if (!cl_args.input_file.empty()) { @@ -238,8 +204,7 @@ int main(int argc, char** argv) { : problem_instance.solve(cl_args.nb_searches, cl_args.depth, cl_args.nb_threads, - cl_args.timeout, - cl_args.h_params); + cl_args.timeout); // Write solution. vroom::io::write_to_json(sol, diff --git a/src/problems/cvrp/cvrp.cpp b/src/problems/cvrp/cvrp.cpp index 97c0b6971..9666ce0a2 100644 --- a/src/problems/cvrp/cvrp.cpp +++ b/src/problems/cvrp/cvrp.cpp @@ -145,8 +145,7 @@ CVRP::CVRP(const Input& input) : VRP(input) { Solution CVRP::solve(const unsigned nb_searches, const unsigned depth, const unsigned nb_threads, - const Timeout& timeout, - const std::vector& h_param) const { + const Timeout& timeout) const { if (_input.vehicles.size() == 1 && !_input.has_skills() && _input.zero_amount().empty() && !_input.has_shipments() && (_input.jobs.size() <= _input.vehicles[0].max_tasks) && @@ -168,7 +167,6 @@ Solution CVRP::solve(const unsigned nb_searches, depth, nb_threads, timeout, - h_param, homogeneous_parameters, heterogeneous_parameters); } diff --git a/src/problems/cvrp/cvrp.h b/src/problems/cvrp/cvrp.h index 2385e5060..8ce0c26e7 100644 --- a/src/problems/cvrp/cvrp.h +++ b/src/problems/cvrp/cvrp.h @@ -22,12 +22,10 @@ class CVRP : public VRP { public: explicit CVRP(const Input& input); - Solution - solve(unsigned nb_searches, - unsigned depth, - unsigned nb_threads, - const Timeout& timeout, - const std::vector& h_param) const override; + Solution solve(unsigned nb_searches, + unsigned depth, + unsigned nb_threads, + const Timeout& timeout) const override; }; } // namespace vroom diff --git a/src/problems/tsp/tsp.cpp b/src/problems/tsp/tsp.cpp index 8c7c1fd01..96816b0ad 100644 --- a/src/problems/tsp/tsp.cpp +++ b/src/problems/tsp/tsp.cpp @@ -297,8 +297,7 @@ std::vector TSP::raw_solve(unsigned nb_threads, Solution TSP::solve(unsigned, unsigned, unsigned nb_threads, - const Timeout& timeout, - const std::vector&) const { + const Timeout& timeout) const { RawRoute r(_input, 0, 0); r.set_route(_input, raw_solve(nb_threads, timeout)); return utils::format_solution(_input, {r}); diff --git a/src/problems/tsp/tsp.h b/src/problems/tsp/tsp.h index ac33410c0..ea4c2fdac 100644 --- a/src/problems/tsp/tsp.h +++ b/src/problems/tsp/tsp.h @@ -47,8 +47,7 @@ class TSP : public VRP { Solution solve(unsigned, unsigned, unsigned nb_threads, - const Timeout& timeout, - const std::vector&) const override; + const Timeout& timeout) const override; }; } // namespace vroom diff --git a/src/problems/vrp.h b/src/problems/vrp.h index e5ed1469e..57a4af8cb 100644 --- a/src/problems/vrp.h +++ b/src/problems/vrp.h @@ -188,13 +188,9 @@ class VRP { const unsigned depth, const unsigned nb_threads, const Timeout& timeout, - const std::vector& h_param, const std::vector& homogeneous_parameters, const std::vector& heterogeneous_parameters) const { - // Use vector of parameters when passed for debugging, else use - // predefined parameter set. - const auto& parameters = (!h_param.empty()) ? h_param - : (_input.has_homogeneous_locations()) + const auto& parameters = (_input.has_homogeneous_locations()) ? homogeneous_parameters : heterogeneous_parameters; assert(nb_searches != 0); @@ -273,12 +269,10 @@ class VRP { virtual ~VRP(); - virtual Solution - solve(unsigned nb_searches, - unsigned depth, - unsigned nb_threads, - const Timeout& timeout, - const std::vector& h_param) const = 0; + virtual Solution solve(unsigned nb_searches, + unsigned depth, + unsigned nb_threads, + const Timeout& timeout) const = 0; }; } // namespace vroom diff --git a/src/problems/vrptw/vrptw.cpp b/src/problems/vrptw/vrptw.cpp index 5ef35d2e3..451ff964d 100644 --- a/src/problems/vrptw/vrptw.cpp +++ b/src/problems/vrptw/vrptw.cpp @@ -143,13 +143,11 @@ VRPTW::VRPTW(const Input& input) : VRP(input) { Solution VRPTW::solve(const unsigned nb_searches, const unsigned depth, const unsigned nb_threads, - const Timeout& timeout, - const std::vector& h_param) const { + const Timeout& timeout) const { return VRP::solve(nb_searches, depth, nb_threads, timeout, - h_param, homogeneous_parameters, heterogeneous_parameters); } diff --git a/src/problems/vrptw/vrptw.h b/src/problems/vrptw/vrptw.h index eefa5163c..06a35110b 100644 --- a/src/problems/vrptw/vrptw.h +++ b/src/problems/vrptw/vrptw.h @@ -22,12 +22,10 @@ class VRPTW : public VRP { public: explicit VRPTW(const Input& input); - Solution - solve(unsigned nb_searches, - unsigned depth, - unsigned nb_threads, - const Timeout& timeout, - const std::vector& h_param) const override; + Solution solve(unsigned nb_searches, + unsigned depth, + unsigned nb_threads, + const Timeout& timeout) const override; }; } // namespace vroom diff --git a/src/structures/cl_args.h b/src/structures/cl_args.h index 68249b417..4a0713872 100644 --- a/src/structures/cl_args.h +++ b/src/structures/cl_args.h @@ -23,19 +23,18 @@ using Servers = struct CLArgs { // Listing command-line options. - Servers servers; // -a and -p - bool check; // -c - std::vector h_params; // -e - bool apply_TSPFix; // -f - bool geometry; // -g - std::string input_file; // -i - Timeout timeout; // -l - std::string output_file; // -o - ROUTER router; // -r - std::string input; // cl arg - unsigned nb_threads; // -t - unsigned nb_searches; // derived from -x - unsigned depth; // derived from -x + Servers servers; // -a and -p + bool check; // -c + bool apply_TSPFix; // -f + bool geometry; // -g + std::string input_file; // -i + Timeout timeout; // -l + std::string output_file; // -o + ROUTER router; // -r + std::string input; // cl arg + unsigned nb_threads; // -t + unsigned nb_searches; // derived from -x + unsigned depth; // derived from -x void set_exploration_level(unsigned exploration_level); }; diff --git a/src/structures/vroom/input/input.cpp b/src/structures/vroom/input/input.cpp index f6f91bf38..705b5c758 100644 --- a/src/structures/vroom/input/input.cpp +++ b/src/structures/vroom/input/input.cpp @@ -1200,20 +1200,17 @@ std::unique_ptr Input::get_problem() const { Solution Input::solve(const unsigned exploration_level, const unsigned nb_thread, - const Timeout& timeout, - const std::vector& h_param) { + const Timeout& timeout) { return solve(utils::get_nb_searches(exploration_level), utils::get_depth(exploration_level), nb_thread, - timeout, - h_param); + timeout); } Solution Input::solve(const unsigned nb_searches, const unsigned depth, const unsigned nb_thread, - const Timeout& timeout, - const std::vector& h_param) { + const Timeout& timeout) { run_basic_checks(); if (_has_initial_routes) { @@ -1253,8 +1250,7 @@ Solution Input::solve(const unsigned nb_searches, } // Solve. - auto sol = - instance->solve(nb_searches, depth, nb_thread, solve_time, h_param); + auto sol = instance->solve(nb_searches, depth, nb_thread, solve_time); // Update timing info. sol.summary.computing_times.loading = loading.count(); diff --git a/src/structures/vroom/input/input.h b/src/structures/vroom/input/input.h index 6e786f876..ad0e96ce3 100644 --- a/src/structures/vroom/input/input.h +++ b/src/structures/vroom/input/input.h @@ -208,17 +208,13 @@ class Input { Solution solve(unsigned nb_searches, unsigned depth, unsigned nb_thread, - const Timeout& timeout = Timeout(), - const std::vector& h_param = - std::vector()); + const Timeout& timeout = Timeout()); // 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 = - std::vector()); + const Timeout& timeout = Timeout()); Solution check(unsigned nb_thread); }; diff --git a/src/utils/helpers.cpp b/src/utils/helpers.cpp index 848ba56b2..b49b14e0a 100644 --- a/src/utils/helpers.cpp +++ b/src/utils/helpers.cpp @@ -28,75 +28,6 @@ Amount max_amount(std::size_t size) { return max; } -INIT get_init(std::string_view s) { - using enum INIT; - if (s == "NONE") { - return NONE; - } - if (s == "HIGHER_AMOUNT") { - return HIGHER_AMOUNT; - } - if (s == "NEAREST") { - return NEAREST; - } - if (s == "FURTHEST") { - return FURTHEST; - } - if (s == "EARLIEST_DEADLINE") { - return EARLIEST_DEADLINE; - } - throw InputException("Invalid heuristic parameter in command-line."); -} - -SORT get_sort(std::string_view s) { - if (s == "AVAILABILITY") { - return SORT::AVAILABILITY; - } - if (s == "COST") { - return SORT::COST; - } - throw InputException("Invalid heuristic parameter in command-line."); -} - -HeuristicParameters str_to_heuristic_param(const std::string& s) { - // Split command-line string describing parameters. - constexpr char delimiter = ';'; - std::vector tokens; - tokens.reserve(4); - std::string token; - std::istringstream tokenStream(s); - while (std::getline(tokenStream, token, delimiter)) { - tokens.push_back(token); - } - - if ((tokens.size() != 3 && tokens.size() != 4) || tokens[0].size() != 1) { - throw InputException("Invalid heuristic parameter in command-line."); - } - - auto init = get_init(tokens[1]); - auto sort = (tokens.size() == 3) ? SORT::AVAILABILITY : get_sort(tokens[3]); - - try { - auto h = std::stoul(tokens[0]); - - if (h != 0 && h != 1) { - throw InputException("Invalid heuristic parameter in command-line."); - } - - auto regret_coeff = std::stof(tokens[2]); - if (regret_coeff < 0) { - throw InputException("Invalid heuristic parameter in command-line."); - } - - return HeuristicParameters(static_cast(h), - init, - regret_coeff, - sort); - } catch (const std::exception&) { - throw InputException("Invalid heuristic parameter in command-line."); - } -} - Priority priority_sum_for_route(const Input& input, const std::vector& route) { return std::accumulate(route.begin(), diff --git a/src/utils/helpers.h b/src/utils/helpers.h index 221656d87..1475bdb1f 100644 --- a/src/utils/helpers.h +++ b/src/utils/helpers.h @@ -70,12 +70,6 @@ inline unsigned get_nb_searches(unsigned exploration_level) { return nb_searches; } -INIT get_init(std::string_view s); - -SORT get_sort(std::string_view s); - -HeuristicParameters str_to_heuristic_param(const std::string& s); - // Evaluate adding job with rank job_rank in given route at given rank // for vehicle v. inline Eval addition_eval(const Input& input,