Skip to content

Commit 5b0e4c9

Browse files
claytonpbarrowsccoffrin
authored andcommitted
fixing dcline for v0.7 (#378)
1 parent 4550559 commit 5b0e4c9

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/core/objective.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,9 @@ function objective_min_pwl_fuel_cost(pm::GenericPowerModel)
220220
# pwl cost
221221
dcline_lines = get_lines(ref[:dcline])
222222
for (i, dcline) in ref[:dcline]
223+
arc = (i, dcline["f_bus"], dcline["t_bus"])
223224
for line in dcline_lines[i]
224-
@constraint(pm.model, dc_p_cost[n][i] >= line["slope"]*dc_p[n][i] + line["intercept"])
225+
@constraint(pm.model, dc_p_cost[n][i] >= line["slope"]*dc_p[n][arc] + line["intercept"])
225226
end
226227
end
227228

src/io/matpower.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ end
546546

547547
"adds dcline costs, if gen costs exist"
548548
function add_dcline_costs(data::Dict{String,Any})
549-
if length(data["gencost"]) > 0 && length(data["dclinecost"]) <= 0
549+
if length(data["gencost"]) > 0 && length(data["dclinecost"]) <= 0 && length(data["dcline"]) > 0
550550
warn(LOGGER, "added zero cost function data for dclines")
551551
model = data["gencost"][1]["model"]
552552
if model == 1
@@ -557,7 +557,7 @@ function add_dcline_costs(data::Dict{String,Any})
557557
"startup" => 0.0,
558558
"shutdown" => 0.0,
559559
"ncost" => 2,
560-
"cost" => [0.0, 0.0, 0.0, 0.0]
560+
"cost" => [dcline["pminf"], 0.0, dcline["pmaxf"], 0.0]
561561
)
562562
push!(data["dclinecost"], dclinecost)
563563
end

test/data/matpower/case5_pwlc.m

+3
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@
5252
4 10 0.00297 0.0297 0.00674 240.0 240.0 240.0 0.0 0.0 1 -30.0 30.0;
5353
];
5454

55+
mpc.dcline = [
56+
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
57+
]

0 commit comments

Comments
 (0)