-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement sclopf #710
Implement sclopf #710
Conversation
It is now included in etrago.optimize
Current status:
Currently, the iterative sclopf always uses pyomo. It would be nice to allow using linopy, but that might not be part of this PR. |
Otherwise e.g. heat pumps or EV demands are not included
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I installed eTraGo using this branch in a fresh virtual environment and when I try to run it (using eGon2035) I got this error message:
File ~/env/etrago_pr_710/lib/python3.10/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
exec(code, globals, locals)
File ~/git/eTraGo/etrago/appl.py:770
etrago = run_etrago(args, json_path=None)
File ~/git/eTraGo/etrago/appl.py:678 in run_etrago
etrago.build_network_from_db()
File ~/git/eTraGo/etrago/tools/network.py:377 in build_network_from_db
self.scenario = NetworkScenario(
File ~/git/eTraGo/etrago/tools/io.py:129 in init
self.configure_timeindex()
File ~/git/eTraGo/etrago/tools/io.py:159 in configure_timeindex
tr = saio.as_pandas(
File ~/env/etrago_pr_710/lib/python3.10/site-packages/saio.py:181 in as_pandas
df = pd.read_sql_query(query.statement, query.session.bind,
File ~/env/etrago_pr_710/lib/python3.10/site-packages/pandas/io/sql.py:526 in read_sql_query
return pandas_sql.read_query(
File ~/env/etrago_pr_710/lib/python3.10/site-packages/pandas/io/sql.py:2739 in read_query
cursor = self.execute(sql, params)
File ~/env/etrago_pr_710/lib/python3.10/site-packages/pandas/io/sql.py:2671 in execute
raise TypeError("Query must be a string unless using sqlalchemy.")
TypeError: Query must be a string unless using sqlalchemy.
Do you have any idea why could it happen?
etrago/appl.py
Outdated
@@ -51,7 +52,7 @@ | |||
"db": "egon-data", # database session | |||
"gridversion": None, # None for model_draft or Version number | |||
"method": { # Choose method and settings for optimization | |||
"type": "market_grid", # type of optimization, 'lopf' or 'market_grid' | |||
"type": "market_grid", # type of optimization, 'lopf', 'sclopf or 'market_grid' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the description of the "type" parameter in the docstrings
I have the same problem on dev when I create a new environment. So I guess this is not related to the changes on this branch. The reason might be a new package version or sth. like that. |
etrago/appl.py
Outdated
@@ -736,6 +737,9 @@ def run_etrago(args, json_path): | |||
# skip snapshots | |||
etrago.skip_snapshots() | |||
|
|||
# Temporary drop DLR as it is currently not working with sclopf | |||
etrago.network.lines_t.s_max_pu = pd.DataFrame(index=etrago.network.snapshots, columns=etrago.network.lines.index, data=1.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it is implemented, we will be dropping DLR also for LOPF or market_grid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is also needed for market_grid as that method also used the sclopf. But I can adjust it for the lopf
formulation=args["model_formulation"], | ||
pyomo=True, | ||
) | ||
path_name = "/sclopf_iteration_" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path_name is assigned but not used.
etrago/execute/__init__.py
Outdated
elif self.args["method"]["type"] == "sclopf": | ||
self.sclopf( | ||
post_lopf=False, | ||
extra_functionality=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function iterate_sclopf()
is failing due to an unexpected keyword. Error message:
File ~/env/etrago_710_fail-fix/lib/python3.10/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
exec(code, globals, locals)
File ~/git/eTraGo/etrago/appl.py:770
etrago = run_etrago(args, json_path=None)
File ~/git/eTraGo/etrago/appl.py:749 in run_etrago
etrago.optimize()
File ~/git/eTraGo/etrago/execute/__init__.py:422 in optimize
self.sclopf(
TypeError: iterate_sclopf() got an unexpected keyword argument 'extra_functionality'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that should be addressed before merging this branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch works using the default args. It can be merged to dev.
Solves #381
I created a new feature branch and did not used the old one because it was very outdated and also included several features that were already in dev.