diff --git a/CHANGELOG.md b/CHANGELOG.md index d89a48eb0..35df46c27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ ### Removed - `geometry_polyline` parameter now be provided through `geometry` parameter [#165](https://github.com/Mapotempo/optimizer-api/pull/165) +- Field `trips` in vehicle model. Use `vehicle_trips` relation instead [#123](https://github.com/Mapotempo/optimizer-api/pull/123) ### Fixed diff --git a/api/v01/entities/vrp_input.rb b/api/v01/entities/vrp_input.rb index de5d01fe3..cafd4a47b 100644 --- a/api/v01/entities/vrp_input.rb +++ b/api/v01/entities/vrp_input.rb @@ -488,7 +488,6 @@ module VrpVehicles optional(:force_start, type: Boolean, documentation: { hidden: true }, desc: '[ DEPRECATED ]') optional(:shift_preference, type: String, values: ['force_start', 'force_end', 'minimize_span'], desc: 'Force the vehicle to start as soon as the vehicle timewindow is open, as late as possible or let vehicle start at any time. Not available with periodic heuristic, it will always leave as soon as possible.') - optional(:trips, type: Integer, default: 1, desc: 'The number of times a vehicle is allowed to return to the depot within its route. Not available with periodic heuristic.') optional :matrix_id, type: String, desc: 'Related matrix, if already defined' optional :value_matrix_id, type: String, desc: 'If any value matrix defined, related matrix index' diff --git a/lib/interpreters/multi_trips.rb b/lib/interpreters/multi_trips.rb deleted file mode 100644 index 11bef50a6..000000000 --- a/lib/interpreters/multi_trips.rb +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright © Mapotempo, 2018 -# -# This file is part of Mapotempo. -# -# Mapotempo is free software. You can redistribute it and/or -# modify since you respect the terms of the GNU Affero General -# Public License as published by the Free Software Foundation, -# either version 3 of the License, or (at your option) any later version. -# -# Mapotempo is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the Licenses for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Mapotempo. If not, see: -# -# - -require './models/relation' - -module Interpreters - class MultiTrips - def expand(vrp) - vrp.vehicles = vrp.vehicles.collect{ |vehicle| - if vehicle.trips > 1 - new_ids = Array.new(vehicle.trips) { |index| vehicle.id + '_trip_' + index.to_s } - new_vehicles = new_ids.collect{ |id| - new_vehicle = Marshal.load(Marshal.dump(vehicle)) - new_vehicle.original_id = new_vehicle.id - new_vehicle.id = id - new_vehicle.trips = 1 - new_vehicle - } - - vrp.relations.select{ |relation| relation.linked_vehicle_ids.include?(vehicle.id) }.each{ |relation| - relation.linked_vehicle_ids -= [vehicle.id] - relation.linked_vehicle_ids += new_ids - } - - vrp.relations += [Models::Relation.new(type: :vehicle_trips, linked_vehicle_ids: new_ids)] - # vrp.relations += [Models::Relation.new(type: :vehicle_group_duration, linked_vehicle_ids: new_ids, lapse: vehicle.duration)] if vehicle.duration # TODO: Requires a complete rework of overall_duration - # vrp.relations += [Models::Relation.new(type: :vehicle_group_duration, linked_vehicle_ids: new_ids, lapse: vehicle.overall_duration)] if vehicle.overall_duration # TODO: Requires a complete rework of overall_duration - - vrp.services.select{ |service| service.sticky_vehicles.any?{ |sticky_vehicle| sticky_vehicle.id == vehicle.id } }.each{ |service| - service.sticky_vehicles -= [vehicle.id] - service.sticky_vehicles += new_ids - } - - new_vehicles - else - vehicle - end - }.flatten - vrp - end - end -end diff --git a/models/vehicle.rb b/models/vehicle.rb index ed03c1db5..b178d2b8e 100644 --- a/models/vehicle.rb +++ b/models/vehicle.rb @@ -57,7 +57,6 @@ class Vehicle < Base field :force_start, default: false field :shift_preference, default: :minimize_span - field :trips, default: 1 field :duration, default: nil field :overall_duration, default: nil field :distance, default: nil @@ -92,7 +91,6 @@ class Vehicle < Base # validates_numericality_of :global_day_index, allow_nil: true # validates_inclusion_of :router_dimension, in: %w( time distance ) # validates_inclusion_of :shift_preference, in: %w( force_start force_end minimize_span ) - # validates_numericality_of :trips, greater_than_or_equal_to: 0 # validates_numericality_of :speed_multiplier # validates_numericality_of :duration, greater_than_or_equal_to: 0 # validates_numericality_of :overall_duration, greater_than_or_equal_to: 0 diff --git a/optimizer_wrapper.rb b/optimizer_wrapper.rb index 20c0a5e17..251883037 100644 --- a/optimizer_wrapper.rb +++ b/optimizer_wrapper.rb @@ -24,7 +24,6 @@ require './lib/routers/router_wrapper.rb' require './lib/interpreters/multi_modal.rb' -require './lib/interpreters/multi_trips.rb' require './lib/interpreters/periodic_visits.rb' require './lib/interpreters/split_clustering.rb' require './lib/interpreters/compute_several_solutions.rb' @@ -200,8 +199,6 @@ def self.solve(service_vrp, job = nil, block = nil) tic = Time.now - Interpreters::MultiTrips.new.expand(vrp) - optim_result = nil unfeasible_services = [] diff --git a/test/fixtures/balanced_split_under_nonuniform_sq_timewindows.dump b/test/fixtures/balanced_split_under_nonuniform_sq_timewindows.dump index e2ffadf90..cef7435ae 100644 Binary files a/test/fixtures/balanced_split_under_nonuniform_sq_timewindows.dump and b/test/fixtures/balanced_split_under_nonuniform_sq_timewindows.dump differ diff --git a/test/fixtures/callage_freq.dump b/test/fixtures/callage_freq.dump index 11ac66b9d..c1ff2a057 100644 Binary files a/test/fixtures/callage_freq.dump and b/test/fixtures/callage_freq.dump differ diff --git a/test/fixtures/cluster_dichotomious.dump b/test/fixtures/cluster_dichotomious.dump index e6ff12d6d..e9d278f90 100644 Binary files a/test/fixtures/cluster_dichotomious.dump and b/test/fixtures/cluster_dichotomious.dump differ diff --git a/test/fixtures/cluster_one_phase.dump b/test/fixtures/cluster_one_phase.dump index 8ae44cc64..74662c23c 100644 Binary files a/test/fixtures/cluster_one_phase.dump and b/test/fixtures/cluster_one_phase.dump differ diff --git a/test/fixtures/cluster_two_phases.dump b/test/fixtures/cluster_two_phases.dump index 131feefb9..a12d87127 100644 Binary files a/test/fixtures/cluster_two_phases.dump and b/test/fixtures/cluster_two_phases.dump differ diff --git a/test/fixtures/dichotomious_approach.dump b/test/fixtures/dichotomious_approach.dump index 5435d7ba5..a75a2aa5e 100644 Binary files a/test/fixtures/dichotomious_approach.dump and b/test/fixtures/dichotomious_approach.dump differ diff --git a/test/fixtures/dichotomious_check_number_of_services.dump b/test/fixtures/dichotomious_check_number_of_services.dump index 2670f9d75..6aab1e416 100644 Binary files a/test/fixtures/dichotomious_check_number_of_services.dump and b/test/fixtures/dichotomious_check_number_of_services.dump differ diff --git a/test/fixtures/instance_andalucia1_two_vehicles.dump b/test/fixtures/instance_andalucia1_two_vehicles.dump index 583174b9b..1548da9cf 100644 Binary files a/test/fixtures/instance_andalucia1_two_vehicles.dump and b/test/fixtures/instance_andalucia1_two_vehicles.dump differ diff --git a/test/fixtures/instance_andalucia2.dump b/test/fixtures/instance_andalucia2.dump index 4190e9e22..0cfbf84c2 100644 Binary files a/test/fixtures/instance_andalucia2.dump and b/test/fixtures/instance_andalucia2.dump differ diff --git a/test/fixtures/instance_baleares2.dump b/test/fixtures/instance_baleares2.dump index 8c0721d7d..9867d9b56 100644 Binary files a/test/fixtures/instance_baleares2.dump and b/test/fixtures/instance_baleares2.dump differ diff --git a/test/fixtures/instance_baleares2_with_priority.dump b/test/fixtures/instance_baleares2_with_priority.dump index b5d7211cf..8ee3a23b4 100644 Binary files a/test/fixtures/instance_baleares2_with_priority.dump and b/test/fixtures/instance_baleares2_with_priority.dump differ diff --git a/test/fixtures/instance_clustered.dump b/test/fixtures/instance_clustered.dump index 71710acad..820140a4c 100644 Binary files a/test/fixtures/instance_clustered.dump and b/test/fixtures/instance_clustered.dump differ diff --git a/test/fixtures/instance_order.dump b/test/fixtures/instance_order.dump index 5c47cad41..1bbfccb2e 100644 Binary files a/test/fixtures/instance_order.dump and b/test/fixtures/instance_order.dump differ diff --git a/test/fixtures/instance_same_point_day.dump b/test/fixtures/instance_same_point_day.dump index 6716598ca..b8d25cb87 100644 Binary files a/test/fixtures/instance_same_point_day.dump and b/test/fixtures/instance_same_point_day.dump differ diff --git a/test/fixtures/length_centroid.dump b/test/fixtures/length_centroid.dump index 0139412f4..19d31ef6e 100644 Binary files a/test/fixtures/length_centroid.dump and b/test/fixtures/length_centroid.dump differ diff --git a/test/fixtures/max_split_functionality.dump b/test/fixtures/max_split_functionality.dump index c164fc220..6e8f8c138 100644 Binary files a/test/fixtures/max_split_functionality.dump and b/test/fixtures/max_split_functionality.dump differ diff --git a/test/fixtures/minimum_duration_lapse_shipments.dump b/test/fixtures/minimum_duration_lapse_shipments.dump index 73c60617d..ce7d3d4e9 100644 Binary files a/test/fixtures/minimum_duration_lapse_shipments.dump and b/test/fixtures/minimum_duration_lapse_shipments.dump differ diff --git a/test/fixtures/no_doubles_3000.dump b/test/fixtures/no_doubles_3000.dump index 1b89481b1..072273c42 100644 Binary files a/test/fixtures/no_doubles_3000.dump and b/test/fixtures/no_doubles_3000.dump differ diff --git a/test/fixtures/ortools_global_six_routes_without_rest.dump b/test/fixtures/ortools_global_six_routes_without_rest.dump index 07160e306..485570661 100644 Binary files a/test/fixtures/ortools_global_six_routes_without_rest.dump and b/test/fixtures/ortools_global_six_routes_without_rest.dump differ diff --git a/test/fixtures/ortools_global_ten_routes_without_rest.dump b/test/fixtures/ortools_global_ten_routes_without_rest.dump index 83f5da7a6..60ca93ba5 100644 Binary files a/test/fixtures/ortools_global_ten_routes_without_rest.dump and b/test/fixtures/ortools_global_ten_routes_without_rest.dump differ diff --git a/test/fixtures/ortools_multimodal_route.dump b/test/fixtures/ortools_multimodal_route.dump index b3489e033..e38f9ac22 100644 Binary files a/test/fixtures/ortools_multimodal_route.dump and b/test/fixtures/ortools_multimodal_route.dump differ diff --git a/test/fixtures/ortools_multimodal_route2.dump b/test/fixtures/ortools_multimodal_route2.dump index 836168b66..3b696d0b3 100644 Binary files a/test/fixtures/ortools_multimodal_route2.dump and b/test/fixtures/ortools_multimodal_route2.dump differ diff --git a/test/fixtures/ortools_one_route_many_stops.dump b/test/fixtures/ortools_one_route_many_stops.dump index b22db224c..e0e15fad6 100644 Binary files a/test/fixtures/ortools_one_route_many_stops.dump and b/test/fixtures/ortools_one_route_many_stops.dump differ diff --git a/test/fixtures/ortools_one_route_with_rest.dump b/test/fixtures/ortools_one_route_with_rest.dump index b219825dd..e59d8c728 100644 Binary files a/test/fixtures/ortools_one_route_with_rest.dump and b/test/fixtures/ortools_one_route_with_rest.dump differ diff --git a/test/fixtures/ortools_one_route_with_rest_and_waiting_time.dump b/test/fixtures/ortools_one_route_with_rest_and_waiting_time.dump index b96cd5c60..4af18424d 100644 Binary files a/test/fixtures/ortools_one_route_with_rest_and_waiting_time.dump and b/test/fixtures/ortools_one_route_with_rest_and_waiting_time.dump differ diff --git a/test/fixtures/ortools_one_route_with_single_mtws.dump b/test/fixtures/ortools_one_route_with_single_mtws.dump index 152e778e2..75a6a5ff3 100644 Binary files a/test/fixtures/ortools_one_route_with_single_mtws.dump and b/test/fixtures/ortools_one_route_with_single_mtws.dump differ diff --git a/test/fixtures/ortools_one_route_without_rest.dump b/test/fixtures/ortools_one_route_without_rest.dump index 0a06fff84..69bcb1e99 100644 Binary files a/test/fixtures/ortools_one_route_without_rest.dump and b/test/fixtures/ortools_one_route_without_rest.dump differ diff --git a/test/fixtures/ortools_one_route_without_rest_2.dump b/test/fixtures/ortools_one_route_without_rest_2.dump index df09b2101..922ac5393 100644 Binary files a/test/fixtures/ortools_one_route_without_rest_2.dump and b/test/fixtures/ortools_one_route_without_rest_2.dump differ diff --git a/test/fixtures/ortools_open_timewindows.dump b/test/fixtures/ortools_open_timewindows.dump index 2ead4502e..b6cb6d5c0 100644 Binary files a/test/fixtures/ortools_open_timewindows.dump and b/test/fixtures/ortools_open_timewindows.dump differ diff --git a/test/fixtures/ortools_optimize_each.dump b/test/fixtures/ortools_optimize_each.dump index 13cefe460..f5bb44e51 100644 Binary files a/test/fixtures/ortools_optimize_each.dump and b/test/fixtures/ortools_optimize_each.dump differ diff --git a/test/fixtures/ortools_performance_when_duration_limit.dump b/test/fixtures/ortools_performance_when_duration_limit.dump index 846a32c35..ab2808183 100644 Binary files a/test/fixtures/ortools_performance_when_duration_limit.dump and b/test/fixtures/ortools_performance_when_duration_limit.dump differ diff --git a/test/fixtures/ortools_single_route_with_route_order.dump b/test/fixtures/ortools_single_route_with_route_order.dump index b0248277b..1f1bed889 100644 Binary files a/test/fixtures/ortools_single_route_with_route_order.dump and b/test/fixtures/ortools_single_route_with_route_order.dump differ diff --git a/test/fixtures/ortools_single_route_with_route_order_2.dump b/test/fixtures/ortools_single_route_with_route_order_2.dump index 04c8174cd..187f2846f 100644 Binary files a/test/fixtures/ortools_single_route_with_route_order_2.dump and b/test/fixtures/ortools_single_route_with_route_order_2.dump differ diff --git a/test/fixtures/performance_12vl.dump b/test/fixtures/performance_12vl.dump index 8406605c9..1cfc725fa 100644 Binary files a/test/fixtures/performance_12vl.dump and b/test/fixtures/performance_12vl.dump differ diff --git a/test/fixtures/performance_13vl.dump b/test/fixtures/performance_13vl.dump index e4717fe5c..18d2b5eaa 100644 Binary files a/test/fixtures/performance_13vl.dump and b/test/fixtures/performance_13vl.dump differ diff --git a/test/fixtures/performance_britanny.dump b/test/fixtures/performance_britanny.dump index da4420f2d..197f58ad5 100644 Binary files a/test/fixtures/performance_britanny.dump and b/test/fixtures/performance_britanny.dump differ diff --git a/test/fixtures/pud_initial_routes.dump b/test/fixtures/pud_initial_routes.dump index effe98baf..b4cb84baf 100644 Binary files a/test/fixtures/pud_initial_routes.dump and b/test/fixtures/pud_initial_routes.dump differ diff --git a/test/fixtures/quality_with_minimum_stops_in_route.dump b/test/fixtures/quality_with_minimum_stops_in_route.dump index b8570de30..9ee59bff1 100644 Binary files a/test/fixtures/quality_with_minimum_stops_in_route.dump and b/test/fixtures/quality_with_minimum_stops_in_route.dump differ diff --git a/test/fixtures/results_regularity.dump b/test/fixtures/results_regularity.dump index 11bbf76b8..3ab372cd8 100644 Binary files a/test/fixtures/results_regularity.dump and b/test/fixtures/results_regularity.dump differ diff --git a/test/fixtures/results_regularity_2.dump b/test/fixtures/results_regularity_2.dump index 840c62730..302d5755f 100644 Binary files a/test/fixtures/results_regularity_2.dump and b/test/fixtures/results_regularity_2.dump differ diff --git a/test/fixtures/route_initialisation.dump b/test/fixtures/route_initialisation.dump index 2c0d2895c..d5f6bc6e8 100644 Binary files a/test/fixtures/route_initialisation.dump and b/test/fixtures/route_initialisation.dump differ diff --git a/test/fixtures/same_point_day_relaxation.dump b/test/fixtures/same_point_day_relaxation.dump index 7c19185f1..5024272fd 100644 Binary files a/test/fixtures/same_point_day_relaxation.dump and b/test/fixtures/same_point_day_relaxation.dump differ diff --git a/test/fixtures/scheduling_and_ortools.dump b/test/fixtures/scheduling_and_ortools.dump index bf20653e1..a0ec69a63 100644 Binary files a/test/fixtures/scheduling_and_ortools.dump and b/test/fixtures/scheduling_and_ortools.dump differ diff --git a/test/fixtures/scheduling_with_post_process.dump b/test/fixtures/scheduling_with_post_process.dump index c94db39ec..2e37cfdfd 100644 Binary files a/test/fixtures/scheduling_with_post_process.dump and b/test/fixtures/scheduling_with_post_process.dump differ diff --git a/test/fixtures/treatment_site.dump b/test/fixtures/treatment_site.dump index 57a8fdd26..ef187f523 100644 Binary files a/test/fixtures/treatment_site.dump and b/test/fixtures/treatment_site.dump differ diff --git a/test/fixtures/two_phases_clustering_sched_with_freq_and_same_point_day_5veh.dump b/test/fixtures/two_phases_clustering_sched_with_freq_and_same_point_day_5veh.dump index 3dd766e45..21d1214ee 100644 Binary files a/test/fixtures/two_phases_clustering_sched_with_freq_and_same_point_day_5veh.dump and b/test/fixtures/two_phases_clustering_sched_with_freq_and_same_point_day_5veh.dump differ diff --git a/test/fixtures/vroom_optimize_each.dump b/test/fixtures/vroom_optimize_each.dump index f0b2022ee..896491f1b 100644 Binary files a/test/fixtures/vroom_optimize_each.dump and b/test/fixtures/vroom_optimize_each.dump differ diff --git a/test/fixtures/vrp_allow_partial_assigment_false.dump b/test/fixtures/vrp_allow_partial_assigment_false.dump index 230f25a6d..1edf6efb3 100644 Binary files a/test/fixtures/vrp_allow_partial_assigment_false.dump and b/test/fixtures/vrp_allow_partial_assigment_false.dump differ diff --git a/test/fixtures/vrp_ten_routes_with_rest.dump b/test/fixtures/vrp_ten_routes_with_rest.dump index 30df1e351..c1a509840 100644 Binary files a/test/fixtures/vrp_ten_routes_with_rest.dump and b/test/fixtures/vrp_ten_routes_with_rest.dump differ diff --git a/test/fixtures/without_same_point_day.dump b/test/fixtures/without_same_point_day.dump index f9c95f884..366e748c4 100644 Binary files a/test/fixtures/without_same_point_day.dump and b/test/fixtures/without_same_point_day.dump differ diff --git a/test/lib/interpreters/multi_trips_test.rb b/test/lib/interpreters/multi_trips_test.rb index 3cf427a20..f4d911b99 100644 --- a/test/lib/interpreters/multi_trips_test.rb +++ b/test/lib/interpreters/multi_trips_test.rb @@ -19,25 +19,6 @@ require 'date' class MultiTripsTest < Minitest::Test - def test_expand_vehicles_trips - vrp = VRP.lat_lon - vrp[:vehicles].first[:trips] = 2 - - vrp = Interpreters::MultiTrips.new.expand(TestHelper.create(vrp)) - - assert_equal 2, vrp.vehicles.size - assert_equal 1, vrp.relations.size - vrp.relations.each{ |relation| - assert_equal :vehicle_trips, relation.type - assert_includes relation.linked_vehicle_ids, 'vehicle_0_trip_0' - assert_includes relation.linked_vehicle_ids, 'vehicle_0_trip_1' - } - - Interpreters::MultiTrips.new.expand(vrp) # consecutive MultiTrips.expand should not produce any error neither inconsistency - assert_equal 2, vrp.vehicles.size - assert_equal 1, vrp.relations.size - end - def test_solve_vehicles_trips_capacity vrp = VRP.lat_lon_capacitated result = OptimizerWrapper.wrapper_vrp('demo', { services: { vrp: [:ortools] }}, TestHelper.create(vrp), nil) @@ -46,7 +27,12 @@ def test_solve_vehicles_trips_capacity # increasing number of trips increases overall available capacity and reduces unassigned : - vrp[:vehicles].first[:trips] = 2 + vrp[:vehicles] << vrp[:vehicles].first.dup + vrp[:vehicles].last[:id] += '_second_trip' + vrp[:relations] = [{ + type: 'vehicle_trips', + linked_vehicle_ids: [vrp[:vehicles].first[:id], vrp[:vehicles].last[:id]] + }] result = OptimizerWrapper.wrapper_vrp('demo', { services: { vrp: [:ortools] }}, TestHelper.create(vrp), nil) assert_equal 2, result[:routes].size assert_equal 2, result[:unassigned].size @@ -54,7 +40,9 @@ def test_solve_vehicles_trips_capacity routes_end = result[:routes].collect{ |route| route[:activities].last[:begin_time] } assert_operator routes_end[0], :<=, routes_start[1] - vrp[:vehicles].first[:trips] = 3 + vrp[:vehicles] << vrp[:vehicles].first.dup + vrp[:vehicles].last[:id] += '_third_trip' + vrp[:relations].first[:linked_vehicle_ids] << vrp[:vehicles].last[:id] result = OptimizerWrapper.wrapper_vrp('demo', { services: { vrp: [:ortools] }}, TestHelper.create(vrp), nil) assert_equal 3, result[:routes].size assert_empty result[:unassigned] @@ -68,14 +56,20 @@ def test_solve_vehicles_trips_capacity def test_solve_vehicles_trips_duration vrp = VRP.basic vrp[:matrices].first[:time] = vrp[:matrices].first[:time].collect{ |l| l.collect{ |v| v.positive? ? 4 : 0 } } - vrp[:vehicles].first[:duration] = 4 + vrp[:vehicles].first[:end_point_id] = vrp[:vehicles].first[:start_point_id] + vrp[:vehicles].first[:duration] = 10 result = OptimizerWrapper.wrapper_vrp('demo', { services: { vrp: [:ortools] }}, TestHelper.create(vrp), nil) assert_equal 1, result[:routes].size assert_equal 2, result[:unassigned].size # increasing number of trips increases overall available duration and reduces unassigned : - vrp[:vehicles].first[:trips] = 2 + vrp[:vehicles] << vrp[:vehicles].first.dup + vrp[:vehicles].last[:id] += '_second_trip' + vrp[:relations] = [{ + type: 'vehicle_trips', + linked_vehicle_ids: [vrp[:vehicles].first[:id], vrp[:vehicles].last[:id]] + }] result = OptimizerWrapper.wrapper_vrp('demo', { services: { vrp: [:ortools] }}, TestHelper.create(vrp), nil) assert_equal 2, result[:routes].size assert_equal 1, result[:unassigned].size @@ -83,7 +77,9 @@ def test_solve_vehicles_trips_duration routes_end = result[:routes].collect{ |route| route[:activities].last[:begin_time] } assert_operator routes_end[0], :<=, routes_start[1] - vrp[:vehicles].first[:trips] = 3 + vrp[:vehicles] << vrp[:vehicles].first.dup + vrp[:vehicles].last[:id] += '_third_trip' + vrp[:relations].first[:linked_vehicle_ids] << vrp[:vehicles].last[:id] result = OptimizerWrapper.wrapper_vrp('demo', { services: { vrp: [:ortools] }}, TestHelper.create(vrp), nil) assert_equal 3, result[:routes].size assert_empty result[:unassigned] diff --git a/test/real_cases_scheduling_test.rb b/test/real_cases_scheduling_test.rb index 4ca712146..060992996 100644 --- a/test/real_cases_scheduling_test.rb +++ b/test/real_cases_scheduling_test.rb @@ -75,7 +75,7 @@ def test_without_same_point_day result = OptimizerWrapper.wrapper_vrp('ortools', { services: { vrp: [:ortools] }}, vrp, nil) assert_equal expecting, result[:routes].sum{ |route| route[:activities].count{ |stop| stop[:service_id] } } + result[:unassigned].size unassigned = result[:unassigned].size - assert_equal 46, unassigned + assert_equal 49, unassigned vrp = TestHelper.load_vrp(self) vrp.resolution_solver = true @@ -235,7 +235,7 @@ def test_performance_12vl # voluntarily equal to watch evolution of scheduling algorithm performance assert_equal expected, seen, 'Do not have the expected number of total visits' - assert_equal 280, unassigned_visits.sum, 'Do not have the expected number of unassigned visits' + assert_equal 315, unassigned_visits.sum, 'Do not have the expected number of unassigned visits' end def test_minimum_stop_in_route @@ -251,7 +251,7 @@ def test_minimum_stop_in_route result = OptimizerWrapper.wrapper_vrp('ortools', { services: { vrp: [:ortools] }}, vrp, nil) assert result[:routes].all?{ |r| (r[:activities].size - 2).zero? || r[:activities].size - 2 >= 5 }, 'Expecting no route with less than 5 stops unless it is empty' assert_operator(should_remain_assigned, :<=, result[:routes].sum{ |r| r[:activities].size - 2 }) - assert_equal 19, result[:unassigned].size + assert_equal 21, result[:unassigned].size assert_equal vrp.visits, result[:routes].sum{ |r| r[:activities].count{ |a| a[:service_id] } } + result[:unassigned].size all_ids = (result[:routes].flat_map{ |route| route[:activities].collect{ |stop| stop[:service_id] } }.compact + result[:unassigned].collect{ |un| un[:service_id] }).uniq @@ -274,7 +274,7 @@ def test_performance_13vl # voluntarily equal to watch evolution of scheduling algorithm performance assert_equal expected, seen, 'Do not have the expected number of total visits' - assert_equal 294, unassigned_visits.sum, 'Do not have the expected number of unassigned visits' + assert_equal 298, unassigned_visits.sum, 'Do not have the expected number of unassigned visits' end def test_fill_days_and_post_processing @@ -287,7 +287,7 @@ def test_fill_days_and_post_processing assert_equal vrp.visits, result[:routes].sum{ |r| r[:activities].count{ |s| s[:service_id] } } + result[:unassigned].size, 'Do not have the expected number of total visits' - assert_equal 74, result[:unassigned].size, 'Do not have the expected number of unassigned visits' + assert_equal 39, result[:unassigned].size, 'Do not have the expected number of unassigned visits' end def test_treatment_site diff --git a/test/test_helper.rb b/test/test_helper.rb index ccd82daf4..f32fe9484 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -102,9 +102,7 @@ def self.coerce(vrp) vrp[:configuration][:preprocessing][:partitions]&.each{ |partition| partition[:entity] = partition[:entity].to_sym } if vrp[:configuration] && vrp[:configuration][:preprocessing] vrp.preprocessing_partitions&.each{ |partition| partition[:entity] = partition[:entity].to_sym } if vrp.is_a?(Models::Vrp) - vrp.provide_original_info unless vrp.is_a?(Hash) # TODO: re-dump with this modification - - vrp[:relations]&.each{ |r| r[:type] = r[:type]&.to_sym } # TODO: re-dump with this modification + vrp[:relations]&.each{ |r| r[:type] = r[:type]&.to_sym } vrp end