I have a Multiple product LP optimization problem in which the product(B1,B2,D) will be received in variable quantity with respect to date column.
The Optimizer should LP variable Output as Assy Out B1, Assy Out B2, Assy Out D, Open Assy Line (Binary decision to produce or not in given date).
The target is to maximize the assembly output per day.
The constraints are material receipt for each date and not allowed to produce more than material available in each date
I used the code below:
dfs=dfs.set_index(dfs['t']) x=np.arange(1,10) Assy_B1=pulp.LpVariable.dicts('Assy_B1',x,0,None,'Integer') Assy_B2=pulp.LpVariable.dicts('Assy_B2',x,0,None,'Integer') Assy_D=pulp.LpVariable.dicts('Assy_D',x,0,None,'Integer') Open_Line=pulp.LpVariable.dicts('Open_Line',x,0,None,'Binary') model=LpProblem('Assembly_Plan',LpMaximize) model +=lpSum([ Assy_B1[t] + Assy_B2[t] + Assy_D[t] for t in x]) for i in x: model+=(Assy_B1[i]+Assy_B2[i]+Assy_D[i])<=(dfs.loc[i,'Max_Capacity ']*Open_Line[i]) model+=lpSum(Assy_B1[i])<=dfs.loc[i,'INPUT B1'] model+=lpSum(Assy_B2[i])<=dfs.loc[i,'INPUT B2'] model+=lpSum(Assy_D[i])<=dfs.loc[i,'INPUT D'] model.solve()
The Model Solution is Optimal and output as below:
Everything is fine except the last date, the model should have capacity to produce 100 but utilized less (date 5/5/2022 cumulative produced is 60 and still 40 of model D can be produced on that day).
Similarly if the input material is available and capacity is less than cumulative material available the model should fit in next best available date for the same.
I am not able to fix this Constrain/Relaxation in Pulp.