I'm new to python programming please bear with me,
I have calculated a distance matrix (300x300) using real data (lat & log) through a OSRM running in dockers in a windows machine. it takes about 400 secs to complete the calculation.
because the Matrix will increase in size as customers locations are added, I need to calculate the distance matrix for the "same" matrix with an additional node (additional lat & log)
What is the fastest way to determine the distance matrix without recalculating the whole matrix?
my current code:
#setup OSRM
from routingpy import OSRM
from routingpy.routers import options
options.default_timeout=None
client = OSRM(base_url="")
#take lat&log from dataframe to list
import numpy as np
from boltons import iterutils
lat_= locations_DCA_df['Latitude'].tolist()
log_= locations_DCA_df['Longitude'].tolist()
distance_list = list()
for i in locations_DCA_df.index:
for j in locations_DCA_df.index:
orig_node = [log_[i],lat_[i]]
dest_node = [log_[j],lat_[j]]
orig_dest = [orig_node,dest_node]
distance_list.append(client.directions(locations=orig_dest,profile='car').distance)
#convert distance_list to distance_ format required for OrTools
distance = iterutils.chunked(distance_list, len(lat_))