# 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

**from preferred vendors, within your determined budget, either on or before a specific deadline.**

**acquiring goods or services**Your target is to balance ** supply **and

**in a manner to ensure a**

**demand****to meet your store demand.**

**minimum level of inventory**In this article, we will present a simple methodology using ** Non-Linear Programming** to design an

**for a**

**optimal inventory replenishment strategy****considering:**

**mid-size retail store**- Transportation Costs from the
to the**Supplier Warehouse****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__

**SUMMARY**

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

**II. Build your Model**

**1. 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?*

**4. Solve the model and prepare the results**What is the suggestion of the model?

**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.

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

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= 480Rmonth= 2,000 $/Month

**Question**

Whichshould you set in the ERP to minimize the total costs?Quantity per replenishment Qi

*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

**as a decision variable.**

**Ri**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 guessing**

**$63,206.7**Hopefully, the optimal solution will be a lower result.

**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?*

Initial Solution:

**$28,991.9**Integer Solution:

**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