Skip to content

Commit

Permalink
Fix: Vroom cannot handle activity positions
Browse files Browse the repository at this point in the history
  • Loading branch information
senhalil committed Jun 24, 2021
1 parent ea58317 commit 273ecce
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
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)
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

0 comments on commit 273ecce

Please sign in to comment.