<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Find best order route is slow in ArcGIS Network Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613155#M5880</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think Domenico is on to something...your problem could be greatly simplified if you could group points or cluster them and use a representative location.&amp;nbsp; If you have 5 origin points all on the same block, it really doesn't matter their individual route solutions, since they will effectively be identical...if you throw a coffee break into the mix, your grouping distance could expand to a couple of blocks.&amp;nbsp; So I would follow his suggestion and have a good look at your point pattern(s) and see if there is any inherent clustering as origins and/or destinations&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Jan 2016 07:44:01 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2016-01-15T07:44:01Z</dc:date>
    <item>
      <title>Find best order route is slow</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613149#M5874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P dir="ltr" style="text-align: left;"&gt;We have a network dataset with around 300k lines.&lt;/P&gt;&lt;P dir="ltr" style="text-align: left;"&gt;We have a car that has to do inspections on some elements along a route. It needs to visit 500-700 elements (most of them are close to each other).&lt;/P&gt;&lt;P dir="ltr" style="text-align: left;"&gt;The points create one simple route but are not ordered.&lt;/P&gt;&lt;P dir="ltr" style="text-align: left;"&gt;The way we solve the problem is to load the points as steps and to ask for best order route (usually the first point is really the start).&lt;/P&gt;&lt;P dir="ltr" style="text-align: left;"&gt;It creates a good route that visits every element.&lt;/P&gt;&lt;P dir="ltr" style="text-align: left;"&gt;The only problem is the time it takes. About 7 minutes to 700 points.&lt;/P&gt;&lt;P dir="ltr" style="text-align: left;"&gt;When the points is ordered it takes a few seconds.&lt;/P&gt;&lt;P dir="ltr" style="text-align: left;"&gt;Is there any way to speed the best route algorithm?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jan 2016 10:09:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613149#M5874</guid>
      <dc:creator>ModyBuchbinder</dc:creator>
      <dc:date>2016-01-14T10:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Find best order route is slow</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613150#M5875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is a lot of combination to figure out.&amp;nbsp; Have you tried a&lt;/P&gt;&lt;P&gt;lexicographic sort on the coordinates? Or is that what you mean by sorted? You really need to limit you search radius for the next possible candidate.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jan 2016 10:50:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613150#M5875</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-14T10:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Find best order route is slow</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613151#M5876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mody, NA based on the well-known Dijkstra's algorithm so if you need speed you need more rules/restriction so algorithm discards useless path evaluate &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jan 2016 10:50:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613151#M5876</guid>
      <dc:creator>nicogis</dc:creator>
      <dc:date>2016-01-14T10:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Find best order route is slow</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613152#M5877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The route is not going in one direction only but it might be a good idea to order the points by ariel distance first and then run the route in this order.&lt;/P&gt;&lt;P&gt;Do you know any ready to use tool that will order the point (starting from a known point) or do I have to write it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jan 2016 06:23:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613152#M5877</guid>
      <dc:creator>ModyBuchbinder</dc:creator>
      <dc:date>2016-01-15T06:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Find best order route is slow</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613153#M5878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;short of a simple sort on the XY coordinates of the points, which may speed things up, a spanning tree from an origin point may help since it provides the shortest connections between points.&amp;nbsp; I haven't experimented in a long time, but you could give this a try &lt;A href="http://www.arcgis.com/home/item.html?id=6ce9db93533345e49350d30a07fc913a" title="http://www.arcgis.com/home/item.html?id=6ce9db93533345e49350d30a07fc913a"&gt;http://www.arcgis.com/home/item.html?id=6ce9db93533345e49350d30a07fc913a&lt;/A&gt; (spanning tree tools) it may give you some ideas. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jan 2016 06:57:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613153#M5878</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-15T06:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Find best order route is slow</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613154#M5879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mody you can also approximate solution collapse your points of same edge in a single point ('most of them are close to each other') and then order all points after solve. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jan 2016 07:32:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613154#M5879</guid>
      <dc:creator>nicogis</dc:creator>
      <dc:date>2016-01-15T07:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: Find best order route is slow</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613155#M5880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think Domenico is on to something...your problem could be greatly simplified if you could group points or cluster them and use a representative location.&amp;nbsp; If you have 5 origin points all on the same block, it really doesn't matter their individual route solutions, since they will effectively be identical...if you throw a coffee break into the mix, your grouping distance could expand to a couple of blocks.&amp;nbsp; So I would follow his suggestion and have a good look at your point pattern(s) and see if there is any inherent clustering as origins and/or destinations&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jan 2016 07:44:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613155#M5880</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-15T07:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: Find best order route is slow</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613156#M5881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="text-align: left;"&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;I think I found a great solution (Dan post gave me the idea).&lt;/P&gt;&lt;P style="text-align: left;"&gt;We work so much with complex software that we forget how quick a computer is when it just do in memory calculation.&lt;/P&gt;&lt;P style="text-align: left;"&gt;The code below sort the point by distance (direct distance). It is running in memory and takes less the 3 seconds for 2000 points (including reading and writing to layer).&lt;/P&gt;&lt;P dir="ltr" style="text-align: left;"&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import sys
import traceback
import math
points = arcpy.GetParameterAsText(0)
# globals
coords = []
order = []
# find the closest point that is not connected
def FindClosest(x,y):
&amp;nbsp;&amp;nbsp;&amp;nbsp; global coords
&amp;nbsp;&amp;nbsp;&amp;nbsp; global order
&amp;nbsp;&amp;nbsp;&amp;nbsp; max1 = 1000000000000
&amp;nbsp;&amp;nbsp;&amp;nbsp; closest = -1
&amp;nbsp;&amp;nbsp;&amp;nbsp; for i in range(0, len(order)):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (order&lt;I&gt; != 0): continue
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # noo need for sqrt - just looking for the smallest
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dist = math.pow((coords&lt;I&gt;[0] - x),2) + math.pow((coords&lt;I&gt;[1] - y),2)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (dist &amp;lt; max1):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max1 = dist
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; closest = i&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return closest
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #read into memory
&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor(points, ["&lt;A href="mailto:SHAPE@X" rel="nofollow noopener noreferrer" target="_blank"&gt;SHAPE@X&lt;/A&gt;", "&lt;A href="mailto:SHAPE@Y" rel="nofollow noopener noreferrer" target="_blank"&gt;SHAPE@Y&lt;/A&gt;"]) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p = [row[0],row[1]]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; coords.append(p)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; order.append(0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("read %s records" % len(coords))
&amp;nbsp;&amp;nbsp;&amp;nbsp; # first record
&amp;nbsp;&amp;nbsp;&amp;nbsp; next1 = 2
&amp;nbsp;&amp;nbsp;&amp;nbsp; order[0] = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; x1 = coords[0][0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; y1 = coords[0][1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; # endless loop until we have no free points
&amp;nbsp;&amp;nbsp;&amp;nbsp; while(True):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = FindClosest(x1,y1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(x == -1): break # done
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; order&lt;X&gt; = next1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x1 = coords&lt;X&gt;[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y1 = coords&lt;X&gt;[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; next1 = next1 + 1&lt;/X&gt;&lt;/X&gt;&lt;/X&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; # update results
&amp;nbsp;&amp;nbsp;&amp;nbsp; i = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.UpdateCursor(points, ["order1"]) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[0] = order&lt;I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = i + 1&lt;/I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; #for i in range(0,len(order)):
&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("point %s order = %s" % (order&lt;I&gt;,i))
except:&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:13:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/find-best-order-route-is-slow/m-p/613156#M5881</guid>
      <dc:creator>ModyBuchbinder</dc:creator>
      <dc:date>2021-12-12T02:13:38Z</dc:date>
    </item>
  </channel>
</rss>

