Skip to content

Commit

Permalink
Merge pull request #111 from senhalil/feat/infeasible_service_with_ne…
Browse files Browse the repository at this point in the history
…gative_quantity

Fix: eliminate negatif infeasible quantities
  • Loading branch information
fab-girard authored Jan 20, 2021
2 parents 40fc5c7 + 41fb257 commit d97986c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@
- Bump OR-Tools v7.8 [#107](https://github.com/Mapotempo/optimizer-api/pull/107)
- VROOM were previously always called synchronously, it is now reserved to a set of effective `router_mode` (:car, :truck_medium) within a limit of points (<200). [#107](https://github.com/Mapotempo/optimizer-api/pull/107)

### Removed


### Fixed

- `unassigned` output were in some cases returning the key `shipment_id` instead of `pickup_shipment_id` and `delivery_shipment_id` [#107](https://github.com/Mapotempo/optimizer-api/pull/107)
- Uniformize route content and always return `original_vehicle_id` [#107](https://github.com/Mapotempo/optimizer-api/pull/107)
- Infeasibility detection of services with negative quantity [#111](https://github.com/Mapotempo/optimizer-api/pull/111)


## [v0.1.5] - 2021-01-05

Expand Down
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def self.vehicle_and_days_partitions
module VRP # rubocop: disable Metrics/ModuleLength, Style/CommentedKeyword
def self.toy
{
units: [{ id: 'u1' }],
points: [{
id: 'p1',
location: {
Expand Down
11 changes: 11 additions & 0 deletions test/wrapper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2820,6 +2820,17 @@ def test_impossible_service_too_long
assert_empty OptimizerWrapper.config[:services][:demo].detect_unfeasible_services(TestHelper.create(vrp))
end

def test_impossible_service_with_negative_quantity
vrp = VRP.toy
vrp[:services].first[:quantities] = [{ unit_id: 'u1', value: -5 }]
vrp[:vehicles].first[:capacities] = [{ unit_id: 'u1', limit: 5 }]
assert_empty OptimizerWrapper.config[:services][:demo].detect_unfeasible_services(TestHelper.create(vrp))

vrp[:services].first[:quantities].first[:value] = -6
result = OptimizerWrapper.config[:services][:demo].detect_unfeasible_services(TestHelper.create(vrp))
assert_equal(1, result.count{ |un| un[:reason] == 'Service quantity greater than any vehicle capacity' })
end

def test_feasible_if_tardiness_allowed
vrp = VRP.basic

Expand Down
2 changes: 1 addition & 1 deletion wrappers/wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ def detect_unfeasible_services(vrp)

vrp.services.each{ |service|
service.quantities.each{ |qty|
if vehicle_max_capacities[qty.unit_id] && qty.value && vehicle_max_capacities[qty.unit_id] < qty.value
if vehicle_max_capacities[qty.unit_id] && qty.value && vehicle_max_capacities[qty.unit_id] < qty.value.abs
add_unassigned(unfeasible, vrp, service, 'Service quantity greater than any vehicle capacity')
break
end
Expand Down

0 comments on commit d97986c

Please sign in to comment.