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 (thanks in part to OR!) however I would like to create a variable that shows the extent of a supply shortfall. Currently if the current inventory is 0, and demand is > 0, then the model is unable to satisfy the constraints and returns 'Infeasible'.
I would like to define a slack/soft constraint that captures the shortfall so that the end result is always 'optimal' even though a shortfall is realised, and shows this extent.
Unfortunately my current soft constraint is not recognised by the model and the output is still 'infeasible'
Desired outcome:
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
# Sales Demand
# Storage levels must meet sales demand
for date, grade in storage_inventory_vars:
model += storage_inventory_vars[date, product] \
+ insufficient_storage_supply[(date, product)] \
>= sales_demand[date][product]
The variable insufficient_supply[(date, product)]
is the key slack constraint here that I would like to measure as it should prevent an infeasible solution (owing to insufficient supply to meet demand).
You can observe in the sales demand data on the 2020-05-18 and 19 that there is a very large spike in demand for AFE so that it greatly exceeds supply.
Here, if storage_inventory_vars['2020-05-18, 'AFE']
== 50,000 then insufficient_supply[('2020-05-18, 'AFE')]
should == -50,000. The sum should then produce an optimal solution is the sum is greater than the demand.
All help very gratefully received, thank you.