Skip to content

Commit

Permalink
[OA] multi-trips with lapses
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsecadeline committed May 31, 2021
1 parent 8b2e811 commit 4eb7167
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Added

- Implementation of `vehicle_trips` relation : these vehicles' routes are successive [#123] (https://github.com/Mapotempo/optimizer-api/pull/123)
- Implementation of `vehicle_trips` relation: the routes can be successive or with a minimum duration `lapse` in between [#123] (https://github.com/Mapotempo/optimizer-api/pull/123)

### Changed

Expand Down
2 changes: 1 addition & 1 deletion api/v01/entities/vrp_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ module VrpMisc
shipment, meetup, minimum_duration_lapse, maximum_duration_lapse, vehicle_trips')
optional(:lapse,
type: Integer, values: ->(v) { v >= 0 },
desc: 'Only used for relations implying a duration constraint : minimum/maximum day lapse, vehicle group durations...')
desc: 'Only used for relations implying a duration constraint. Lapse expressed in days for minimum/maximum day lapse, in seconds for vehicle_group_durations and vehicle_trips.')
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 })
optional(:periodicity, type: Integer, documentation: { hidden: true }, desc: 'In the case of planning optimization, number of weeks/months to consider at the same time/in each relation : vehicle group duration on weeks/months')
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 @@ -107,4 +107,18 @@ def test_vehicle_trips_with_lapse_0
second_route = result[:routes].find{ |r| r[:vehicle_id] == 'vehicle_1' }
assert_operator first_route[:end_time], :<=, second_route[:start_time]
end

def test_lapse_between_trips
vrp = VRP.lat_lon_two_vehicles
# ensure one vehicle only is not enough :
vrp[:vehicles].each{ |vehicle| vehicle[:distance] = 100000 }
vrp[:relations] = [TestHelper.vehicle_trips_relation(vrp)]

vrp[:relations].first[:lapse] = 3600
result = OptimizerWrapper.wrapper_vrp('demo', { services: { vrp: [:ortools] }}, TestHelper.create(vrp), nil)
assert(result[:routes].all?{ |route| route[:activities].size > 2 })
first_route_end = result[:routes][0][:activities].last[:begin_time]
last_route_start = result[:routes][1][:activities].first[:begin_time]
assert_operator first_route_end + 3600, :<=, last_route_start
end
end

0 comments on commit 4eb7167

Please sign in to comment.