diff --git a/src/core/objective.jl b/src/core/objective.jl index 670f5a937..1a8aae010 100644 --- a/src/core/objective.jl +++ b/src/core/objective.jl @@ -220,8 +220,9 @@ function objective_min_pwl_fuel_cost(pm::GenericPowerModel) # pwl cost dcline_lines = get_lines(ref[:dcline]) for (i, dcline) in ref[:dcline] + arc = (i, dcline["f_bus"], dcline["t_bus"]) for line in dcline_lines[i] - @constraint(pm.model, dc_p_cost[n][i] >= line["slope"]*dc_p[n][i] + line["intercept"]) + @constraint(pm.model, dc_p_cost[n][i] >= line["slope"]*dc_p[n][arc] + line["intercept"]) end end diff --git a/src/io/matpower.jl b/src/io/matpower.jl index 69aee8812..871bc58ed 100644 --- a/src/io/matpower.jl +++ b/src/io/matpower.jl @@ -546,7 +546,7 @@ end "adds dcline costs, if gen costs exist" function add_dcline_costs(data::Dict{String,Any}) - if length(data["gencost"]) > 0 && length(data["dclinecost"]) <= 0 + if length(data["gencost"]) > 0 && length(data["dclinecost"]) <= 0 && length(data["dcline"]) > 0 warn(LOGGER, "added zero cost function data for dclines") model = data["gencost"][1]["model"] if model == 1 @@ -557,7 +557,7 @@ function add_dcline_costs(data::Dict{String,Any}) "startup" => 0.0, "shutdown" => 0.0, "ncost" => 2, - "cost" => [0.0, 0.0, 0.0, 0.0] + "cost" => [dcline["pminf"], 0.0, dcline["pmaxf"], 0.0] ) push!(data["dclinecost"], dclinecost) end diff --git a/test/data/matpower/case5_pwlc.m b/test/data/matpower/case5_pwlc.m index ba761c14b..ece6632b9 100755 --- a/test/data/matpower/case5_pwlc.m +++ b/test/data/matpower/case5_pwlc.m @@ -52,3 +52,6 @@ 4 10 0.00297 0.0297 0.00674 240.0 240.0 240.0 0.0 0.0 1 -30.0 30.0; ]; +mpc.dcline = [ + 1 10 1 10 10 25.91 -4.16 1.1 0.92617 10 900 -900 900 -900 900 0 0 0 0 0 0 0 0 +] \ No newline at end of file