I am trying to run an electricity arbitrage model in Gekko. I have an electricity price array for every hour of a year (8760 total hours), a battery of energy size E, and for every hour I want to decide whether to charge the battery or discharge it, based on minimizing the electricity cost, and keep track of the energy in the battery constrained to hold no less than 0 energy and no more than E.
I've tried many times, most recently getting the error that the optimize equation exceeds the limits
from gekko import Gekko
m = Gekko()
#variables
E_battery = m.Var(lb=0, ub=366.2, value=0) #energy in battery at time t, battery size 366 MWh
Pc = m.Var(lb=0, ub=50) #charge power, 50 MW max
Pd = m.Var(lb=0, ub=36.6) #discharge power, max 36 MW
E_price = m.Param(electricity_price[:,1])
m.time = np.linspace(0,8759, 8760)
m.Equation(E_battery.dt() == (1-delta)*E_battery + roundtrip_eff*(Pc - Pd))
m.Obj(sum(E_price[i]*Pc for i in range(8760)))
m.options.IMODE = 7
m.solve()