solve_network: enable rolling horizon
This commit is contained in:
parent
4bb0716414
commit
723350c8ef
@ -630,15 +630,18 @@ solving:
|
|||||||
#tmpdir: "path/to/tmp"
|
#tmpdir: "path/to/tmp"
|
||||||
options:
|
options:
|
||||||
clip_p_max_pu: 1.e-2
|
clip_p_max_pu: 1.e-2
|
||||||
linearized_unit_commitment: true
|
|
||||||
load_shedding: false
|
load_shedding: false
|
||||||
transmission_losses: 0
|
|
||||||
noisy_costs: true
|
noisy_costs: true
|
||||||
skip_iterations: true
|
skip_iterations: true
|
||||||
|
rolling_horizon: false
|
||||||
|
seed: 123
|
||||||
|
# options that go into the optimize function
|
||||||
track_iterations: false
|
track_iterations: false
|
||||||
min_iterations: 4
|
min_iterations: 4
|
||||||
max_iterations: 6
|
max_iterations: 6
|
||||||
seed: 123
|
transmission_losses: 0
|
||||||
|
linearized_unit_commitment: true
|
||||||
|
horizon: 365
|
||||||
|
|
||||||
solver:
|
solver:
|
||||||
name: gurobi
|
name: gurobi
|
||||||
@ -666,7 +669,6 @@ solving:
|
|||||||
AggFill: 0
|
AggFill: 0
|
||||||
PreDual: 0
|
PreDual: 0
|
||||||
GURO_PAR_BARDENSETHRESH: 200
|
GURO_PAR_BARDENSETHRESH: 200
|
||||||
seed: 10 # Consistent seed for all plattforms
|
|
||||||
gurobi-numeric-focus:
|
gurobi-numeric-focus:
|
||||||
name: gurobi
|
name: gurobi
|
||||||
NumericFocus: 3 # Favour numeric stability over speed
|
NumericFocus: 3 # Favour numeric stability over speed
|
||||||
|
@ -70,7 +70,7 @@ renewable:
|
|||||||
cutout: europe-2019-era5
|
cutout: europe-2019-era5
|
||||||
|
|
||||||
conventional:
|
conventional:
|
||||||
unit_commitment: true
|
unit_commitment: false
|
||||||
dynamic_fuel_price: true
|
dynamic_fuel_price: true
|
||||||
nuclear:
|
nuclear:
|
||||||
p_max_pu: "data/nuclear_p_max_pu.csv" # float of file name
|
p_max_pu: "data/nuclear_p_max_pu.csv" # float of file name
|
||||||
@ -88,3 +88,5 @@ solving:
|
|||||||
#tmpdir: "path/to/tmp"
|
#tmpdir: "path/to/tmp"
|
||||||
options:
|
options:
|
||||||
load_shedding: true
|
load_shedding: true
|
||||||
|
rolling_horizon: true
|
||||||
|
horizon: 365
|
||||||
|
@ -7,11 +7,14 @@ run:
|
|||||||
|
|
||||||
scenario:
|
scenario:
|
||||||
clusters: # number of nodes in Europe, any integer between 37 (1 node per country-zone) and several hundred
|
clusters: # number of nodes in Europe, any integer between 37 (1 node per country-zone) and several hundred
|
||||||
- 37
|
- 37c
|
||||||
opts: # only relevant for PyPSA-Eur
|
opts: # only relevant for PyPSA-Eur
|
||||||
- 'Ept'
|
- 'Ept'
|
||||||
|
|
||||||
snapshots:
|
snapshots:
|
||||||
start: "2019-04-01"
|
start: "2019-01-01"
|
||||||
end: "2019-04-10"
|
end: "2019-02-01"
|
||||||
inclusive: 'left' # include start, not end
|
inclusive: 'left' # include start, not end
|
||||||
|
|
||||||
|
conventional:
|
||||||
|
unit_commitment: false
|
||||||
|
@ -598,47 +598,43 @@ def extra_functionality(n, snapshots):
|
|||||||
|
|
||||||
def solve_network(n, config, solving, opts="", **kwargs):
|
def solve_network(n, config, solving, opts="", **kwargs):
|
||||||
set_of_options = solving["solver"]["options"]
|
set_of_options = solving["solver"]["options"]
|
||||||
solver_options = solving["solver_options"][set_of_options] if set_of_options else {}
|
|
||||||
solver_name = solving["solver"]["name"]
|
|
||||||
cf_solving = solving["options"]
|
cf_solving = solving["options"]
|
||||||
track_iterations = cf_solving.get("track_iterations", False)
|
kwargs["solver_options"] = (
|
||||||
min_iterations = cf_solving.get("min_iterations", 4)
|
solving["solver_options"][set_of_options] if set_of_options else {}
|
||||||
max_iterations = cf_solving.get("max_iterations", 6)
|
)
|
||||||
transmission_losses = cf_solving.get("transmission_losses", 0)
|
kwargs["solver_name"] = solving["solver"]["name"]
|
||||||
linearized_unit_commitment = cf_solving.get("linearized_unit_commitment", False)
|
kwargs["extra_functionality"] = extra_functionality
|
||||||
|
kwargs["transmission_losses"] = cf_solving.get("transmission_losses", False)
|
||||||
|
kwargs["linearized_unit_commitment"] = cf_solving.get(
|
||||||
|
"linearized_unit_commitment", False
|
||||||
|
)
|
||||||
|
|
||||||
|
rolling_horizon = cf_solving.pop("rolling_horizon", False)
|
||||||
|
skip_iterations = cf_solving.pop("skip_iterations", False)
|
||||||
|
if not n.lines.s_nom_extendable.any():
|
||||||
|
skip_iterations = True
|
||||||
|
logger.info("No expandable lines found. Skipping iterative solving.")
|
||||||
|
|
||||||
# add to network for extra_functionality
|
# add to network for extra_functionality
|
||||||
n.config = config
|
n.config = config
|
||||||
n.opts = opts
|
n.opts = opts
|
||||||
|
|
||||||
skip_iterations = cf_solving.get("skip_iterations", False)
|
if rolling_horizon:
|
||||||
if not n.lines.s_nom_extendable.any():
|
kwargs["horizon"] = cf_solving.get("horizon", 365)
|
||||||
skip_iterations = True
|
kwargs["overlap"] = cf_solving.get("overlap", 0)
|
||||||
logger.info("No expandable lines found. Skipping iterative solving.")
|
n.optimize.optimize_with_rolling_horizon(**kwargs)
|
||||||
|
status, condition = "", ""
|
||||||
if skip_iterations:
|
elif skip_iterations:
|
||||||
status, condition = n.optimize(
|
status, condition = n.optimize(**kwargs)
|
||||||
solver_name=solver_name,
|
|
||||||
transmission_losses=transmission_losses,
|
|
||||||
extra_functionality=extra_functionality,
|
|
||||||
linearized_unit_commitment=linearized_unit_commitment,
|
|
||||||
**solver_options,
|
|
||||||
**kwargs,
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
|
kwargs["track_iterations"] = (cf_solving.get("track_iterations", False),)
|
||||||
|
kwargs["min_iterations"] = (cf_solving.get("min_iterations", 4),)
|
||||||
|
kwargs["max_iterations"] = (cf_solving.get("max_iterations", 6),)
|
||||||
status, condition = n.optimize.optimize_transmission_expansion_iteratively(
|
status, condition = n.optimize.optimize_transmission_expansion_iteratively(
|
||||||
solver_name=solver_name,
|
**kwargs
|
||||||
track_iterations=track_iterations,
|
|
||||||
min_iterations=min_iterations,
|
|
||||||
max_iterations=max_iterations,
|
|
||||||
linearized_unit_commitment=linearized_unit_commitment,
|
|
||||||
transmission_losses=transmission_losses,
|
|
||||||
extra_functionality=extra_functionality,
|
|
||||||
**solver_options,
|
|
||||||
**kwargs,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if status != "ok":
|
if status != "ok" and not rolling_horizon:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"Solving status '{status}' with termination condition '{condition}'"
|
f"Solving status '{status}' with termination condition '{condition}'"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user