Add support for the linopy io_api option

This commit is contained in:
Koen van Greevenbroek 2024-01-24 11:23:56 +01:00
parent 2bee36be87
commit 3e32dbccb5
4 changed files with 5 additions and 0 deletions

View File

@ -687,6 +687,7 @@ solving:
rolling_horizon: false rolling_horizon: false
seed: 123 seed: 123
custom_extra_functionality: "../data/custom_extra_functionality.py" custom_extra_functionality: "../data/custom_extra_functionality.py"
# io_api: "direct" # Increases performance but only supported for the highs and gurobi solvers
# options that go into the optimize function # options that go into the optimize function
track_iterations: false track_iterations: false
min_iterations: 4 min_iterations: 4

View File

@ -7,6 +7,7 @@ options,,,
-- rolling_horizon,bool,"{'true','false'}","Whether to optimize the network in a rolling horizon manner, where the snapshot range is split into slices of size `horizon` which are solved consecutively." -- rolling_horizon,bool,"{'true','false'}","Whether to optimize the network in a rolling horizon manner, where the snapshot range is split into slices of size `horizon` which are solved consecutively."
-- seed,--,int,Random seed for increased deterministic behaviour. -- seed,--,int,Random seed for increased deterministic behaviour.
-- custom_extra_functionality,--,str,Path to a Python file with custom extra functionality code to be injected into the solving rules of the workflow relative to ``rules`` directory. -- custom_extra_functionality,--,str,Path to a Python file with custom extra functionality code to be injected into the solving rules of the workflow relative to ``rules`` directory.
-- io_api,string,"{'lp','mps','direct'}",Passed to linopy and determines the API used to communicate with the solver. With the ``'lp'`` and ``'mps'`` options linopy passes a file to the solver; with the ``'direct'`` option (only supported for HIGHS and Gurobi) linopy uses an in-memory python API resulting in better performance.
-- track_iterations,bool,"{'true','false'}",Flag whether to store the intermediate branch capacities and objective function values are recorded for each iteration in ``network.lines['s_nom_opt_X']`` (where ``X`` labels the iteration) -- track_iterations,bool,"{'true','false'}",Flag whether to store the intermediate branch capacities and objective function values are recorded for each iteration in ``network.lines['s_nom_opt_X']`` (where ``X`` labels the iteration)
-- min_iterations,--,int,Minimum number of solving iterations in between which resistance and reactence (``x/r``) are updated for branches according to ``s_nom_opt`` of the previous run. -- min_iterations,--,int,Minimum number of solving iterations in between which resistance and reactence (``x/r``) are updated for branches according to ``s_nom_opt`` of the previous run.
-- max_iterations,--,int,Maximum number of solving iterations in between which resistance and reactence (``x/r``) are updated for branches according to ``s_nom_opt`` of the previous run. -- max_iterations,--,int,Maximum number of solving iterations in between which resistance and reactence (``x/r``) are updated for branches according to ``s_nom_opt`` of the previous run.

1 Unit Values Description
7 -- rolling_horizon bool {'true','false'} Whether to optimize the network in a rolling horizon manner, where the snapshot range is split into slices of size `horizon` which are solved consecutively.
8 -- seed -- int Random seed for increased deterministic behaviour.
9 -- custom_extra_functionality -- str Path to a Python file with custom extra functionality code to be injected into the solving rules of the workflow relative to ``rules`` directory.
10 -- io_api string {'lp','mps','direct'} Passed to linopy and determines the API used to communicate with the solver. With the ``'lp'`` and ``'mps'`` options linopy passes a file to the solver; with the ``'direct'`` option (only supported for HIGHS and Gurobi) linopy uses an in-memory python API resulting in better performance.
11 -- track_iterations bool {'true','false'} Flag whether to store the intermediate branch capacities and objective function values are recorded for each iteration in ``network.lines['s_nom_opt_X']`` (where ``X`` labels the iteration)
12 -- min_iterations -- int Minimum number of solving iterations in between which resistance and reactence (``x/r``) are updated for branches according to ``s_nom_opt`` of the previous run.
13 -- max_iterations -- int Maximum number of solving iterations in between which resistance and reactence (``x/r``) are updated for branches according to ``s_nom_opt`` of the previous run.

View File

@ -33,6 +33,8 @@ Upcoming Release
* Bugfix: Correctly read out number of solver threads from configuration file. * Bugfix: Correctly read out number of solver threads from configuration file.
* Add support for the linopy ``io_api`` option; set to ``"direct"`` to increase model reading and writing performance for the highs and gurobi solvers.
PyPSA-Eur 0.9.0 (5th January 2024) PyPSA-Eur 0.9.0 (5th January 2024)
================================== ==================================

View File

@ -890,6 +890,7 @@ def solve_network(n, config, solving, opts="", **kwargs):
"linearized_unit_commitment", False "linearized_unit_commitment", False
) )
kwargs["assign_all_duals"] = cf_solving.get("assign_all_duals", False) kwargs["assign_all_duals"] = cf_solving.get("assign_all_duals", False)
kwargs["io_api"] = cf_solving.get("io_api", None)
if kwargs["solver_name"] == "gurobi": if kwargs["solver_name"] == "gurobi":
logging.getLogger("gurobipy").setLevel(logging.CRITICAL) logging.getLogger("gurobipy").setLevel(logging.CRITICAL)