Maximizing Sales with Quadratic Programming: A Detailed Implementation Guide
Learn how to optimize & improve sales force coverage by using Quadratic Programming
In today’s competitive business environment, it is critical for organisations to optimise their sales force coverage through enhancing territory design in order to boost revenue and enhance efficiency. Territory design is the process of partitioning a market into geographical regions known as territories and assigning salespeople to oversee those territories. This procedure entails assessing statistics such as Revenue, market size, and customer demographics to find the most effective approach to divide and distribute territories. The purpose of territory design is to optimise the effectiveness of the sales team by ensuring that each salesperson has a suitable number of potential customers and that the workload is balanced across the team.
One powerful tool that can help with this is quadratic programming. Quadratic programming is a mathematical technique for solving difficult optimization problems that include several variables and restrictions.
In this blog, we’ll look at how quadratic programming can be used to improve sales force alignment, with a focus on coding in Python, map plots in Folium, and optimization in cvxpy.
What is Quadratic Programming?
Before getting into the use of Quadratic Programming in territory design, it is critical to understand the fundamentals of Quadratic Programming. Quadratic Programming is a numerical optimization method for problems with a quadratic objective function and constraints. This optimization method is used to find the optimal variable values that will improve the objective function while satisfying the restrictions. Quadratic Programming is a powerful method that may be used to tackle a wide range of issues, from fitting curves in statistics and many more.
Quadratic programming is a powerful optimization technique because it can handle non-linear objective functions that linear programming cannot. Furthermore, Quadratic Programming allows us to include linear restrictions, making it a versatile optimization tool. The approach is frequently utilised in many industries, including finance, engineering, and operations research.
To learn more about Linear programing, please read —
What Information Do We Need?
Before beginning the process of territory design for sales force alignment, it is crucial to have the geographical location information of the entities we wish to map. For example, in the case of a pharmaceutical company targeting hospitals in a specific location to promote their drug, hospitals can be considered as entities. By grouping these entities together, we can effectively create territories.
In this article, we will be using fictitious data based on Bangalore locations. The data will be made up of random Revenue and Workload values. Revenue is the predicted value of each hospital’s projected income, while the workload is the quantity of human effort required for marketing. The workload can be calculated by dividing the number of man-hours required for marketing by the number of man-hours in a month. In this example, we used random values ranging from 10,000 to 100,000 for Revenue and 0.1 to 0.2 for Workload.

Step 1: Selecting Seed Accounts
The first step in using quadratic programming for territory design is to carefully select the seed accounts. Seed accounts are a crucial set of accounts that serve as the foundation for organizing the sales team. These accounts are chosen based on their geographical location in relation to one another. The goal of selecting seed accounts is to cover the entire area with the minimum number of seed accounts possible. This helps in reducing the workload of sales representatives and increasing the coverage area.
Various strategies, such as k-means clustering or hierarchical clustering, can be used to choose the seed accounts. These strategies help to identify the seed accounts by grouping the accounts based on their location. However, in this article, we will choose the seed accounts based on their proximity to one another. The objective is to choose seed accounts that are wide apart so that the area is well covered. We’ll begin by picking a hospital at random as the seed account. Then, based on the distance from the chosen seed, we will select the hospital with the greatest distance as the next seed. This technique will be repeated until we have enough seeds. Once the seed accounts have been selected, we can begin to optimize the alignment of the sales force.

Step 2: Optimization function — Maximising Revenue per Distance
The next step in using quadratic programming for territory design is to optimize the alignment of the sales force based on revenue and distance. The objective is to find the best possible territory boundaries that maximize revenue per distance from the seed accounts. By using quadratic programming to find the territory boundaries, we can increase revenue and improve efficiency.

Step 3: Defining Constraints
When employing quadratic programming for sales force alignment, numerous constraints must be considered. These limits aid in ensuring that the final solution is designed in accordance with the requirements. Some of the major constraints that must be considered are as follows:
- Every entity should only be linked to one territory: It is essential that each account be assigned to a single seed account. This constraint helps to guarantee that the sales staff covers each account and that there is no overlap between territories.
- Workload should be balanced for each territory: It is critical to ensure that the sales team’s job is distributed evenly. This constraint prevents any one salesman from being overworked while others are underworked. We can boost the sales team’s efficiency by balancing the workload.
- Distance from the base should be within a threshold: It is important to ensure that the distance between the seed account and the accounts within the territory is within a certain range. This constraint ensures that the sales staff can efficiently cover the full territory. A sales representative, for example, should be able to cover all of the accounts in the region within a reasonable time frame.
By taking these constraints into account, we can ensure that the final solution is practical, covers all accounts, has a balanced workload, and is efficient. The purpose of quadratic programming is not only to maximise the objective function but also to satisfy the restrictions.
Implementation
We can use Python to implement the constraints and solve the quadratic programming problem using cvxpy library & plot the results using Folium.
cvxpy is a modelling language for convex optimization problems that are incorporated in Python. It gives the user the ability to represent a convex optimization issue in natural terminology. The package allows you to create convex and non-convex optimization problems with and without constraints. It also enables the design of complex, multi-objective optimization problems in which numerous objectives are optimised at the same time.
Folium uses the Leaflet.js package to allow users to build interactive maps. It allows the user to generate maps that may be shown in a web browser quickly and effortlessly. The library enables the user to add map objects such as markers, polygons, and lines. It also allows the user to alter the map’s design and components, such as changing the colours, markers, and labels.
Please refer to the Kaggle notebook for implementation details:
Conclusion

Quadratic programming is an effective optimization approach for improving sales force alignment and increasing revenue. We can utilise quadratic programming to optimise sales force alignment by picking seeds, maximising Revenue per distance, and taking into account restrictions such as account mapping, workload balance, and distance from the base. This method improves efficiency by reducing the effort of sales personnel while expanding their coverage area. With the help of this guide, you should now be able to apply quadratic programming for sales force alignment and implement it using Python, Folium, and cvxpy. These libraries are extensively used in data analysis and optimization, and they make it simple to put the procedures mentioned in this blog post into action. By following the steps outlined in this guide, you will be able to use quadratic programming to improve your own sales force alignment and increase revenue.
References:
- https://python-visualization.github.io/folium/modules.html?highlight=marker#:~:text=The%20color%20of%20the%20marker,black'%2C%20'lightgray'%5D
- https://pubsonline.informs.org/doi/10.1287/mnsc.29.11.1237
- https://towardsdatascience.com/linear-programming-theory-and-applications-c67600591612
If you have read so far, a big thank you for reading! I hope you find this article to be helpful. If you’d like, add me on LinkedIn!
Good luck this week, Pratyush






