I am trying to optimize a "microgrid" with regards to cost, the model will take a fixed demand, a flexible demand, spot price for electricity, along with fixed production data for a solar power system. Additionally power can be stored in a battery to be discharged during optimal times, as well as charged. The time period is 48 hours.
I have most of this defined and working, but I am struggling with getting the battery to work, I have tried different ways of defining it, but i am getting keyerrors due to my indexing:
Here I have tried to define the battery as a constraint, the charge and discharge models seem to work, they both have values for the 48 time-steps in model t. I have also tried to define it using the same formula, except using batterylevel[t] = everything else of [t-1]. Sadly none of this works. How can I implement this? Any help would be greatly appreciated!
Please sign in to leave a comment.