|
220 | 220 | fleet_data: { |
221 | 221 | // in this sample we have 4 vehicles, |
222 | 222 | // 2 vehicles for each depot (we have 2 depots) |
223 | | - vehicle_locations: [[0, 0], [0, 0], [1, 1], [1, 1]], // [start location in array Depot, stop location in array Depot] |
224 | | - vehicle_ids: vehicles.map(vehicle => vehicle.name), // ["CarA", "CarB", "CarC", "CarD"], // the id for each vehicle |
| 223 | + vehicle_locations: vehicles.map(vehicle => vehicle.start_end_location_ids), // [start location in array Depot, stop location in array Depot] |
| 224 | + vehicle_ids: vehicles.map(vehicle => vehicle.name), // the id for each vehicle |
225 | 225 | vehicle_types: vehicles.map(vehicle => vehicle.vehicle_type_id), // cost_matrix_data & travel_time_matrix_data data id "1" |
226 | 226 | capacities: [vehicles.map(vehicle => vehicle.capacity)], // the capacity for each vehicle |
227 | | - //vehicle_time_windows: [[8, 17], [8, 17], [8, 17], [10, 20], [10, 20]], // the time in seconds |
228 | | - //vehicle_break_time_windows: [[[12, 14], [12, 14], [12, 14], [12, 14], [12, 14]]], // the time in seconds |
229 | | - //vehicle_break_durations: [vehicles.map(vehicle => convertHoursToSeconds(vehicle.break_duration))] // the time in seconds |
| 227 | + vehicle_time_windows: vehicles.map(vehicle => { |
| 228 | + const workingHours = vehicle.working_hours; |
| 229 | + return workingHours.map(convertHoursToSeconds); |
| 230 | + }), // the time in seconds |
| 231 | + vehicle_break_time_windows: [vehicles.map(vehicle => { |
| 232 | + const breakHours = vehicle.break_time_window; |
| 233 | + return breakHours.map(convertHoursToSeconds); |
| 234 | + })], // the time in seconds |
| 235 | + vehicle_break_durations: [vehicles.map(vehicle => convertHoursToSeconds(vehicle.break_duration))] // the time in seconds |
230 | 236 | }, |
231 | 237 | task_data: { |
232 | 238 | task_locations: Array.from({ length: stopslength }, (_, index) => depotslength + index), // the index in array Stops. the first 2 stops are the depots and does not count as tasks |
233 | 239 | demand: [stops.map(stop => stop.properties.demand)], // the demand for each task/stop |
234 | | - // task_time_windows: [stops.map(stop => { |
235 | | - // const openingHours = stop.properties.opening_hours; |
236 | | - // return openingHours.map(convertHoursToSeconds); |
237 | | - // })], // the time in seconds |
| 240 | + task_time_windows: stops.map(stop => { |
| 241 | + const openingHours = stop.properties.opening_hours; |
| 242 | + return openingHours.map(convertHoursToSeconds); |
| 243 | + }), // the time in seconds |
238 | 244 | service_times: stops.map(stop => convertHoursToSeconds(stop.properties.service_time)) // the time in seconds |
239 | 245 | } |
240 | 246 | }, |
241 | 247 | client_version: "custom" |
242 | 248 | } |
243 | 249 | }; |
244 | 250 |
|
| 251 | + console.log(optimizerBody); |
| 252 | + |
245 | 253 | // URL for making calls to the NVIDIA optimizer service. |
246 | 254 | var optimizerUrl = 'https://api.nvcf.nvidia.com/v2/nvcf/exec/functions/4bb2668d-c877-4b89-aabf-1630ed9b32c3/versions/471b94dc-931e-4aa1-99f4-935f5f352737'; |
247 | 255 |
|
|
268 | 276 | // Get the data from the response. |
269 | 277 | var data = await optimizerResponse.json(); |
270 | 278 |
|
| 279 | + console.log(data); |
| 280 | + |
271 | 281 | // Wait until the optimization is complete |
272 | 282 | while (data.percentComplete < 100) { |
273 | 283 |
|
|
0 commit comments