Production Planning Example with PuLP

Production Planning Example with PuLP

Let’s consider a simple Production Planning problem for a factory that produces two products: Product A and Product B.

The factory has limited resources: labor hours and raw material.

The goal is to maximize the profit while respecting the constraints of available resources.

Problem Statement:

  • Product A requires:
    • $2$ labor hours per unit
    • $3$ kg of raw material per unit
    • Yields a profit of $30 per unit
  • Product B requires:
    • $3$ labor hours per unit
    • $1$ kg of raw material per unit
    • Yields a profit of $20 per unit

The factory has:

  • $100$ labor hours available per week
  • $90$ kg of raw material available per week

The factory needs to decide how many units of each product to produce to maximize profit, given the constraints.

Mathematical Model:

Let:

  • $(x_1)$ = number of units of Product A produced
  • $(x_2)$ = number of units of Product B produced

Objective:
$$
\text{Maximize } 30x_1 + 20x_2
$$
Subject to:
$$
2x_1 + 3x_2 \leq 100 \quad \text{(labor hours constraint)}
$$
$$
3x_1 + 1x_2 \leq 90 \quad \text{(raw material constraint)}
$$
$$
x_1 \geq 0, \quad x_2 \geq 0 \quad \text{(non-negativity constraint)}
$$

Solution using PuLP:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pulp

# Define the problem
problem = pulp.LpProblem("Production_Planning", pulp.LpMaximize)

# Decision variables
x1 = pulp.LpVariable('x1', lowBound=0, cat='Continuous') # Units of Product A
x2 = pulp.LpVariable('x2', lowBound=0, cat='Continuous') # Units of Product B

# Objective function
problem += 30 * x1 + 20 * x2, "Profit"

# Constraints
problem += 2 * x1 + 3 * x2 <= 100, "Labor_hours"
problem += 3 * x1 + 1 * x2 <= 90, "Raw_material"

# Solve the problem
problem.solve()

# Output the results
print("Status:", pulp.LpStatus[problem.status])
print(f"Optimal number of Product A to produce: {x1.varValue}")
print(f"Optimal number of Product B to produce: {x2.varValue}")
print(f"Maximum Profit: ${pulp.value(problem.objective)}")

Explanation:

  • Decision variables represent the number of units of each product to be produced.
  • Objective function aims to maximize the total profit from producing both products.
  • Constraints ensure that the production doesn’t exceed the available labor hours and raw material.

Results:

1
2
3
4
Status: Optimal
Optimal number of Product A to produce: 24.285714
Optimal number of Product B to produce: 17.142857
Maximum Profit: $1071.4285599999998

Explanation of the Results:

The problem has been solved, and the solution status is “$Optimal$”, meaning the solution found satisfies all the constraints and maximizes the profit under the given conditions.

  • Optimal number of Product A to produce: $24.29$ units (rounded to two decimal places)
  • Optimal number of Product B to produce: $17.14$ units (rounded to two decimal places)

Since the solution involves fractional units (which might represent part of a batch or a continuous process in certain industries), the optimal production mix is not whole numbers.

  • Maximum Profit: $1071.43

This means that producing approximately $24.29$ units of Product A and $17.14$ units of Product B will yield the highest possible profit of $1071.43, while respecting the constraints on labor hours and raw materials.

If the production process must involve whole units, you might consider rounding these values or solving the problem using integer programming, depending on the context.