def _iter_over_int_viol_set(int_viol_set, mb, PTDF, abs_ptdf_tol, rel_ptdf_tol): for i in int_viol_set: i_n = PTDF.interface_keys[i] if mb.pfi[i_n].expr is None: expr = libbranch.get_power_flow_interface_expr_ptdf( mb, i_n, PTDF, abs_ptdf_tol=abs_ptdf_tol, rel_ptdf_tol=rel_ptdf_tol) mb.pfi[i_n] = expr yield i, i_n
def add_initial_monitored_interfaces(mb, interfaces, ptdf_options, PTDF): ## static information between runs rel_ptdf_tol = ptdf_options['rel_ptdf_tol'] abs_ptdf_tol = ptdf_options['abs_ptdf_tol'] constr = mb.ineq_pf_interface_bounds int_viol_in_mb = mb._interfaces_monitored for i, i_n in _iter_over_initial_set_interfaces(interfaces, PTDF): minimum_limit = PTDF.interface_min_limits[i] maximum_limit = PTDF.interface_max_limits[i] mb.pfi[i_n] = libbranch.get_power_flow_interface_expr_ptdf( mb, i_n, PTDF, abs_ptdf_tol=abs_ptdf_tol, rel_ptdf_tol=rel_ptdf_tol) constr[i_n] = (minimum_limit, mb.pfi[i_n], maximum_limit) int_viol_in_mb.append(i)
def add_initial_monitored_interfaces(mb, interfaces, ptdf_options, PTDF): ## static information between runs rel_ptdf_tol = ptdf_options['rel_ptdf_tol'] abs_ptdf_tol = ptdf_options['abs_ptdf_tol'] constr = mb.ineq_pf_interface_bounds int_viol_in_mb = mb._interfaces_monitored pos_slacks = hasattr(mb, 'pfi_slack_pos') neg_slacks = hasattr(mb, 'pfi_slack_neg') for i, i_n in _iter_over_initial_set_interfaces(interfaces, PTDF): minimum_limit = PTDF.interface_min_limits[i] maximum_limit = PTDF.interface_max_limits[i] mb.pfi[i_n] = libbranch.get_power_flow_interface_expr_ptdf( mb, i_n, PTDF, abs_ptdf_tol=abs_ptdf_tol, rel_ptdf_tol=rel_ptdf_tol) constr[i_n] = _generate_interface_bounds(mb, i_n, minimum_limit, maximum_limit, neg_slacks, pos_slacks) int_viol_in_mb.append(i)