@@ -482,7 +482,12 @@ function objective_variable_pg_cost(pm::AbstractPowerModel, report::Bool=true)
482482 pg_cost = var (pm, n)[:pg_cost ] = Dict {Int,Any} ()
483483
484484 for (i,gen) in ref (pm, n, :gen )
485- points = calc_pwl_points (gen[" ncost" ], gen[" cost" ], gen[" pmin" ], gen[" pmax" ])
485+ pg_vars = [var (pm, n, :pg , i)[c] for c in conductor_ids (pm, n)]
486+ pmin = sum (JuMP. lower_bound .(pg_vars))
487+ pmax = sum (JuMP. upper_bound .(pg_vars))
488+
489+ # note pmin/pmax may be different from gen["pmin"]/gen["pmax"] in the on/off case
490+ points = calc_pwl_points (gen[" ncost" ], gen[" cost" ], pmin, pmax)
486491
487492 pg_cost_lambda = JuMP. @variable (pm. model,
488493 [i in 1 : length (points)], base_name= " $(n) _pg_cost_lambda" ,
@@ -497,7 +502,7 @@ function objective_variable_pg_cost(pm::AbstractPowerModel, report::Bool=true)
497502 pg_expr += point. mw* pg_cost_lambda[i]
498503 pg_cost_expr += point. cost* pg_cost_lambda[i]
499504 end
500- JuMP. @constraint (pm. model, pg_expr == sum (var (pm, n, :pg , i)[c] for c in conductor_ids (pm, n) ))
505+ JuMP. @constraint (pm. model, pg_expr == sum (pg_vars ))
501506 pg_cost[i] = pg_cost_expr
502507 end
503508
@@ -512,7 +517,13 @@ function objective_variable_dc_cost(pm::AbstractPowerModel, report::Bool=true)
512517 p_dc_cost = var (pm, n)[:p_dc_cost ] = Dict {Int,Any} ()
513518
514519 for (i,dcline) in ref (pm, n, :dcline )
515- points = calc_pwl_points (dcline[" ncost" ], dcline[" cost" ], dcline[" pminf" ], dcline[" pmaxf" ])
520+ arc = (i, dcline[" f_bus" ], dcline[" t_bus" ])
521+ p_dc_vars = [var (pm, n, :p_dc )[arc][c] for c in conductor_ids (pm, n)]
522+ pmin = sum (JuMP. lower_bound .(p_dc_vars))
523+ pmax = sum (JuMP. upper_bound .(p_dc_vars))
524+
525+ # note pmin/pmax may be different from dcline["pminf"]/dcline["pmaxf"] in the on/off case
526+ points = calc_pwl_points (dcline[" ncost" ], dcline[" cost" ], pmin, pmax)
516527
517528 dc_p_cost_lambda = JuMP. @variable (pm. model,
518529 [i in 1 : length (points)], base_name= " $(n) _dc_p_cost_lambda" ,
@@ -528,8 +539,7 @@ function objective_variable_dc_cost(pm::AbstractPowerModel, report::Bool=true)
528539 dc_p_cost_expr += point. cost* dc_p_cost_lambda[i]
529540 end
530541
531- arc = (i, dcline[" f_bus" ], dcline[" t_bus" ])
532- JuMP. @constraint (pm. model, dc_p_expr == sum (var (pm, n, :p_dc )[arc][c] for c in conductor_ids (pm, n)))
542+ JuMP. @constraint (pm. model, dc_p_expr == sum (p_dc_vars))
533543 p_dc_cost[i] = dc_p_cost_expr
534544 end
535545
0 commit comments