Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix durations with sticky vehicles #11

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions optimizer_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,16 +426,16 @@ def self.build_independent_vrps(vrp, skill_sets, vehicle_indices_by_skills, skil
service_ids,
vehicle_indices)[:vrp]
}
is_sticky = vrp.services.all?{ |service| service.skills.any?{ |skill| skill.to_s.include?("sticky_skill") } }
total_size =
vrp.services.all?{ |service| service.sticky_vehicle_ids.any? } ? vrp.vehicles.size :
independent_vrps.collect{ |s_vrp| s_vrp.services.size * [1, s_vrp.vehicles.size].min }.sum
is_sticky ? vrp.vehicles.size :
independent_vrps.collect{ |s_vrp| s_vrp.services.size * [1, s_vrp.vehicles.size].min }.sum
independent_vrps.each{ |sub_vrp|
# If one sub vrp has no vehicle or no service, duration can be zero.
# We only split duration among sub_service_vrps that have at least one vehicle and one service.
this_sub_size =
vrp.services.all?{ |service| service.skills.any?{ |skill| skill.to_s.include?("sticky_skill") } } ?
sub_vrp.vehicles.size :
sub_vrp.services.size * [1, sub_vrp.vehicles.size].min
is_sticky ? sub_vrp.vehicles.size :
sub_vrp.services.size * [1, sub_vrp.vehicles.size].min
Interpreters::SplitClustering.adjust_independent_duration(sub_vrp, this_sub_size, total_size)
}

Expand Down
Loading