Unlocking the Potential of AI and OR
Vijay Gupta, PhD
Head - Operations Research @ Adani AI Labs | Carnegie Mellon | IIT | ISB | Ex-Shell | Ex-IBM
Balancing demand, operational constraints, and costs in production planning can be complex. Artificial Intelligence (AI) and Operations Research (OR) offer powerful tools to optimize this process. This post explores how advanced AI models can be utilized with OR for enhanced production planning (as an example).
The Challenge: Finding the Optimal Strategy
As a production planner, your goal is to create a cost-effective daily schedule for various plants while meeting demand and constraints like capacity and availability. Failure to meet demand incurs penalties.
Example Scenario
·???????? Product Demand & Penalty: Daily product demand and penalties for unmet demand.
·???????? Plant Details: Capacity limits, costs, availability, and ramp rates.
·???????? Constraints: Demand satisfaction, source capacity, plant availability, ramp up/down rates, and external sourcing for unmet demand.
OR Approach
This optimization problem can be addressed using OR models such as multiperiod LP, solved by available solvers to minimize monthly production costs.
Results: The Optimal Plan
Using the OR model, we obtained an optimal production schedule with minimal costs.
Battle Ground: Testing the Smartest AI Models
We tested several advanced AI reasoning models:
·???????? OpenAI’s o1, Google's Gemini 2.0 Flash and DeepSeek-R1: All the 3 models failed to provide even feasible solutions due to constraint violations. However, they were able to explain and formulate the mathematical model.
Optimization Model Explanation from AI Models
Below is the response from one of the AI Models to structure the problem:
We need to minimize the total cost, which includes production costs at each plant and penalty costs for unmet demand.? The problem has several constraints:
?* Demand Satisfaction:? Production from the plants must meet the daily demand, or incur a penalty.
?* Capacity Constraints: Each plant has a maximum production capacity.
?* Availability Constraints: Plant 1 is only available on certain days.
?* Minimum Capacity Constraints: Each plant has a minimum production level.
?* Ramp-up/Ramp-down Constraints:? The change in production from one day to the next is limited.
Optimization Model
We can formulate this as a linear programming (LP) problem.
Decision Variables:
?* P1[t]: Production from Plant 1 on day t
?* P2[t]: Production from Plant 2 on day t
?* P3[t]: Production from Plant 3 on day t
?* U[t]: Unmet demand on day t
Objective Function:
Minimize:? ∑(8 P1[t] + 12 P2[t] + 15 P3[t] + 100 U[t])? for all days t
Constraints:
?* Demand Satisfaction: P1[t] + P2[t] + P3[t] + U[t] = Demand[t] for all t
?* Capacity Constraints: P1[t] <= 1500, P2[t] <= 5000, P3[t] <= 2000 for all t
?* Availability Constraint: P1[t] = 0 for t < 11 or t > 20
?* Minimum Capacity Constraints: P1[t] >= 200, P2[t] >= 400, P3[t] >= 200 for all t
?* Ramp-up Constraint: P2[t] - P2[t-1] <= 500, P3[t] - P3[t-1] <= 300 for t > 1
?* Ramp-down Constraint: P2[t-1] - P2[t] <= 300, P3[t-1] - P3[t] <= 150 for t > 1
?* Non-negativity: All variables must be non-negative.
The Game Changer: Shifting from Results to Code
Instructing AI models like Google's Gemini 2.0 Flash and DeepSeek-R1 to generate Python code using PuLP for optimization provided the code which generates the optimal solution when solved with LP solver. Below is the generated code:
```python
from pulp import LpMinimize, LpProblem, LpVariable, lpSum, value
Data
days = list(range(1, 31))
demand = {...}? # Daily demand data
penalty_cost = 100
领英推荐
Plant data
plants = {
??????????????? "Plant1": {"capacity": 1500, "cost": 8, "availability": list(range(11, 21)), "min_capacity": 200},
??????????????? "Plant2": {"capacity": 5000, "cost": 12, "availability": days, "min_capacity": 400, "ramp_up": 500, "ramp_down": 300},
??????????????? "Plant3": {"capacity": 2000, "cost": 15, "availability": days, "min_capacity": 200, "ramp_up": 300, "ramp_down": 150}
}
Define the problem
prob = LpProblem("Production_Optimization", LpMinimize)
Decision variables
P1 = LpVariable.dicts("P1", days, lowBound=0, upBound=1500)
P2 = LpVariable.dicts("P2", days, lowBound=400, upBound=5000)
P3 = LpVariable.dicts("P3", days, lowBound=200, upBound=2000)
U = LpVariable.dicts("U", days, lowBound=0)
Objective function
prob += lpSum([8 P1[i] + 12 P2[i] + 15 P3[i] + 100 U[i] for i in days])
Constraints
for i in days:
??????????????? # Demand constraint
??????????????? prob += P1[i] + P2[i] + P3[i] + U[i] >= demand[i]
??????????????? # Plant 1 availability
??????????????? if i not in plants["Plant1"]["availability"]:
??????????????? ??? prob += P1[i] == 0
??????????????? else:
??????????????? ??? prob += P1[i] >= plants["Plant1"]["min_capacity"]
??????????????? # Ramp-up and ramp-down constraints for Plant 2
??????????????? if i > 1:
??????????????? ??? prob += P2[i] - P2[i-1] <= plants["Plant2"]["ramp_up"]
??????????????? ??? prob += P2[i-1] - P2[i] <= plants["Plant2"]["ramp_down"]
??????????????? # Ramp-up and ramp-down constraints for Plant 3
??????????????? if i > 1:
??????????????? ??? prob += P3[i] - P3[i-1] <= plants["Plant3"]["ramp_up"]
??????????????? ??? prob += P3[i-1] - P3[i] <= plants["Plant3"]["ramp_down"]
Solve the problem
prob.solve()
Results
results = [{"Day": i, "Demand": demand[i], "Plant1": value(P1[i]), "Plant2": value(P2[i]), "Plant3": value(P3[i]), "Unmet Demand": value(U[i]), "Total Production": value(P1[i] + P2[i] + P3[i]), "Cost": value(8 P1[i] + 12 P2[i] + 15 P3[i] + 100 U[i])} for i in days]
Print results
print("Day | Demand | Plant1 | Plant2 | Plant3 | Unmet Demand | Total Production | Cost")
for res in results:
??????????????? print(f"{res['Day']} | {res['Demand']} | {res['Plant1']} | {res['Plant2']} | {res['Plant3']} | {res['Unmet Demand']} | {res['Total Production']} | {res['Cost']}")
Total cost
total_cost = sum(res["Cost"] for res in results)
print(f"\nTotal Optimum Production Cost: {total_cost} Rs")
```
Towards Perfection: Combining AI and OR Strengths
Our experiments show AI's potential in analyzing and structuring the OR problems, producing a basic math formulation and generating the solver code can significantly enhance the efficiency of OR scientists. AI reasoning can be used to generate a good initial solution for some of the most complex OR problems as well which can improve OR algorithms efficiency. Combining multiple AI models' outputs can lead to even better results, enabling powerful optimization solutions significantly faster and cheaper. Finally, AI is an excellent enabler for handing more and more complex OR problems.
Stay tuned.. We will share more comparisons for harder OR problems in coming weeks and how AI reasoning capabilities can be leveraged.
Data scientist- Operations Research- Tesco| Ph.D. (Logistics & Supply Chain Management)
1 个月Insightful to read this Vijay Gupta, PhD. Kudos to entire team??
Practice Head
1 个月Insightful!
Staff Data Scientist- Blue Yonder || Ex - FICO || Ex - IIM Faculty || Ex - Zycus || PhD - IIT Kharagpur || Operations Research & Supply Chain Management
1 个月Very informative Vijay Gupta, PhD
Great work Vijay Gupta, PhD. Very good example of how AI can democratize algorithms for all.
Systems Engineering, Digital Twins, Predictive Maintenance, DS & ML/AI
1 个月Thanks for the insights, Vijay!!!