Hello,
I am currently modelling a supply problem that attempts to optimise a rail schedule which moves products from a production plant, to a warehouse to satisfy sales.
The model is working fine, however I would like to create a variable that shows the extent of a supply shortfall i.e. if the current inventory is 0, and demand is > 0, then the model is unable to satisfy the constrains and returns 'unfeasible'.
I would like to define a variable to captures the shortfall so that the end result is always 'optimal' even though a shortfall is realised, and shows the extent.
i.e.
desired_output_df.head(10)
>>>
date product current_inventory sales_demand inventory_shortfall
'2020-01-01' 'AFM' 10000 5000 0
'2020-01-02' 'AFM' 5000 5000 0
'2020-01-03' 'AFM' 0 6000 6000
My attempt to model this can be found below. As there is a significantly large amount of code, it is very difficult to create a MRE, so I am hoping that I could just get a steer on the best way to attempt this :)
# Objective Function
model += pulp.lpSum([
storage_inventory_target_overage[(date, product)]
+ storage_inventory_target_shortage[(date, product)]
+ storage_inventory_shortage[(date, product)]
for date, product in storage_inventory_vars]
), 'Minimise stockpile shortfalls'
# Port stockpile target, max/min and shortage constraints
for date, product in storage_inventory_vars:
max_level = storage_stockpile_max[grade]
min_level = 0
target_level = storage_stockpile_target[grade]
model += storage_inventory_vars[(date, product)] <= max_level
# Storage Inventory Target Constraints
model += storage_inventory_target_overage[(date, product)] >= 0
model += storage_inventory_target_overage[(date, product)] - binary[(date, product)] * 100000000 <= 0
model += storage_inventory_target_shortage[(date, product)] >= 0
model += storage_inventory_target_shortage[(date, product)] - (1 - binary[(date, product)]) * 10000000 <= 0
model += storage_inventory_vars[(date, product)] >= target_level \
+ storage_inventory_target_overage[(date, product)] \
- storage_inventory_target_shortage[(date, product)]
# storage Inventory Shortages
model += storage_stockpile_shortage[(date, product)] >= 0
model += storage_inventory_vars[(date, product)] <= 0 == storage_stockpile_shortage[(date, product)]
# Sales Demand
# storage stockpile levels must meet sales demand
for date, product in storage_inventory_vars:
pulp.lpSum(storage_inventory_vars[date, product]) >= sales_demand[date][product]
All help greatly appreciated, thank you.