oemof / oemof-solph

A model generator for energy system modelling and optimisation (LP/MILP).
https://oemof.org
MIT License
297 stars 125 forks source link

N+1 timesteps regarded in storage_costs for GenericStorage #1091

Closed bdietermann closed 1 month ago

bdietermann commented 2 months ago

I’m currently trying to use the parameter storage_costs for a GenericStorage. In order to figure out the unit of this parameter, I specified a source and a storage, with storage_costs = -1. These are the only costs present within in the system. The storage is initialized with a SOC of 98% and is charged to 100% by the optimizer in the first timestep and afterwards is kept on 100% for the whole simulation duration. I then checked the costs computed by pyomo: This reveals, that all SOCs “after” the simulation timesteps (so resulting from the power computed of the optimizer) are taken into account for the target function, which in my opinion is the desired behavior. But also the intial energy content is added. So the calculation is based on n + 1 timesteps with n being the number of timesteps in the simulation. For a storage with nominal_storage_capacity=1, storage_costs=-1, and a constant SOC=100% this results in costs of -3 for a simulation duration of 2 timesteps. As storages are usually defined as balanced storages, the inital SOC has twice the weight compared to all other timesteps. Furthermore, the inital SOC is typically predefined, so taking it into account also doesn't make sense to me for non-balanced storages.

Therefore, I would suggest to neglect the initial storage in the cost function for optimization.

p-snft commented 1 month ago

For the moment, you can workaround the issue by giving costs per time point, e.g. storage_costs[0] + 2*[-1].

Some considerations:

  1. For optimisation using an assumed cyclic time, it does not make sense to consider both, the 0th and N+1st time point. This can be seen in particular as the storage is typically balanced, so it is really one value that gains twice the weight.
  2. If time is assumed linear (no balanced storage), there are N+1 points in time for N time steps. Thus, the implementation makes sense to me. However, typically the initial content is predefined, so it just gives an offset to the objective value.

Thus, as a first approach to solve this here, I'd suggest to drop the costs for the 0th time step.

p-snft commented 1 month ago

Fixed in (alpha) release v0.6.0a1.