Linear Programming (LP) is a core mathematical optimization technique, used to determine the best possible outcome (maximum profit, minimum cost, optimal allocation) under a set of constraints.
In this example, we will try to find the maximum profit that can be earned by manufacturing two products, A and B.
Below are the facts about the given problem:
| Item | Product A | Product B |
|---|---|---|
| Profit per unit | $40 | $30 |
| Labor hours needed | 2 | 1 |
| Material units needed | 1 | 1 |
Constraints:
- Labor = 100 hours
- Material = 80 units
- Define the problem: We want to maximize the profit by manufacturing two products, A and B.
- Define the variables: x = number of units of product A, y = number of units of product B.
- Define the objective function: profit = 40x + 30y.
- Define the constraints: 2x + y <= 100, x + y <= 80, x >= 0, y >= 0.
- Solve the problem using a linear programming solver.
Refer main.py for the code implementation.
-
Refer below youtube video to understand the concepts of Linear Programming. https://www.youtube.com/watch?v=Bzzqx1F23a8
-
Use matplotlib to plot the constraints and the solution.