Maximize your Business Profitability with Python

Use linear programming to help your local bakery to improve its business profitability by selecting the right items to sell

Maximize your Business Profitability with Python

Use linear programming to help your local bakery to improve its business profitability by selecting the right items to sell

If you‘ve read my previous articles, you will notice that my main focus is always to use Linear Programming, Machine Learning or Statistics to reduce operational costs.

As a Supply Chain Solution Designer for a 3PL, my mission was always to cut the costs to keep competitive pricing for our customers.

However, these tools and concepts can also be used to maximize the profit of your Supply Chain by focusing your production on high margin products.

In this article, I will show you how to help your local bakery to maximize its profit by producing the right items using Linear Programming with Python.

I. Scenario


Problem Statement

You want to help your local bakery to maximize its profit. They sell several types of products including cakes, pastries and sandwiches.

Available resources

  • 4 bakers working 6 hours per day (Total: 24 hours/day)
  • 1 assistant for sandwiches 4 hours per day
  • 2 ovens that can be used 24 hours per day (Total: 48 hours/day)
  • 100 slots available for stock and display

These items have different resource needs and profit level

Resources needs for each of your SKU — (Image by Author)

Objective

What do you need to produce to maximize your daily profit?

  • Results
Lemon Cake = 0
Sandwich = 20
Chocolate Cake = 32
Croissant = 0
Chocolate Eclair = 0
Panini = 0
Profit reached: 328 euros/day

Based on these results, your local bakery owner should focus his attention on Chocolate Cakes and Sandwiches to reach a maximum profit of 328 euros/day.

This result can be improved by implementing more constraints and parameters to ensure that your model shows the actual reality of your business.

  • What is the utilization ratio of your resources?
Lemon Cake = 0
Sandwich = 20
Chocolate Cake = 32
Croissant = 0
Chocolate Eclair = 0
Panini = 0
1,440/1,440 minutes of bakers used
2,880/2,880 minutes of oven used
240/240 minutes of assistants working time used
126/200 display slots
Profit reached: 328.0 euros

Good news! You are fully utilizing your equipment and workforce.

  • What if we have two more assistants to make sandwiches?
Lemon Cake = 0
Sandwich = 60
Chocolate Cake = 32
Croissant = 0
Chocolate Eclair = 0
Panini = 0
Profit reached: 504 euros
  • 50% profit increase if you recruit two more assistants (4h/day) by selling more sandwiches
🔗
You can find the full code in this GitHub repository: Link.

II. Build your Model

We will be using the PuLP library of python. PuLP is a modelling framework for Linear (LP) and Integer Programming (IP) problems written in Python maintained by COIN-OR Foundation (Computational Infrastructure for Operations Research).

1. Declare your variables, parameters and model

  • LpMaximize: your objective is to maximize your profit
  • lowBound =0: you cannot have a negative value of pastries
  • cat = ‘Integer’: let’s try to sell entire croissants :)

These parameters can be loaded from an Excel file.

2. Define the objective and add constraints

3. Solve your model and analyze the results

III. Next Steps


1. Improve your model

Your local bakery cannot stop selling Lemon Cake from one day to another because it is not profitable.

Therefore in your model, you can add constraints of minimum quantity for each item to guarantee that your fans of lemon cake will have their favourite product.

Additional parameters and constraints can be added like ingredients quantity, shelf life, …

2. Share your model with your local bakery owner

Now that you’ve built your tool you would like to share it with your local bakery owner.

Could you imagine the impact on her business you would have if you could implement this simple tool? (and how many free lemon cakes you could get ?)

If you are interested, I have written an article on how to share your python script ready to be used by people without any prior experience of Python.

3. How many assistants do you need?

Take inspiration from this article showing a simple methodology using Linear Programming to optimize your workforce allocation assuming a fluctuating workload.

References

[1] Computational Infrastructure for Operations Research, Optimization with PuLP (Documentation), Link