Variable marginal_cost with pyomo

117 views
Skip to first unread message

Jessica Guichard

unread,
Nov 11, 2022, 10:18:14 AM11/11/22
to pypsa
Hi,

For my optimisation model, I was hoping to use a variable cost for energy coming from my store, that is a different price for every snapshot.

This works well when I use network.lopf(pyomo=False).

However, I need to use an extra_functionality which does not work without pyomo (Or else I don't know how), in which case I get an error message:

"The series.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead."

Is there any way to use variable marginal_cost and extra_functionality?

Thank you

Jessica Guichard


Fabian Neumann

unread,
Nov 13, 2022, 4:11:39 AM11/13/22
to pypsa
Hi Jessica,

these two options should not exclude each other.

Variable marginal cost for stores are implemented as series or static values:


Your extra_functionality is always written for a particular optimisation interface. If yours is written for pyomo, you need to rewrite it for `pyomo=False` or, since PyPSA v0.21, the linopy optimisation module



The particular error message you have, is just a warning, use

pd.concat([df1, df2])

instead of

df1.append(df2)

Best wishes,

Fabian N

Jessica Guichard

unread,
Nov 14, 2022, 11:33:53 AM11/14/22
to pypsa
Ok thanks, I managed to get it to work.

Jessica Guichard

unread,
Nov 15, 2022, 11:05:16 AM11/15/22
to pypsa
Actually I rejoiced too quickly. I've managed to write the equivalent code for extra_functionality for optimization without pyomo, and it runs fine for simulation with a low number of snapshots. But for a year of hourly snapshots, I cannot seem to get to the end of the simulation (takes forever) when using optimization without pyomo.

I'm using .csv files for the variable marginal costs of stores, which look like this:

snapshots,hydrogen,grid
0,50.74,51.52
1,50.74,51.95
2,50.74,65
3,50.74,51.97
4,50.74,41.92
5,50.74,38.97
6,50.74,37.69
7,50.74,37.38
...

Do I need to change the syntax so that I don't get the error message when using pyomo?

Jessica Guichard

unread,
Nov 22, 2022, 5:52:26 AM11/22/22
to pypsa
Solved my issue by installing gurobi. Glpk just could not seem to handle the large datasets I was requesting it to handle.
Reply all
Reply to author
Forward
0 new messages