Skip to content

Commit 2a539b6

Browse files
committed
Merge branch 'simplify/remove-debug-stuff'
2 parents bd1157a + 19aff96 commit 2a539b6

File tree

13 files changed

+37
-172
lines changed

13 files changed

+37
-172
lines changed

src/main.cpp

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ int main(int argc, char** argv) {
3131
std::string router_arg;
3232
std::string limit_arg;
3333
std::string output_file;
34-
std::vector<std::string> heuristic_params_arg;
3534
unsigned exploration_level;
3635

3736
cxxopts::Options options("vroom",
@@ -85,22 +84,10 @@ int main(int argc, char** argv) {
8584
cxxopts::value<std::string>(cl_args.input));
8685

8786
// we don't want to print debug args on --help
88-
std::optional<unsigned> debug_depth;
89-
std::optional<unsigned> debug_nb_searches;
90-
9187
options.add_options("debug_group")
92-
("e,heuristic-param",
93-
"Heuristic parameter",
94-
cxxopts::value<std::vector<std::string>>(heuristic_params_arg))
9588
("f,apply-tsp-fix",
9689
"apply experimental TSPFix local search operator",
97-
cxxopts::value<bool>(cl_args.apply_TSPFix)->default_value("false"))
98-
("d,depth",
99-
"search depth",
100-
cxxopts::value<std::optional<unsigned>>(debug_depth))
101-
("s,nb-searches",
102-
"number of searches to perform in parallel",
103-
cxxopts::value<std::optional<unsigned>>(debug_nb_searches));
90+
cxxopts::value<bool>(cl_args.apply_TSPFix)->default_value("false"));
10491

10592
// clang-format on
10693
try {
@@ -164,12 +151,6 @@ int main(int argc, char** argv) {
164151
}
165152
exploration_level = std::min(exploration_level, vroom::MAX_EXPLORATION_LEVEL);
166153
cl_args.set_exploration_level(exploration_level);
167-
if (debug_depth) {
168-
cl_args.depth = debug_depth.value();
169-
}
170-
if (debug_nb_searches) {
171-
cl_args.nb_searches = debug_nb_searches.value();
172-
}
173154

174155
// Determine routing engine (defaults to ROUTER::OSRM).
175156
if (router_arg == "libosrm") {
@@ -188,21 +169,6 @@ int main(int argc, char** argv) {
188169
cl_args.router = vroom::ROUTER::OSRM;
189170
}
190171

191-
try {
192-
// Force heuristic parameters from the command-line, useful for
193-
// debugging.
194-
std::ranges::transform(heuristic_params_arg,
195-
std::back_inserter(cl_args.h_params),
196-
[](const auto& str_param) {
197-
return vroom::utils::str_to_heuristic_param(
198-
str_param);
199-
});
200-
} catch (const vroom::Exception& e) {
201-
std::cerr << "[Error] " << e.message << std::endl;
202-
vroom::io::write_to_json(e, cl_args.output_file);
203-
exit(e.error_code);
204-
}
205-
206172
// Get input problem from first input file, then positional arg,
207173
// then stdin.
208174
if (!cl_args.input_file.empty()) {
@@ -238,8 +204,7 @@ int main(int argc, char** argv) {
238204
: problem_instance.solve(cl_args.nb_searches,
239205
cl_args.depth,
240206
cl_args.nb_threads,
241-
cl_args.timeout,
242-
cl_args.h_params);
207+
cl_args.timeout);
243208

244209
// Write solution.
245210
vroom::io::write_to_json(sol,

src/problems/cvrp/cvrp.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ CVRP::CVRP(const Input& input) : VRP(input) {
145145
Solution CVRP::solve(const unsigned nb_searches,
146146
const unsigned depth,
147147
const unsigned nb_threads,
148-
const Timeout& timeout,
149-
const std::vector<HeuristicParameters>& h_param) const {
148+
const Timeout& timeout) const {
150149
if (_input.vehicles.size() == 1 && !_input.has_skills() &&
151150
_input.zero_amount().empty() && !_input.has_shipments() &&
152151
(_input.jobs.size() <= _input.vehicles[0].max_tasks) &&
@@ -168,7 +167,6 @@ Solution CVRP::solve(const unsigned nb_searches,
168167
depth,
169168
nb_threads,
170169
timeout,
171-
h_param,
172170
homogeneous_parameters,
173171
heterogeneous_parameters);
174172
}

src/problems/cvrp/cvrp.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ class CVRP : public VRP {
2222
public:
2323
explicit CVRP(const Input& input);
2424

25-
Solution
26-
solve(unsigned nb_searches,
27-
unsigned depth,
28-
unsigned nb_threads,
29-
const Timeout& timeout,
30-
const std::vector<HeuristicParameters>& h_param) const override;
25+
Solution solve(unsigned nb_searches,
26+
unsigned depth,
27+
unsigned nb_threads,
28+
const Timeout& timeout) const override;
3129
};
3230

3331
} // namespace vroom

src/problems/tsp/tsp.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ std::vector<Index> TSP::raw_solve(unsigned nb_threads,
297297
Solution TSP::solve(unsigned,
298298
unsigned,
299299
unsigned nb_threads,
300-
const Timeout& timeout,
301-
const std::vector<HeuristicParameters>&) const {
300+
const Timeout& timeout) const {
302301
RawRoute r(_input, 0, 0);
303302
r.set_route(_input, raw_solve(nb_threads, timeout));
304303
return utils::format_solution(_input, {r});

src/problems/tsp/tsp.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ class TSP : public VRP {
4747
Solution solve(unsigned,
4848
unsigned,
4949
unsigned nb_threads,
50-
const Timeout& timeout,
51-
const std::vector<HeuristicParameters>&) const override;
50+
const Timeout& timeout) const override;
5251
};
5352

5453
} // namespace vroom

src/problems/vrp.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,9 @@ class VRP {
188188
const unsigned depth,
189189
const unsigned nb_threads,
190190
const Timeout& timeout,
191-
const std::vector<HeuristicParameters>& h_param,
192191
const std::vector<HeuristicParameters>& homogeneous_parameters,
193192
const std::vector<HeuristicParameters>& heterogeneous_parameters) const {
194-
// Use vector of parameters when passed for debugging, else use
195-
// predefined parameter set.
196-
const auto& parameters = (!h_param.empty()) ? h_param
197-
: (_input.has_homogeneous_locations())
193+
const auto& parameters = (_input.has_homogeneous_locations())
198194
? homogeneous_parameters
199195
: heterogeneous_parameters;
200196
assert(nb_searches != 0);
@@ -273,12 +269,10 @@ class VRP {
273269

274270
virtual ~VRP();
275271

276-
virtual Solution
277-
solve(unsigned nb_searches,
278-
unsigned depth,
279-
unsigned nb_threads,
280-
const Timeout& timeout,
281-
const std::vector<HeuristicParameters>& h_param) const = 0;
272+
virtual Solution solve(unsigned nb_searches,
273+
unsigned depth,
274+
unsigned nb_threads,
275+
const Timeout& timeout) const = 0;
282276
};
283277

284278
} // namespace vroom

src/problems/vrptw/vrptw.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,11 @@ VRPTW::VRPTW(const Input& input) : VRP(input) {
143143
Solution VRPTW::solve(const unsigned nb_searches,
144144
const unsigned depth,
145145
const unsigned nb_threads,
146-
const Timeout& timeout,
147-
const std::vector<HeuristicParameters>& h_param) const {
146+
const Timeout& timeout) const {
148147
return VRP::solve<TWRoute, vrptw::LocalSearch>(nb_searches,
149148
depth,
150149
nb_threads,
151150
timeout,
152-
h_param,
153151
homogeneous_parameters,
154152
heterogeneous_parameters);
155153
}

src/problems/vrptw/vrptw.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ class VRPTW : public VRP {
2222
public:
2323
explicit VRPTW(const Input& input);
2424

25-
Solution
26-
solve(unsigned nb_searches,
27-
unsigned depth,
28-
unsigned nb_threads,
29-
const Timeout& timeout,
30-
const std::vector<HeuristicParameters>& h_param) const override;
25+
Solution solve(unsigned nb_searches,
26+
unsigned depth,
27+
unsigned nb_threads,
28+
const Timeout& timeout) const override;
3129
};
3230

3331
} // namespace vroom

src/structures/cl_args.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,18 @@ using Servers =
2323

2424
struct CLArgs {
2525
// Listing command-line options.
26-
Servers servers; // -a and -p
27-
bool check; // -c
28-
std::vector<HeuristicParameters> h_params; // -e
29-
bool apply_TSPFix; // -f
30-
bool geometry; // -g
31-
std::string input_file; // -i
32-
Timeout timeout; // -l
33-
std::string output_file; // -o
34-
ROUTER router; // -r
35-
std::string input; // cl arg
36-
unsigned nb_threads; // -t
37-
unsigned nb_searches; // derived from -x
38-
unsigned depth; // derived from -x
26+
Servers servers; // -a and -p
27+
bool check; // -c
28+
bool apply_TSPFix; // -f
29+
bool geometry; // -g
30+
std::string input_file; // -i
31+
Timeout timeout; // -l
32+
std::string output_file; // -o
33+
ROUTER router; // -r
34+
std::string input; // cl arg
35+
unsigned nb_threads; // -t
36+
unsigned nb_searches; // derived from -x
37+
unsigned depth; // derived from -x
3938

4039
void set_exploration_level(unsigned exploration_level);
4140
};

src/structures/vroom/input/input.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,20 +1200,17 @@ std::unique_ptr<VRP> Input::get_problem() const {
12001200

12011201
Solution Input::solve(const unsigned exploration_level,
12021202
const unsigned nb_thread,
1203-
const Timeout& timeout,
1204-
const std::vector<HeuristicParameters>& h_param) {
1203+
const Timeout& timeout) {
12051204
return solve(utils::get_nb_searches(exploration_level),
12061205
utils::get_depth(exploration_level),
12071206
nb_thread,
1208-
timeout,
1209-
h_param);
1207+
timeout);
12101208
}
12111209

12121210
Solution Input::solve(const unsigned nb_searches,
12131211
const unsigned depth,
12141212
const unsigned nb_thread,
1215-
const Timeout& timeout,
1216-
const std::vector<HeuristicParameters>& h_param) {
1213+
const Timeout& timeout) {
12171214
run_basic_checks();
12181215

12191216
if (_has_initial_routes) {
@@ -1253,8 +1250,7 @@ Solution Input::solve(const unsigned nb_searches,
12531250
}
12541251

12551252
// Solve.
1256-
auto sol =
1257-
instance->solve(nb_searches, depth, nb_thread, solve_time, h_param);
1253+
auto sol = instance->solve(nb_searches, depth, nb_thread, solve_time);
12581254

12591255
// Update timing info.
12601256
sol.summary.computing_times.loading = loading.count();

0 commit comments

Comments
 (0)