# Procurement Process Optimization with Python

Use non-linear programming to find the optimal ordering policy that minimizes capital, transportation and storage costs

Use non-linear programming to find the optimal ordering policy that minimizes capital, transportation and storage costs

*Article originally published on **Medium**. *

**Procurement management** is a strategic approach to* ***acquiring goods or services** from preferred vendors, within your determined budget, either on or before a specific deadline.

Your target is to balance **supply **and **demand **in a manner to ensure a **minimum level of inventory** to meet your store demand.

In this article, we will present a simple methodology using **Non-Linear Programming** to design an** optimal inventory replenishment strategy** for a **mid-size retail store **considering:

- Transportation Costs from the
**Supplier Warehouse**to the**Store Reserve****($/Carton)** - Costs to finance your inventory
**(% of inventory value in $)** - Reserve (Store’s Warehouse) Rental Costs for storage
**($/Carton)**

💌 New articles straight in your inbox for free: __Newsletter__

**As a Supply Planning manager, you need to optimize inventory allocation to reduce transportation costs.**

**SUMMARYI. Scenario**

**II. Build your Model1. Declare your decision variables**

*What are you trying to decide?*

**2. Declare your objective function**

*What do you want to minimize?*

**3. Define the constraints**

*What are the limits in resources?***What is the suggestion of the model?**

**4. Solve the model and prepare the results**

**III. Conclusion & Next Steps**## I. Scenario

Problem Statement

As a Store Manager of a mid-size retail location, you are in charge of setting the replenishment quantity in the ERP.

For each SKU, when the inventory level is below a certain threshold your ERP is sending an automatic **Purchase Order (PO)** to your supplier.

You need to balance the constraints of stock capacity, transportation costs and cost of inventory to fix the right quantity for your PO.

**1 supplier**that receives your orders via EDI connection*(with your**ERP**)*and ships them using a 3rd Party Transportation company at your expense*Note: we’ll not consider any lead time in this article***60 active stock-keeping units (SKU)**with**a purchasing price ($/carton)**and a yearly**sales quantity (Cartons/year)****Transportation**using a 3rd party company that operates parcel delivery invoiced per carton**($/Carton)****Storage Location**(Store’s Reserve) with a capacity of**480 boxes**stored on shelves

To simplify the comprehension, let’s introduce some notations

**Annual Demand per SKU**

**Transportation**

b = 42.250 $

A = -0.3975 $/Carton

**Costs of Capital**

As a mid-size business, we suppose that your cost of capital is quite high: 12.5%.

**Storage Costs**

In this model, we suppose that we have the best landlord in the world. She invoices us by carton occupied taking the average value per year. We will not pay for the empty locations.

Imax= 480

Rmonth= 2,000 $/Month

**Question**

WhichQuantity per replenishment Qishould you set in the ERP to minimize the total costs?

*You can find the full code in this Github (Follow Me :D) repository:*

*Link*## II. Build your Model

Unlike the previous article of the series, we won’t use PuLP as we are not in a linear programming problem. We will be using the SciPy optimization functions to solve this non-linear minimization problem.

### 1. Declare your decision variables

*What are you trying to decide?*

We want to set the quantity per replenishment order sent by our ERP to the supplier.

**However**, to simplify our calculation we will use the number of replenishment per year **Ri **as a decision variable.

The replenishment quantity will be calculated using the formula below.

*Note: We accept to have a replenishment case quantity that is not an integer.*

### 2. Declare your objective function

*What do you want to minimize?*

The purchasing cost itself is not included in the objective function as it is out of the scope of our optimization targets.

**Code**

### 3. Define the constraints

*What are the limits in resources that will determine your feasible region?*

This is where problems start as we have a non-linear constraint (1/Ri).

### 4. Solve the model and prepare the results

What are the results of your simulation?

**Initial Guess**

Unlike Linear Programming, we need to provide an initial vector of a potential solution to the algorithm for the first iteration to initiate it.

Here, we’ll assume that 2 replenishments per year for all SKUs could be a good candidate.

**total cost for initial guessingHopefully, the optimal solution will be a lower result.**

**$63,206.7****Solve**

**Comment**

*I could not find any method to implement Integer Non-Linear Programming using Scipy solvers. If you have a solution, better than this quick-and-dirty rounding, using another library of python, can you please share it in the comment section?*

**Integer Solution:**

**$28,991.9****with a maximum inventory of 356 cartons**

**$29,221.3**## III. Conclusion & Next Steps

Conclusion

This optimized solution is **56% better than the initial guess** of 2 replenishment per year for all references.

### Demand Distribution

What if we have a stochastic distribution of your demand and we want to avoid stock-outs? In the article below, you can find a simple methodology to build replenishment rules assuming a stochastic distribution of your demand.

### Next Steps

We can see here that our solution is mainly driven by transportation costs as we have a maximum stock of **356 boxes**.

In the next article, we will perform an exploratory data analysis to understand the distribution of our decision variables and understand what drove the results for each reference.

We’ll also try to understand what is the impact of the transformation from continuous to integer decision variables.

Finally, we’ll try several scenarios to see how the model reacts:

- High rental costs and low transportation costs
- Non-linear purchasing costs
- Higher Minimum Order Quantity

### About Me

Let’s connect on Linkedin and Twitter, I am a Supply Chain Engineer that is using data analytics to improve logistics operations and reduce costs.

## References

[1] SciPy Optimization Library, Official Documentation, Link

[2] Samir Saci, Supply Planning using Linear Programming with Python