Is it possible to get more optimized result values from the solver?

Hi community,

i have a question to oemof/oemof-solph.

In the normal case, the flow values will be returned from oemof-solph.
But is it possible to get more detailed results (optimization values) from oemof-solph/the solver?

For example when i add a transformer with an input flow as nonconvex-type and add the nonconvex-attribute “startup_costs” or “activity_costs”.
So, is it possible to get e.g. the total startup costs for the optimization period or e.g. for every timestep (like the optimized flow values)?

Or is there a existing variable or class in oemof-solph that contains this raw optimization data and i can extract this informations from there?

Thanks a lot for your help.

You definitely should be able to get the results of any variable.

Could you provide a minimal(!) example to make it easier to help you.

Hi,

i used the “basic_example” in the oemof examples from github and added a nonconvex-flow to the storage input flow (line 150 in my attached example). In the nonconvex flow i set the “activity_costs” to a numeric list which is created by a function (line 143) with sinus operations to get a little flexible in the activity costs during every day in the model optimization horizon.

Suppose there are several such additional time variable values (e.g. startup_costs) at the different nonconvex-flows in the model.

How can i get these variable flow costs (which are different at every timestep in this example) from the optimization results (e.g. like the optimized flow value at every timestep)?

example_get_additional_flow_costs.zip (131.3 KB)

In that case you just have to multiply your activity_costs time series with the time series of the status variable and sum up the results.

The key of the flows is a tuple with (from node, to node). So if to node is storage you will get the flow that feeds the storage.

In the parameters dictionary nonconvex is an object. So it is one item and therefore treated as an scalar and not as a sequence even though it contains a sequence.

# add results to the energy system to make it possible to store them.
results = solph.processing.results(model)

inflow_results = [v for k, v in results.items() if k[1] == storage][0]

# Variant 1: Using the parameter dicitionary
parameter = solph.processing.parameter_as_dict(model)
inflow_parameter = [v for k, v in parameter.items() if k[1] == storage][0]
activity_costs = pd.Series(
    inflow_parameter["scalars"]["nonconvex"].activity_costs,
    index=inflow_results["sequences"].index,
)
print(inflow_results["sequences"].status.multiply(activity_costs).sum())

# Variant 2: Using the object from the model
inflow_object = [v for k, v in model.flows.items() if k[1] == storage][0]
activity_costs = pd.Series(
    inflow_object.nonconvex.activity_costs,
    index=inflow_results["sequences"].index,
)
print(inflow_results["sequences"].status.multiply(activity_costs).sum())
2 Likes