How to Plan Visits
The PTV xCluster server allows you to plan visits of field workers based on given locations and visit orders. The visit plan is balanced considering daily and weekly imbalance tolerances of the field worker.
Benefits
- Create an optimized visit plan for a field worker.
- Optimize the visit plan considering weekly and daily imbalance tolerances of the field worker.
Prerequisites
- Installed and licensed PTV xCluster Server
Programming Guide
To call planVisits specify the field worker, the locations and the visit orders. In this example the default imbalance tolerance of 10% is used.
var location1 = { "id": "Location1", "routeLocation": { "$type": "OffRoadRouteLocation", "offRoadCoordinate": { "x": 6.186895, "y": 49.948391 } } }; var location2 = { "id": "Location2", "routeLocation": { "$type": "OffRoadRouteLocation", "offRoadCoordinate": { "x": 6.086895, "y": 49.918391 } } }; var order1 = { "id": "order1", "locationId": "Location1", "numberOfVisitsPerWeek": 1, "visitRhythmInWeeks": 2, "serviceTimes": [ 900 ] }; var order2 = { "id": "order2", "locationId": "Location2", "numberOfVisitsPerWeek": 1, "visitRhythmInWeeks": 2, "serviceTimes": [ 800 ] }; var fieldWorker = { "id": "fieldWorker1", "location": { "$type": "OffRoadRouteLocation", "offRoadCoordinate": { "x": 5.939532, "y": 49.932788 } }}; xcluster.planVisits({ "fieldWorker" : fieldWorker, "locations": [location1, location2], "orders": [order1, order2], "planVisitsOptions": { "planningPeriod": { "startDate": "2016-12-19", "numberOfWeeks": 4 }, "workDays": { "monday": true } }, "distanceMode": { "$type": "DirectDistance" } }, planVisitsCompleted); function planVisitsCompleted(planVisitsResponse, exception) { var result = ''; for (visitIdx = 0; visitIdx < planVisitsResponse.visits.length; visitIdx++) { result += "visit for " + planVisitsResponse.visits[visitIdx].orderId + ' number ' + planVisitsResponse.visits[visitIdx].visitNumber + ' at ' + new Date(planVisitsResponse.visits[visitIdx].visitDate).toLocaleDateString(); if (visitIdx < planVisitsResponse.visits.length - 1) { result += ', '; } } print(result); }Related Topics
The following topics might be relevant for this use case.