Understanding Linear Programming
Linear programming (LP) is a method for engineers or data scientists to find the best outcome of a business problem i.e maximum profit, minimum cost in a linear mathematical model.
Each of the LP problem consist of following components : 1. Objective Function : Purpose behind LP i.e maximize profit, minimize loss , 2. Decision Variables : These are the controllable variables that influence the objective function, 3. Constraints : These are linear restrictions on decisions variables.
Case Example : XYZ Pharmaceuticals
XYZ Pharmaceuticals manufacturers two types of medicine with same salt : A and B. The manufacturer wants to maximize their weekly operational profit.
$1 of profit per medicine A.
$1.5 of profit per medicine B.
Medicine A requires 1 hour of manufacturing labor and 2 hours of packaging labor.
Medicine B requires 2 hours of manufacturing labor and 1 hour of packaging labor.
Each week, XYZ has only 100 hours of manufacturing labor and 100 hours of packaging labor available.
Lets Build the Objective Function, Decision Variables and Constraints
Let x be the of medicine A produced and y be the medicine B product in the week
Objective Function : Max(z) = 1x + 1.5y
Decision Variables (Subject to) 1x + 2y <= 100 (Available Manufacturing Hours) 2x + 1y <=100 ( Available Packaging Hours)
Constraints : x >= 0 & y >= 0
Loading & Solving the Problem Statement in PuLP
Discussing Solution
We see that the optimal solution for production of Medicine A & B to return maximum profit is 33.33 units weekly for both A & B to maximize the profit up to 83.33 units. We can even plot the illustrative graph using matplotlib library in python.
There are many commercial optimizer tools, but having hands-on experience with a programmatic way of doing optimization is invaluable.
Comments