From 049c9d7c5105dcf60a4533db4655b813caf41c61 Mon Sep 17 00:00:00 2001 From: reinterpretcat Date: Wed, 16 Oct 2024 20:28:45 +0200 Subject: [PATCH] Apply minor refactorings --- vrp-pragmatic/src/format/problem/job_reader.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/vrp-pragmatic/src/format/problem/job_reader.rs b/vrp-pragmatic/src/format/problem/job_reader.rs index 619054b36..87cff62a4 100644 --- a/vrp-pragmatic/src/format/problem/job_reader.rs +++ b/vrp-pragmatic/src/format/problem/job_reader.rs @@ -35,11 +35,10 @@ pub(super) fn read_jobs_with_extra_locks( let random = &environment.random; let logger = &environment.logger; - let (mut jobs, mut locks) = read_required_jobs(api_problem, props, coord_index, job_index, random); - let (conditional_jobs, conditional_locks) = read_conditional_jobs(api_problem, coord_index, job_index); + let (mut jobs, locks) = read_required_jobs(api_problem, props, coord_index, job_index, random); + let conditional_jobs = read_conditional_jobs(api_problem, coord_index, job_index); jobs.extend(conditional_jobs); - locks.extend(conditional_locks); (Jobs::new(fleet, jobs, transport, logger).unwrap(), locks) } @@ -79,7 +78,7 @@ pub(super) fn read_locks(api_problem: &ApiProblem, job_index: &JobIndex) -> Vec< .filter(|job| job.as_str() != "departure" && job.as_str() != "arrival") .fold((HashMap::::default(), vec![]), |(mut indexer, mut jobs), job| { let job_id = match job.as_str() { - "break" | "reload" => { + "break" | "reload" | "recharge" => { let entry = indexer.entry(job.clone()).or_insert(1_usize); let job_index = *entry; *entry += 1; @@ -178,11 +177,7 @@ fn read_required_jobs( (jobs, vec![]) } -fn read_conditional_jobs( - api_problem: &ApiProblem, - coord_index: &CoordIndex, - job_index: &mut JobIndex, -) -> (Vec, Vec>) { +fn read_conditional_jobs(api_problem: &ApiProblem, coord_index: &CoordIndex, job_index: &mut JobIndex) -> Vec { let mut jobs = vec![]; api_problem.fleet.vehicles.iter().for_each(|vehicle| { @@ -201,7 +196,7 @@ fn read_conditional_jobs( } }); - (jobs, vec![]) + jobs } fn read_optional_breaks(