@@ -85,7 +85,7 @@ def solve(vrp, job, thread_proc = nil, &block)
8585 } . each { |relation |
8686 order_route = {
8787 vehicle : vrp . vehicles . size == 1 ? vrp . vehicles . first : nil ,
88- mission_ids : relation . linked_service_ids
88+ missions : relation . linked_services
8989 }
9090 vrp . routes += [ order_route ]
9191 }
@@ -136,7 +136,7 @@ def solve(vrp, job, thread_proc = nil, &block)
136136 @job = job
137137 @previous_result = nil
138138 relations = [ ]
139- services = [ ]
139+ ortools_services = [ ]
140140 routes = [ ]
141141 services_activity_positions = { always_first : [ ] , always_last : [ ] , never_first : [ ] , never_last : [ ] }
142142 vrp . services . each_with_index { |service , service_index |
@@ -161,7 +161,7 @@ def solve(vrp, job, thread_proc = nil, &block)
161161 }
162162
163163 if service . activity
164- services << OrtoolsVrp ::Service . new (
164+ ortools_services << OrtoolsVrp ::Service . new (
165165 time_windows : service . activity . timewindows . collect { |tw |
166166 OrtoolsVrp ::TimeWindow . new ( start : tw . start , end : tw . end || 2147483647 ,
167167 maximum_lateness : tw . maximum_lateness )
@@ -208,11 +208,12 @@ def solve(vrp, job, thread_proc = nil, &block)
208208 alternative_index : 0
209209 )
210210
211- services = update_services_activity_positions ( services , services_activity_positions , service . id ,
212- service . activity . position , service_index , 0 )
211+ ortools_services =
212+ update_services_activity_positions ( ortools_services , services_activity_positions , service . id ,
213+ service . activity . position , service_index , 0 )
213214 elsif service . activities
214215 service . activities . each_with_index { |possible_activity , activity_index |
215- services << OrtoolsVrp ::Service . new (
216+ ortools_services << OrtoolsVrp ::Service . new (
216217 time_windows : possible_activity . timewindows . collect { |tw |
217218 OrtoolsVrp ::TimeWindow . new ( start : tw . start , end : tw . end || 2147483647 ,
218219 maximum_lateness : tw . maximum_lateness )
@@ -257,8 +258,9 @@ def solve(vrp, job, thread_proc = nil, &block)
257258 alternative_index : activity_index
258259 )
259260
260- services = update_services_activity_positions ( services , services_activity_positions , service . id ,
261- possible_activity . position , service_index , activity_index )
261+ ortools_services =
262+ update_services_activity_positions ( ortools_services , services_activity_positions , service . id ,
263+ possible_activity . position , service_index , activity_index )
262264 }
263265 end
264266 }
@@ -275,17 +277,17 @@ def solve(vrp, job, thread_proc = nil, &block)
275277 }
276278
277279 vehicles = build_problem_vehicles ( vrp , total_quantities )
278- build_problem_relations ( vrp , services , relations )
280+ build_problem_relations ( vrp , ortools_services , relations )
279281
280282 vrp . routes . collect { |route |
281- next if route . vehicle . nil? || route . mission_ids . empty?
283+ next if route . vehicle . nil? || route . missions . empty?
282284
283- service_ids = corresponding_mission_ids ( services . collect ( & :id ) , route . mission_ids )
284- next if service_ids . empty?
285+ ortools_service_ids = corresponding_mission_ids ( ortools_services , route . missions )
286+ next if ortools_service_ids . empty?
285287
286288 routes << OrtoolsVrp ::Route . new (
287289 vehicle_id : route . vehicle . id . to_s ,
288- service_ids : service_ids . map ( &:to_s )
290+ service_ids : ortools_service_ids . map ( &:to_s )
289291 )
290292 }
291293
@@ -308,7 +310,7 @@ def solve(vrp, job, thread_proc = nil, &block)
308310
309311 problem = OrtoolsVrp ::Problem . new (
310312 vehicles : vehicles ,
311- services : services ,
313+ services : ortools_services ,
312314 matrices : matrices ,
313315 relations : relations ,
314316 routes : routes
@@ -710,8 +712,9 @@ def update_services_activity_positions(services, services_activity_positions,
710712 }
711713 end
712714
713- def corresponding_mission_ids ( available_ids , mission_ids )
714- mission_ids . collect { |mission_id |
715+ def corresponding_mission_ids ( available_ortools_services , missions )
716+ available_ids = available_ortools_services . map ( &:id )
717+ missions . map ( &:id ) . collect { |mission_id |
715718 correct_id =
716719 if available_ids . include? ( mission_id )
717720 mission_id
0 commit comments