Skip to content

Commit

Permalink
skip vroom if ride constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
braktar authored and frodrigo committed Aug 20, 2024
1 parent 1c17925 commit 0376e23
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/wrapper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,31 @@ def test_activity_position_presence
:assert_no_activity_with_position
end

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


problem[:vehicles].first[:maximum_ride_time] = 1
vrp = TestHelper.create(problem)
refute_includes OptimizerWrapper.config[:services][:ortools].inapplicable_solve?(vrp),
:assert_no_ride_constraint
assert_includes OptimizerWrapper.config[:services][:vroom].inapplicable_solve?(vrp),
:assert_no_ride_constraint

problem[:vehicles].first.delete(:maximum_ride_time)
problem[:vehicles].first[:maximum_ride_distance] = 1
vrp = TestHelper.create(problem)
refute_includes OptimizerWrapper.config[:services][:ortools].inapplicable_solve?(vrp),
:assert_no_ride_constraint
assert_includes OptimizerWrapper.config[:services][:vroom].inapplicable_solve?(vrp),
:assert_no_ride_constraint
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 @@ -52,6 +52,7 @@ def solver_constraints
:assert_homogeneous_router_definitions,
:assert_matrices_only_one,
:assert_no_distance_limitation,
:assert_no_ride_constraint,
:assert_no_service_duration_modifiers,
:assert_vehicles_no_capacity_initial,
:assert_vehicles_no_duration_limit,
Expand Down
4 changes: 4 additions & 0 deletions wrappers/wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ def assert_possible_to_get_distances_if_maximum_ride_distance(vrp)
)
end

def assert_no_ride_constraint(vrp)
vrp.vehicles.none?(&:maximum_ride_distance) && vrp.vehicles.none?(&:maximum_ride_time)
end

def assert_no_vehicle_free_approach_or_return_if_heuristic(vrp)
vrp.vehicles.none?{ |vehicle| vehicle.free_approach || vehicle.free_return } || !vrp.periodic_heuristic?
end
Expand Down

0 comments on commit 0376e23

Please sign in to comment.