Location Optimis(z)ation in Alteryx

Ever wondered what the mysterious 4th macro type is in Alteryx? The one at the bottom called the Location Optimizer macro…well, hopefully this blog (in two parts) will be useful. This type of macro is designed to answer what is known as location-allocation problems (more on this later). According to Alteryx, this is “a macro that runs in multiple iterations determining the best locations to add or remove from a location network”. This post gives a brief introduction into what these types of problems are and how these problems are solved by examining the Alteryx sample workflow. In the next part of the post, we will show it in action.

Location allocation problems have been written about in GIS and operations research since the 60s and 70s (for some detailed background reading see here, or Tomintz, Clarke & Alfadhli in chapter 11 of Chris Brunsdon and Alex Singleton’s excellent Geocompution: a practical primer). At their most simple, they try to choose a set of facilities which cost the least to serve the most demand. They are a specific type of optimisation problem where geography, and the link between a set of origins (or demand points) and supply points (or facilities), play the key role. The idea is to find the optimal set of supply points that serve the demand as effectively as possible. There are many examples of practical applications that may use this problem, from choosing locations for depots, stores and pharmacies, to optimising the location of police stations and hospitals.

In mature networks, these types of approaches can be more theoretical and strategic than practical – after all it is unlikely that lots of locations would be closed just to open a different series of slightly more optimum locations. Moreover, in industries where the opening and closing of locations is dynamic, careful consideration of the local market, and indeed micro-location factors, are likely to be more important in decision making than creating the optimum network as a whole, and this is before we get into issues of site acquisition and planning permission. However, this doesn’t preclude the approach from being useful for some purposes.

One of the earliest and most used examples is the p-median problem attributed in Hakami in 1964 (I couldn’t find a pdf of this, but details here). This tries to find the optimum number of p locations that minimises the weighted distance of the system. Its probably easiest to see this in practice, via the Alteryx sample workflows (Optimise location by minimising distance), with a small bit of explanation first. This calculates the distance between a set of origin (demand) points (the orange boxes) and a set of potential (supply) locations (blue dots), and in doing so, choose which one facility has the lowest overall cost. The diagrams below try to explain this bit by bit. Let’s say that have 3 potential locations, but we don’t really want to use all of these, instead we need to minimise the costs of operating these by choosing 1. The question in this case is which one is the best?

To choose the best facility, we need to loop through each facility in turn, calculating the total distances (and weighting these by the demand at each demand point), and then select the best single facility which has the lowest (weighted) distance overall.

Obviously in reality, the scale of the analysis is likely to be much larger – with many more potential locations and many more demand points, and we will probably want to select more than just 1 facility. In practice this often means hundreds or thousands of potential locations that can be selected in thousands of possible combinations. This has to be done by running multiple iterations until the (heuristically) optimal solution is found.

Let’s have a look at an example via the Alteryx sample workflow, which is really useful for understanding the nuts and bolts. As with all macros, we need to run it from another workflow, and the example tries to add in a set of 3 new facilities to an existing network of 6 facilities, from a candidate list of over 1800 potential locations. The idea is to find the best combination of 3 new facilities to add to the existing 6 facilities. At the heart of the sample is the LocOpt_MinDistanceOptimizer, as shown below:

Alteryx Location Optmiser Minimizer distance Macro

Stepping through this, the demand locations coming into this from the D input already have the distance to the nearest existing facility appended to each of them. This is the current view of the network.

Note the existing distance field on the right

The macro will run by randomly select 3 new locations from the list of potential locations. It compares these to the current network by:

  1. Finding the nearest demand point to each supply point
  2. Establishing if the “new” distance is less than the existing distance (using two fields and the minimum formula)
  3. Then calculates the weighted average distance (it uses demand as the weighting field) for the entire network as a whole.

After 3, we have a single value for all demand and supply points which represents the “score” for the iteration’s combination of locations. The score and the existing distances are retained ready for the next iteration, which selects a different random combination of potential locations, and again tries to calculate the score. The use of the minimum function serves to decide the best demand-supply pair each time, and so a good pairing (which minimises the distance) is retained until a better pairing (with a lower distance) comes along. This is repeated many times with different combinations until the lowest score is found.

This happens REALLY quickly (if you use straight line distance). The sample actually runs hundreds of iterations across multiple phases (see below). The phases just start with random combinations (phase 1) before proceeding into assessing smaller changes with the best combinations in phase 2, according to this link. I couldn’t find much more on this – perhaps someone on the Alteryx Engine side who knows can add to this?

The settings for the macro are pretty easy. You just need to specify the output that you want to use as the score for each iteration, and whether you are trying to find a higher score or lower score, which will vary depending on your use. In the sample, it optimises for a lower score, as we want to find the lowest overall distance for each demand point.

And really, that’s it for the introduction to location optimiser macros. In part 2, we’ll describe a bit more about the types of location-allocation problems, and show how these can be used in more practical settings.

One thought on “Location Optimis(z)ation in Alteryx

  1. […] In Part 1, we introduced the Location Optimiser macro and how the p-median based approach for solving location-allocation problems is shown in the Alteryx sample workflows (trying to minimise the overall weighted distance that demand points have to travel to a set of potential facilities). In this part, we’ll give some examples to bring it to life a bit, and discuss some of the different approaches to simply minimising distance. […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s