Customer Assignment

Customer Assignment Model

The goal of this model is to pick a set of retail store locations, chosen from among a set of candidate locations, to maximize the total number of potential customers. The likelihood that a customer visits a store is assumed to decrease as the distance from that customer to the nearest store increases.

Define model parameters

Number of customers, number of candidate store locations, number of stores to build (from among the candidate locations), and number of clusters to group the customers into. Feel free to modify any of these.

In [1]:

Determine customer and candidate store locations

In this simple example, we choose random locations for customers and store candidates. Customers are distributed using Gaussian distributions around a few randomly chosen population centers. Store locations are uniformly distributed.

In [2]:


First customer location: (-0.35900217499377257, 0.2709793718400695)

Create clusters

To limit the size of the optimization model, we group individual customers into clusters and optimize on these clusters. Clusters are computed using the KMeans algorithm (as implemented in the scikit-learn package).

In [3]:

First cluster center: [-0.46785392 0.32856046]

Weights for first 10 clusters: [61, 79, 79, 35, 17, 77, 51, 27, 61, 95]

Define store attraction function

Trivial attraction model – the further away the store is, the less attractive it is to the customer

In [4]:

Filter viable customer-store pairings

Collect viable pairings – some stores are just too far away from a customer to be relevant. Threshold is heuristic and arbitrary.

In [5]:

Build optimization model

Pick stores from among candidate locations to maximize total customer attraction

In [6]:

Plot results

Show a map of customers (small red dots), customer clusters (large red dots), selected store locations (green dots with incident lines), and customers likely to be attracted to those stores (lines)

In [7]:

Modeling Example

Access the Jupyter Notebook