# Force closest facilities take the same route

I have a routing problem that I intend to solve with ArcGIS network analyst. First, Closest facility works perfect for me to find the shortest paths to a number of demands. The results look like the left part of the figure:

For my analysis I would like to compare the left situation with the right one, when it is more cost-efficient to share the route. This far I have just painted the routes in the right part for clarity. In a normal Dijkstra I would just recursively adapt the weights of the links, setting the already chosen to a lower cost. However, I do not know how could I do this in ArcGIS closest facility.

Is there a way to modify the shortest path algorithm in Network analyst?

You cannot make modifications to the Closest Facility solver directly from ArcMap without writing your own solver with ArcObjects and say Visual C++ or C#. Look for more details here Custom solver.

However, there is a simpler approach. If you are OK with some Python scripting, this is what you could do with arcpy (Python programming) to tackle this problem:

1. Take any of the incident points and solve Route problem finding the shortest/fastest path from the incident to each facility. Find the best route (compare the total travel time / km).
2. Find out what road links have been traversed by this particular route. There is even a GP tool for that.
3. Load those line features as scaled-cost barriers in the same Route network layer. You can specify factor of 0-0.9 to make the cost of traversing the same road links smaller. So if traversing a road link costed 10min, with factor 0.6 it will be just 6 min. This means that the road links which have been traversed by the first incident-facility route will be more attractive to subsequent routes.
4. Repeat the step 1 taking next incident point and the facilities present. Having scaled-cost barriers loaded, the traversed road links will be more attractive to the routes generated.

The steps above can be easily automated with arcpy. Please take a look at this sample.

• thank you! The second way is pretty much, what I was thinking about. Dec 17, 2015 at 22:33
• No problem! If you stuck at some point of implementing the workflow, please do post a question we could take a look. Dec 18, 2015 at 8:17