From 9715c9d42b50053fa46be0316fce111ead959c88 Mon Sep 17 00:00:00 2001 From: Jonas Hoersch Date: Sun, 3 Feb 2019 15:44:40 +0100 Subject: [PATCH] fixup! solve_network: Extract line limit duals and radically refactor --- scripts/solve_network.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/solve_network.py b/scripts/solve_network.py index 18a6c40e..4df98c5c 100644 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -131,12 +131,12 @@ def solve_network(n, config=None, solver_log=None, opts=None): solver_name = solver_options.pop('name') def extra_postprocessing(n, snapshots, duals): - if hasattr(n, 'line_volume_limit'): + if hasattr(n, 'line_volume_limit') and hasattr(n.model, 'line_volume_constraint'): cdata = pd.Series(list(n.model.line_volume_constraint.values()), index=list(n.model.line_volume_constraint.keys())) n.line_volume_limit_dual = -cdata.map(duals).sum() - if hasattr(n, 'line_cost_limit'): + if hasattr(n, 'line_cost_limit') and hasattr(n.model, 'line_cost_constraint'): cdata = pd.Series(list(n.model.line_cost_constraint.values()), index=list(n.model.line_cost_constraint.keys())) n.line_cost_limit_dual = -cdata.map(duals).sum()