Hello GeoNet,
I am working on a large Vehicle Routing Problem (VRP) for a number of depots and orders all across Michigan. Thus far I have been manually doing the VRP, adding Routes manually via 'Add Item' and changing its specifics. The sheer number of Routes and Route Renewals makes the task of doing this across all of Michigan essentially impossible.
I have some minor experience with ModelBuilder, but I am having difficulty automating the process.
Ideally, the computer would automatically add a number of Routes and Renewals based on values in the attribute table of the Depot (some have only 1 truck for deliveries, some have multiple, etc).
Is it possible to do what I need with ModelBuilder, or is another tool better?
How should I go about doing this?
Thank you in advance.
Hi David,
If you are wanting to create a VRP layer by looking into the attribute table for the depot your best bet is probably to do it through python. There is some example code on both the solve VRP and make VRP help pages. Here is the link for them:Solve Vehicle Routing Problem—Help | ArcGIS Desktop Make Vehicle Routing Problem Layer—Help | ArcGIS for Desktop
Since it sounds like you have a layer partly set up with the depots you could use some code like this to look at the depots and determine the number of routes that are to be created.
# open the layer File
layerFile = arcpy.mapping.Layer(layer)
subLayerNames = dict((lyr.datasetName, lyr) for lyr in arcpy.mapping.ListLayers(layerFile)[1:])
depotsLayerName = subLayerNames["Depots"]
# determine how many routes should be created
depotCursor = arcpy.SearchCursor(depotsLayerName)
for row in depotCursor:
numberOfRoutes = row.getValue("?????") # add the name of whatever attribute indicates the number of routes
depotName = row.getValue("Name")
From there you could create a temporary text file that gets a line for each route you want to create and then add the routes using the route field mappings and add locations scripts like shown in the above links.