Oh, Six Seven!

This week, we had two rather spontaneous releases. After we found out, the way we implemented a consistency measure we introduced with oemof.solph 0.6.5 lead to memory leaks, I wanted to release the fix very quick. This lead to a premature release and the demand to have a second quick fix. So, after telling you about the new version 0.6.7 (GitHub, Zenodo, PyPI, RTD), I will also give a post mortem analysis.

oemof.solph v0.6.7 highlights

New features

  • It is now possible to pip install oemof.solph[solver], which will also install ready to use solvers.
  • VariableSplitConverter: A converter with one input and two competing outputs, where the split between the outputs can vary linearly between two given, real operating points (e.g. an extraction/backpressure turbine, where the split between electricity and heat varies with the amount of heat extracted).
  • Added a solver attribute to the Results class to get the return values of the solver in a structured way.
  • Added dual-variables and reduced cost to the Results class.
  • Model.solve(allow_nonoptimal=True) will now return a Results object. (It of course will not contain real results but solver infos.)

Fixes

  • Gradient limits of NonConvex flows were not working.
  • With minimum_uptime, a start-up in the last minimum_uptime - 1 time steps was impossible.
  • Fixed a memory leak that occurred when one script instantiated multiple energy EnergySystem instances. (More about that later.)
  • Variable costs returned wrong values if the variable cost of the flow was a constant.
  • A GenericStorage with investment ignored min_storage_level if it was non-zero only at the last time point.
  • Multiplication of constant time series (e.g. flow.variable_costs when initialised in the form Flow(variable_costs=5)) with pd.Series did not work correctly.

Post mortem

In solph 0.5.6, we introduced a new way of casting scalar values to series, when needed. Before, you could e.g. state flow = Flow(variable_costs=5), wich resulted in flow.variable_costs == [5, 5, ..., 5] but assigning scalar values later was not possible. Instead, you had to manually give the correct length. The standard way to handle this is the following:

class Flow:
    def __init__(self, variable_costs):
        self.variable_costs = variable_costs

    @property
    def variable_costs(self):
        return self._variable_costs

    @variable_costs.setter
    def variable_costs(self, value):
        self._variable_costs = sequence(value)

We, however, did not like all the repetitive code for every sequence we have, thus we introduced a class-level descriptor in the form:

class Flow:
    variable_costs = Apply(sequence)

    def __init__(self, variable_costs):
        self.variable_costs = variable_costs

Unfortunately, we decided to not add the converted data (the data sequence was applied to) to the instance of the object that uses Apply. Instead, we collected it within the Apply instance. As its lifetime, however, is tied to the lifetime of the class, we created a memory leak. (I now replaced Apply although it was fixed as it is proven to be hard to maintain. Such problems should not slip through.)

This problem was big, I know some people who downgraded their solph installations to still be able to have one script iterating over thousands of EnergySystems. Thus, we did not check implications of another change before the release: We thought it was a good idea to keep pd.Series unchanged when they are assigned to a time series (sequence). However, some part of our code uses integer indexing, so it may fail or (worse) produce wrong results when pd.Series are used.

Leave a Reply

Your email address will not be published. Required fields are marked *