File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -1473,6 +1473,20 @@ def add_duration_from_and_to_depot(vrp, data_items)
14731473 end
14741474 log "matrix computed in #{ ( Time . now - tic ) . round ( 2 ) } seconds"
14751475
1476+ max_time_from_depot = 0
1477+ max_time_to_depot = 0
1478+
1479+ time_matrix_from_depot . map { |matrix |
1480+ matrix . map { |time |
1481+ ( ( time > max_time_from_depot ) && ( time != 2147483647 ) ) ? max_time_from_depot = time : nil
1482+ }
1483+ }
1484+ time_matrix_to_depot . map { |matrix |
1485+ matrix . map { |time |
1486+ ( ( time > max_time_to_depot ) && ( time != 2147483647 ) ) ? max_time_to_depot = time : nil
1487+ }
1488+ }
1489+
14761490 v_index = {
14771491 from : vrp . vehicles . collect { |v |
14781492 start_loc = v . start_point &.location
@@ -1488,8 +1502,10 @@ def add_duration_from_and_to_depot(vrp, data_items)
14881502 point [ 4 ] [ :duration_from_and_to_depot ] = [ ]
14891503
14901504 vrp . vehicles . each_with_index { |_vehicle , v_i |
1491- duration_from = time_matrix_from_depot [ v_index [ :from ] [ v_i ] ] [ p_index ] if v_index [ :from ] [ v_i ]
1492- duration_to = time_matrix_to_depot [ p_index ] [ v_index [ :to ] [ v_i ] ] if v_index [ :to ] [ v_i ]
1505+ duration_from = [ time_matrix_from_depot [ v_index [ :from ] [ v_i ] ] [ p_index ] , max_time_from_depot * 10 ] . min \
1506+ if v_index [ :from ] [ v_i ]
1507+ duration_to = [ time_matrix_to_depot [ p_index ] [ v_index [ :to ] [ v_i ] ] , max_time_to_depot * 10 ] . min if \
1508+ v_index [ :to ] [ v_i ]
14931509
14941510 # TODO: investigate why division by vehicle.router_options[:speed_multiplier]
14951511 # detoriarates the performance of periodic
You can’t perform that action at this time.
0 commit comments