Skip to content

Some variable bounds are set multiple times #125

@odow

Description

@odow

I'm looking at making these variable bounds lazy:

function branch_rate_bounds!(
container::OptimizationContainer,
::DeviceModel{B, T},
network_model::NetworkModel{<:AbstractPowerModel},
) where {B <: PSY.ACTransmission, T <: AbstractBranchFormulation}
time_steps = get_time_steps(container)
net_reduction_data = get_network_reduction(network_model)
all_branch_maps_by_type = net_reduction_data.all_branch_maps_by_type
for var in _get_flow_variable_vector(container, network_model, B)
for (name, (arc, reduction)) in PNM.get_name_to_arc_map(net_reduction_data, B)
# TODO: entry is not type stable here, it can return any type ACTransmission.
# It might have performance implications. Possibly separate this into other functions
reduction_entry = all_branch_maps_by_type[reduction][B][arc]
# Use the same limit values as FlowRateConstraint for consistency.
limits = get_min_max_limits(reduction_entry, FlowRateConstraint, T)
for t in time_steps
@assert limits.min <= limits.max "Infeasible rate limits for branch $(name)"
JuMP.set_upper_bound(var[name, t], limits.max)
JuMP.set_lower_bound(var[name, t], limits.min)
end
end
end
return
end

and I ran into an issue: this function loops over multiple occurrences of the same var[name, t].

Is this expected (and just a minor performance issue to be re-setting existing bounds)? Or is it a bug somewhere?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions