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: Vroom cannot handle activity positions #242

Merged
merged 1 commit into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions test/wrapper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2129,6 +2129,18 @@ def test_wrong_matrix_and_points_definitions
assert_includes OptimizerWrapper.config[:services][:vroom].inapplicable_solve?(vrp), :assert_correctness_matrices_vehicles_and_points_definition
end

def test_activity_position_presence
problem = VRP.basic
vrp = TestHelper.create(problem)
refute_includes OptimizerWrapper.config[:services][:ortools].inapplicable_solve?(vrp), :assert_no_activity_with_position
refute_includes OptimizerWrapper.config[:services][:vroom].inapplicable_solve?(vrp), :assert_no_activity_with_position

problem[:services].first[:activity][:position] = 'always_last'
vrp = TestHelper.create(problem)
refute_includes OptimizerWrapper.config[:services][:ortools].inapplicable_solve?(vrp), :assert_no_activity_with_position
assert_includes OptimizerWrapper.config[:services][:vroom].inapplicable_solve?(vrp), :assert_no_activity_with_position
end

def test_unassigned_presence
problem = {
units: [{
Expand Down
1 change: 1 addition & 0 deletions wrappers/vroom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def solver_constraints
:assert_vehicles_start_or_end,

# Mission constraints
:assert_no_activity_with_position,
:assert_no_direct_shipments,
:assert_no_exclusion_cost,
:assert_no_complex_setup_durations,
Expand Down
6 changes: 6 additions & 0 deletions wrappers/wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ def assert_wrong_vehicle_shift_preference_with_heuristic(vrp)
(vrp.vehicles.map(&:shift_preference).uniq - [:minimize_span] - ['minimize_span']).empty? || vrp.preprocessing_first_solution_strategy.to_a.first != 'periodic'
end

def assert_no_activity_with_position(vrp)
senhalil marked this conversation as resolved.
Show resolved Hide resolved
vrp.services.none?{ |service|
(service.activities.to_a + [service.activity]).compact.any?{ |a| a.position != :neutral }
}
end

def assert_no_vehicle_overall_duration_if_heuristic(vrp)
vrp.vehicles.none?(&:overall_duration) || vrp.preprocessing_first_solution_strategy.to_a.first != 'periodic'
end
Expand Down