Set variable distance/time limits in Model Builder for Network Analysis

4557
6
12-08-2014 12:25 PM
HamishKingsbury1
Occasional Contributor

Hey All

I'm using ArcMap 10.2.2. I am working on a routing project, it requires me to produce a network that is based on vehicle statistics. One of the desired functionality that is required is for this route to be within x% of the fastest and/or shortest route between the same points. I have developed a model that will create routes based on the shortest, fastest and one based on the statistics with no distance/time restrictions.

What I want to be able to do is pass the Total_Length (from shortest) and/or the Total_Time (from quickest) plus x% into the network based on vehicle statistics as a restriction. How do i go about doing this in Model Builder? I have tried playing around with variables but have had any luck.

Any help is appreciated.

Cheers in advance

Hamish

0 Kudos
6 Replies
MelindaMorang
Esri Regular Contributor

Hello Hamish.  So, you essentially want to constrain your route to fail (or something) if it exceeds cost + x% of the shortest route (in time or distance).  Unfortunately, I don't think there's a way you can set up a restriction attribute to do this.  Restriction attributes (and, in fact, all network attributes) have values specific to network edges.  They don't know about the Route as a whole while you're solving it.  When you click Solve, the network edges are searched to find the shortest path.  Each time a new network edge is reached, the cost attribute's evaluator returns a value indicating the cost of traversing that edge.  The restriction attribute kicks in just before that, to indicate whether traversal is prohibited across that edge or whether the result should be scaled by some factor.  Neither the restrictions nor the cost attributes have any other information about the network edges already queried or traversed, though, so you couldn't create a restriction that kicks in after your total travel time for that Route has reached a certain value.

I think your best bet is to do some clever post-processing.  You'll have to check the results of your third Route (the one based on the statistics) and compare the value with the values obtained in your previous length-based and time-based solves, and then mark the ones that are outside your acceptable range.

If you describe your end goal a bit more thoroughly, I'm happy to help you continue brainstorming.

0 Kudos
HamishKingsbury1
Occasional Contributor

Hi Melinda

So ultimately, the end goal is to create a web app that a user can enter their start/end destination. They can specify whether the shortest, fastest and safest (vehicle stats) route is returned. For users who don't want to travel the full length of the safest route (often close to twice the distance/time) they can specify to have a route that is x% longer/faster than the shortest/fastest route.

Hopefully, that's a bit clearer.

Cheers

0 Kudos
MelindaMorang
Esri Regular Contributor

Oh, so the route returned might be a compromise between length and safety, because the shortest route might be somewhat unsafe, but the safest route is too long.  Got it.

Hmm...I'm not sure if there is a way to do that in Network Analyst.  We don't really have a way to constrain Routes in that way.  Perhaps you could take a slightly different approach and create a few more cost attributes that balance length and safety.  The user couldn't input a % longer/faster amount, but maybe they could choose from a few different options ranging from safest to shortest, and then pick the one that seems best to them.

I'll pass your question on to some of my colleagues and see if anyone else wants to weigh in.  It's an interesting problem.

0 Kudos
HamishKingsbury1
Occasional Contributor

Thank you for that, hopefully someone has an idea of a way to approach this.

0 Kudos
MichaelRice
New Contributor III

Hi Hamish,

Unfortunately, the problem you are trying to solve is a variant of the notoriously-difficult “Resource Constrained Shortest Path Problem”. There are algorithms for solving this problem, but they can require exponential time to run in the worst case. So, basically, you cannot hope for a solution which is always practically-fast for all inputs of this problem type.

Furthermore, as Melinda pointed out, there is currently nothing in Network Analyst to support such constraints directly anyway. So, even if you wanted to use one of these algorithms, you would have to implement it yourself as a "custom solver".

Therefore, unless you want some help/advice on implementing a custom solver in Network Analyst from scratch (which is no trivial task), you will have to consider alternative formulations or be willing to relax your constraints. For example, assuming you have two separate cost attributes (let's call them A and B), you could always define a third cost attribute (C) which represents some weighted combination of the two (e.g., C = x*A + y*B, for some x,y values in the range between 0.0 and 1.0). This would allow you some form of control over how you wish to weight the contribution of each individual attribute in the resulting paths if solving for the "hybrid" cost attribute C.

Let us know which direction you might like to take this in, and we can discuss any further options with you then.

HamishKingsbury1
Occasional Contributor

Hi Michael

Thank you for that. I have spoken with some other team members and we have come to the conclusion that using a weighted combination would be the most appropriate approach for this project.

Thank you again, to both you and Melinda Morang

0 Kudos