Skip to content

Commit

Permalink
Allow zero as lapse in relation
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsecadeline committed Apr 20, 2021
1 parent ecaddb1 commit 099c4c2
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 243 deletions.
2 changes: 1 addition & 1 deletion api/v01/entities/vrp_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ module VrpMisc
It could be the following types: same_route, sequence, order, minimum_day_lapse, maximum_day_lapse,
shipment, meetup, minimum_duration_lapse, maximum_duration_lapse')
optional(:lapse,
type: Integer, values: ->(v) { v.positive? },
type: Integer, values: ->(v) { v >= 0 },
desc: 'Only used for relations implying a duration constraint : minimum/maximum day lapse, vehicle group durations...')
optional(:linked_ids, type: Array[String], allow_blank: false, desc: 'List of activities involved in the relation', coerce_with: ->(val) { val.is_a?(String) ? val.split(/,/) : val })
optional(:linked_vehicle_ids, type: Array[String], allow_blank: false, desc: 'List of vehicles involved in the relation', coerce_with: ->(val) { val.is_a?(String) ? val.split(/,/) : val })
Expand Down
14 changes: 14 additions & 0 deletions test/lib/interpreters/multi_trips_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,18 @@ def test_solve_vehicles_trips
assert route1
assert route0[:activities].last[:departure_time] <= route1[:activities].first[:begin_time]
end

def test_vehicle_trips_with_lapse_0
problem = VRP.lat_lon_two_vehicles
problem[:relations] = [{
type: :vehicle_trips,
lapse: 0,
linked_vehicle_ids: problem[:vehicles].collect{ |v| v[:id] }
}]

result = OptimizerWrapper.wrapper_vrp('demo', { services: { vrp: [:ortools] }}, TestHelper.create(problem), nil)
first_route = result[:routes].find{ |r| r[:vehicle_id] == 'vehicle_0' }
second_route = result[:routes].find{ |r| r[:vehicle_id] == 'vehicle_1' }
assert_operator first_route[:end_time], :<=, second_route[:start_time]
end
end
Loading

0 comments on commit 099c4c2

Please sign in to comment.