Background
I'm setting up a model to optimize dispatch of a solar + battery + electrolyser/fuel-cell system using PuLP. The idea is to maximize revenue by charging the Battery and producing Hydrogen from solar generation when prices are low, then discharging the Battery and burning Hydrogen when prices are high.
research & troubleshooting
I'm new to PuLP, I've spent a while working on this, using online guides and SO for assistance but my code is still returning rubbish answers. I've spent a while browsing SO searching for answers (here, here, here and here). and I think I know what the issue might be.
Potential Problem Identification
I think my main problem is that I have a bunch of logical constraints which I need to write in a different form to work in PuLP. I currently have no indicator variables or Big M constraints which I believe are useful way of writing conditional constraints. I tried to write them myself, but with no luck because I didn't know how to write them in PuLP (which I believe doesn't allow you to use IF or np.where, etc)
As for Big M constraints, I've had a go at writing them in what I believe to be an appropriate way, but it returns the error "Non-constant expressions cannot be multiplied".
Problem Example
I've attached sample of code below of what I am trying to achieve via a conditional constraint in PuLP.
In my system the Electroylyser has a minimal operational capacity (10%). Therefore its potential energy draw at time t needs to be something like;
if (SE[t] + BE[t]) < E_MinCons_kwh:
(SE[t] + BE[t]) == 0
elif (HZ_Size_nm3 - HSC[t]) < E_MinProd_nm3:
(SE[t] + BE[t]) == 0
else:
(SE[t] + BE[t]) <= e_kwh
(SE[t] + BE[t]) <= (HZ_Size_nm3 - HSC[t]) * nm3_to_kwh)
(SE[t] + BE[t]) >= E_MinCons_kwh
Where
SE[t] = electricity input from Solar powering the Electrolyser at time t
BE[t] = electricity input from Battery powering the Electrolyser at time t
E_MinCons_kwh = The minimal power draw of the Electrolyser (~18 kWh)
e_kwh = the maximum power draw of the Electrolyser (~180 KWh)
HZ_Size_nm3 = The size of the hydrogen Storage tank (~5,000 nm3)
HSC[t] = the current storage level of the hydrogen tank at time t (in nm3)
HSC[t+1] = HSC[t] + SH[t] + BH[t] - HF[t] - HM[t]
SH[t] = volume of Hydrogen produced from solar electricity at time t (in nm3)
BH[t] = volume of Hydrogen produced from Battery Discharge at time t (in nm3)
HF[t] = volume of Hydrogen consumed by the Fuel-Cell at time t (in nm3)
HM[t] = volume of Hydrogen sold to market at time t (in nm3)
E_MinProd_nm3 = Hydrogen produced when Electroylser operating at min capacity (~3.6 nm3)
nm3_to_kwh = Conversion factor, kwh required to produce 1 nm3 of hydrogen (~5.4 kwh)
Requested Assistance
Does anyone know How I can write the above logical argument, in a method which can be used in PuLP constraints?