AnsweredAssumed Answered

Vehicle Routing Problem Solver takes too long and gives Time Out error

Question asked by sgunes_UW on Oct 7, 2020
Latest reply on Oct 8, 2020 by william.kalande@gmail.com

I have been working on coding a Vehicle Routing Problem Solver, mostly by following ArcGIS Guide online (Guide to Network Analysis (Part 7 - Vehicle Routing Problem) | ArcGIS for Developers ). My code is as follows:

from arcgis.gis import GIS
import pandas as pd
import getpass
from IPython.display import HTML
import arcgis

from arcgis.features import Feature, FeatureSet, GeoAccessor, GeoSeriesAccessor
import networkx as nx
import osmnx as ox
import requests
import matplotlib.cm as cm
import matplotlib.colors as colors
from pathlib import Path
import geopandas as gpd # combines the capabilities of pandas and shapely for geospatial operations

#connect to your GIS
gis = GIS( client_id='Db8G5Jo6FCgLqTLk')
print("Successfully logged in as: " + gis.properties.user.username)

data_path = Path('./data')

if not data_path.exists():
   data_path.mkdir()

#read shape file

addresses = gpd.read_file('data/Addresses_in_King_County___address_point-shp/Addresses_in_King_County___address_point.shp')

 

>>>>OUTPUT: 
Please sign in to your GIS and paste the code that is obtained below. If a web browser does not automatically open, please navigate to the URL below yourself instead. Opening web browser to navigate to: https://www.arcgis.com/sharing/rest//oauth2/authorize?response_type=code&client_id=Db8G5Jo6FCgLqTLk&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&state=jQpTnOHa6SZTus7HYIMTkuNssqgbVkEnter code obtained on signing in using SAML: ········
/Users/seymagunes/opt/anaconda3/envs/ox/lib/python3.8/site-packages/urllib3/connectionpool.py:981: InsecureRequestWarning: Unverified HTTPS request is being made to host 'www.arcgis.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings  warnings.warn(
Successfully logged in as: XXXXX
>>>>

sea = addresses[addresses['CTYNAME']=="SEATTLE"]
pd.set_option('display.max_columns', None)
df_o = pd.DataFrame(sea.sample(N), columns = ['LON', 'LAT'])
#print (df_o)
orders_sdf = pd.DataFrame.spatial.from_xy(df_o, 'LON', 'LAT')
orders_sdf = orders_sdf.drop(axis=1, labels=['LON', 'LAT'])
orders_fset = orders_sdf.spatial.to_featureset()


r = {'ObjectID': ['1','2'],
'Name': ['Route1', 'Route2'],
'StartDepotName': ['Warehouse', 'Warehouse'],
'EndDepotName': ['Warehouse', 'Warehouse'],
#'EarliestStartTime': [1.573546e+12, 1.573546e+12 ],
# 'LatestStartTime': [8.00, 8.00 ],
'Capacities':[200, 50],
'CostPerUnitTime': [1,1],
'MaxOrderCount':[200,50],
# 'MaxTotalTime': [8,8],
'AssignmentRule': [1,1]
}

df = pd.DataFrame(r, columns = ['ObjectID',
'Name',
'StartDepotName',
'EndDepotName',
# 'EarliestStartTime',
# 'LatestStartTime',
'Capacities',
'CostPerUnitTime',
'MaxOrderCount',
# 'MaxTotalTime',
'AssignmentRule'])

#df["LatestStartTime"] = df["LatestStartTime"].astype("int64")/ 10 ** 6
#df["EarliestStartTime"] = df["EarliestStartTime"].astype("int64")/ 10 ** 6

routes_fset = arcgis.features.FeatureSet.from_dataframe(df)

# 1 depot
w = {'Latitude': [47.618011],
'Longitude': [-122.329422],
'Name': ['Warehouse']
}

df_w = pd.DataFrame(w, columns = ['Latitude',
'Longitude',
'Name'])

depots_sdf = pd.DataFrame.spatial.from_xy(df_w, "Longitude", "Latitude")
depots_sdf = depots_sdf.drop(axis=1, labels=["Longitude", "Latitude"])
depots_fset = depots_sdf.spatial.to_featureset()

import datetime as dt
import arcgis.network as network

if_async = False
current_date = dt.datetime.now().date()

result1 = network.analysis.solve_vehicle_routing_problem(orders=orders_fset, depots=depots_fset,
default_date=current_date,
routes=routes_fset, populate_route_lines=True,
save_route_data=True,
populate_directions=True,
directions_language="es",
future=if_async)

runs for 20+ minutes ends with error
>>>>


 

Outcomes