From 0c9d6d7ae73f6bc9201316e3d3ab3febfdedaa23 Mon Sep 17 00:00:00 2001 From: jjospina Date: Thu, 12 Sep 2024 09:21:05 -0600 Subject: [PATCH] WIP: upgrade to JuMP 1.15 --- Project.toml | 6 +- src/PowerModelsITD.jl | 1 - src/core/objective.jl | 62 ++++++++++---------- src/core/objective_dmld.jl | 10 ++-- src/core/objective_dmld_simple.jl | 10 ++-- src/core/objective_helpers.jl | 8 +-- src/core/objective_storage.jl | 60 +++++++++---------- src/form/acp.jl | 94 ++++++++++-------------------- src/form/acr.jl | 12 ++-- src/form/fbs.jl | 8 +-- src/form/fotp.jl | 8 +-- src/form/fotr.jl | 8 +-- src/form/ivr.jl | 16 ++--- src/form/lindist3flow.jl | 4 +- src/form/linear.jl | 2 +- src/form_decomposition/acp.jl | 78 +++++++------------------ src/form_decomposition/acr.jl | 4 +- src/form_decomposition/boundary.jl | 4 +- src/form_decomposition/fbs.jl | 4 +- src/form_decomposition/fotr.jl | 4 +- src/form_decomposition/ivr.jl | 8 +-- 21 files changed, 171 insertions(+), 240 deletions(-) diff --git a/Project.toml b/Project.toml index be606db..21e1249 100755 --- a/Project.toml +++ b/Project.toml @@ -18,10 +18,10 @@ StsDOpt = "6b7f5ccb-1a75-42de-b5f3-d93534753244" InfrastructureModels = "0.7.8" Ipopt = "0.9, 1.0.2" JSON = "~0.18, ~0.19, ~0.20, ~0.21" -JuMP = "~0.22, ~0.23, 1" +JuMP = "1.15" LinearAlgebra = "1.6" -PowerModels = "0.20" -PowerModelsDistribution = "0.15.2" +PowerModels = "0.21" +PowerModelsDistribution = "0.16.0" SCS = "~1.0, ~1.1" julia = "1.6" StsDOpt = "0.1.6" diff --git a/src/PowerModelsITD.jl b/src/PowerModelsITD.jl index 89c374e..1db5ada 100755 --- a/src/PowerModelsITD.jl +++ b/src/PowerModelsITD.jl @@ -13,7 +13,6 @@ module PowerModelsITD # Borrow dependencies from other packages import InfrastructureModels: optimize_model!, @im_fields, nw_id_default - import PowerModelsDistribution: @smart_constraint, _has_nl_expression # Import necessary (additional) packages/functions import LinearAlgebra diff --git a/src/core/objective.jl b/src/core/objective.jl index 79661fb..9c30503 100644 --- a/src/core/objective.jl +++ b/src/core/objective.jl @@ -131,7 +131,7 @@ function objective_mc_variable_pg_cost(pm::_PMD.AbstractUnbalancedIVRModel; repo pg_cost_expr += point.cost*pg_cost_lambda[i] end # Important: This constraint had to be changed to a Non-linear constraint - JuMP.@NLconstraint(pm.model, pg_expr == sum(_PMD.var(pm, n, :pg, i)[c] for c in gen["connections"])) + JuMP.@constraint(pm.model, pg_expr == sum(_PMD.var(pm, n, :pg, i)[c] for c in gen["connections"])) pg_cost[i] = pg_cost_expr end report && _IM.sol_component_value(pm, _PMD.pmd_it_sym, n, :gen, :pg_cost, _PMD.ids(pm, n, :gen), pg_cost) @@ -251,14 +251,14 @@ function _objective_itd_min_fuel_cost_polynomial_linquad(pmitd::AbstractIVRPower for (i,gen) in nw_ref[:gen] bus = gen["gen_bus"] - #to avoid function calls inside of @NLconstraint: + #to avoid function calls inside of @constraint: pg = _PM.var(pm, n, :pg, i) if length(gen["cost"]) == 1 pm_gen_cost[(n,i)] = gen["cost"][1] elseif length(gen["cost"]) == 2 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pm.model, gen["cost"][1]*pg + gen["cost"][2]) + pm_gen_cost[(n,i)] = JuMP.@expression(pm.model, gen["cost"][1]*pg + gen["cost"][2]) elseif length(gen["cost"]) == 3 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pm.model, gen["cost"][1]*pg^2 + gen["cost"][2]*pg + gen["cost"][3]) + pm_gen_cost[(n,i)] = JuMP.@expression(pm.model, gen["cost"][1]*pg^2 + gen["cost"][2]*pg + gen["cost"][3]) else pm_gen_cost[(n,i)] = 0.0 end @@ -272,14 +272,14 @@ function _objective_itd_min_fuel_cost_polynomial_linquad(pmitd::AbstractIVRPower for (i,gen) in nw_ref[:gen] bus = gen["gen_bus"] - #to avoid function calls inside of @NLconstraint: + #to avoid function calls inside of @constraint: pg = _PMD.var(pmd, n, :pg, i) if length(gen["cost"]) == 1 pmd_gen_cost[(n,i)] = gen["cost"][1] elseif length(gen["cost"]) == 2 - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmd.model, gen["cost"][1]*sum(pg[c] for c in gen["connections"]) + gen["cost"][2]) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmd.model, gen["cost"][1]*sum(pg[c] for c in gen["connections"]) + gen["cost"][2]) elseif length(gen["cost"]) == 3 - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmd.model, gen["cost"][1]*sum(pg[c] for c in gen["connections"])^2 + gen["cost"][2]*sum(pg[c] for c in gen["connections"]) + gen["cost"][3]) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmd.model, gen["cost"][1]*sum(pg[c] for c in gen["connections"])^2 + gen["cost"][2]*sum(pg[c] for c in gen["connections"]) + gen["cost"][3]) else pmd_gen_cost[(n,i)] = 0.0 end @@ -288,7 +288,7 @@ function _objective_itd_min_fuel_cost_polynomial_linquad(pmitd::AbstractIVRPower # ITD (Combined objective) - return JuMP.@NLobjective(pmitd.model, Min, + return JuMP.@objective(pmitd.model, Min, sum( sum( pm_gen_cost[(n,i)] for (i,gen) in nw_ref[:gen] ) for (n, nw_ref) in _PM.nws(pm)) @@ -317,20 +317,20 @@ function _objective_itd_min_fuel_cost_polynomial_nl(pmitd::AbstractIVRPowerModel for (i,gen) in nw_ref[:gen] bus = gen["gen_bus"] - #to avoid function calls inside of @NLconstraint: + #to avoid function calls inside of @constraint: pg = _PM.var(pm, n, :pg, i) cost_rev = reverse(gen["cost"]) if length(cost_rev) == 1 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1]) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1]) elseif length(cost_rev) == 2 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg) elseif length(cost_rev) == 3 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2) elseif length(cost_rev) >= 4 cost_rev_nl = cost_rev[4:end] - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2 + sum( v*pg^(d+2) for (d,v) in enumerate(cost_rev_nl)) ) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2 + sum( v*pg^(d+2) for (d,v) in enumerate(cost_rev_nl)) ) else - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, 0.0) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, 0.0) end end end @@ -345,22 +345,22 @@ function _objective_itd_min_fuel_cost_polynomial_nl(pmitd::AbstractIVRPowerModel cost_rev = reverse(gen["cost"]) if length(cost_rev) == 1 - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1]) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1]) elseif length(cost_rev) == 2 - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*sum(pg[c] for c in gen["connections"])) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*sum(pg[c] for c in gen["connections"])) elseif length(cost_rev) == 3 - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*sum(pg[c] for c in gen["connections"]) + cost_rev[3]*sum(pg[c] for c in gen["connections"])^2) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*sum(pg[c] for c in gen["connections"]) + cost_rev[3]*sum(pg[c] for c in gen["connections"])^2) elseif length(cost_rev) >= 4 cost_rev_nl = cost_rev[4:end] - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*sum(pg[c] for c in gen["connections"]) + cost_rev[3]*sum(pg[c] for c in gen["connections"])^2 + sum( v*sum(pg[c] for c in gen["connections"])^(d+2) for (d,v) in enumerate(cost_rev_nl)) ) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*sum(pg[c] for c in gen["connections"]) + cost_rev[3]*sum(pg[c] for c in gen["connections"])^2 + sum( v*sum(pg[c] for c in gen["connections"])^(d+2) for (d,v) in enumerate(cost_rev_nl)) ) else - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, 0.0) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, 0.0) end end end # ITD (Combined objective) - return JuMP.@NLobjective(pmitd.model, Min, + return JuMP.@objective(pmitd.model, Min, sum( sum( pm_gen_cost[(n,i)] for (i,gen) in nw_ref[:gen] ) for (n, nw_ref) in _PM.nws(pm)) @@ -391,16 +391,16 @@ function _objective_itd_min_fuel_cost_polynomial_nl(pmitd::AbstractPowerModelITD cost_rev = reverse(gen["cost"]) if length(cost_rev) == 1 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1]) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1]) elseif length(cost_rev) == 2 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg) elseif length(cost_rev) == 3 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2) elseif length(cost_rev) >= 4 cost_rev_nl = cost_rev[4:end] - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2 + sum( v*pg^(d+2) for (d,v) in enumerate(cost_rev_nl)) ) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2 + sum( v*pg^(d+2) for (d,v) in enumerate(cost_rev_nl)) ) else - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, 0.0) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, 0.0) end end end @@ -419,22 +419,22 @@ function _objective_itd_min_fuel_cost_polynomial_nl(pmitd::AbstractPowerModelITD JuMP.@constraint(pmitd.model, pg_aux == pg) if length(cost_rev) == 1 - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1]) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1]) elseif length(cost_rev) == 2 - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg_aux) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg_aux) elseif length(cost_rev) == 3 - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg_aux + cost_rev[3]*pg_aux^2) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg_aux + cost_rev[3]*pg_aux^2) elseif length(cost_rev) >= 4 cost_rev_nl = cost_rev[4:end] - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg_aux + cost_rev[3]*pg_aux^2 + sum( v*pg_aux^(d+2) for (d,v) in enumerate(cost_rev_nl)) ) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg_aux + cost_rev[3]*pg_aux^2 + sum( v*pg_aux^(d+2) for (d,v) in enumerate(cost_rev_nl)) ) else - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, 0.0) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, 0.0) end end end # ITD (Combined objective) - return JuMP.@NLobjective(pmitd.model, Min, + return JuMP.@objective(pmitd.model, Min, sum( sum( pm_gen_cost[(n,i)] for (i,gen) in nw_ref[:gen] ) for (n, nw_ref) in _PM.nws(pm)) diff --git a/src/core/objective_dmld.jl b/src/core/objective_dmld.jl index a491c25..49094b1 100644 --- a/src/core/objective_dmld.jl +++ b/src/core/objective_dmld.jl @@ -211,16 +211,16 @@ function _objective_itd_min_fuel_polynomial_nl_distribution_load_setpoint_delta( cost_rev = reverse(gen["cost"]) if length(cost_rev) == 1 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1]) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1]) elseif length(cost_rev) == 2 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg) elseif length(cost_rev) == 3 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2) elseif length(cost_rev) >= 4 cost_rev_nl = cost_rev[4:end] - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2 + sum( v*pg^(d+3) for (d,v) in enumerate(cost_rev_nl)) ) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2 + sum( v*pg^(d+3) for (d,v) in enumerate(cost_rev_nl)) ) else - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, 0.0) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, 0.0) end end end diff --git a/src/core/objective_dmld_simple.jl b/src/core/objective_dmld_simple.jl index 00ffe83..4060cd6 100644 --- a/src/core/objective_dmld_simple.jl +++ b/src/core/objective_dmld_simple.jl @@ -149,16 +149,16 @@ function _objective_itd_min_fuel_polynomial_nl_distribution_load_setpoint_delta_ cost_rev = reverse(gen["cost"]) if length(cost_rev) == 1 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1]) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1]) elseif length(cost_rev) == 2 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg) elseif length(cost_rev) == 3 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2) elseif length(cost_rev) >= 4 cost_rev_nl = cost_rev[4:end] - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2 + sum( v*pg^(d+3) for (d,v) in enumerate(cost_rev_nl)) ) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2 + sum( v*pg^(d+3) for (d,v) in enumerate(cost_rev_nl)) ) else - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, 0.0) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, 0.0) end end end diff --git a/src/core/objective_helpers.jl b/src/core/objective_helpers.jl index 2f863c2..83b1a2c 100644 --- a/src/core/objective_helpers.jl +++ b/src/core/objective_helpers.jl @@ -188,7 +188,7 @@ function _objective_variable_pg_cost(pm::_PM.AbstractIVRModel; report::Bool=true for (n, nw_ref) in _PM.nws(pm) gen_lines = _PM.calc_cost_pwl_lines(nw_ref[:gen]) - #to avoid function calls inside of @NLconstraint + #to avoid function calls inside of @constraint pg_cost = _PM.var(pm, n)[:pg_cost] = JuMP.@variable(pm.model, [i in _PM.ids(pm, n, :gen)], base_name="$(n)_pg_cost", ) @@ -197,7 +197,7 @@ function _objective_variable_pg_cost(pm::_PM.AbstractIVRModel; report::Bool=true for (i, gen) in nw_ref[:gen] pg = _PM.var(pm, n, :pg, i) for line in gen_lines[i] - JuMP.@NLconstraint(pm.model, pg_cost[i] >= line.slope*pg + line.intercept) + JuMP.@constraint(pm.model, pg_cost[i] >= line.slope*pg + line.intercept) end end end @@ -217,7 +217,7 @@ function _objective_variable_dc_cost(pm::_PM.AbstractIVRModel, report::Bool=true for (n, nw_ref) in _PM.nws(pm) dcline_lines = _PM.calc_cost_pwl_lines(nw_ref[:dcline]) - #to avoid function calls inside of @NLconstraint + #to avoid function calls inside of @constraint p_dc_cost = _PM.var(pm, n)[:p_dc_cost] = JuMP.@variable(pm.model, [i in _PM.ids(pm, n, :dcline)], base_name="$(n)_p_dc_cost", ) @@ -227,7 +227,7 @@ function _objective_variable_dc_cost(pm::_PM.AbstractIVRModel, report::Bool=true arc = (i, dcline["f_bus"], dcline["t_bus"]) p_dc_var = _PM.var(pm, n, :p_dc)[arc] for line in dcline_lines[i] - JuMP.@NLconstraint(pm.model, p_dc_cost[i] >= line.slope*p_dc_var + line.intercept) + JuMP.@constraint(pm.model, p_dc_cost[i] >= line.slope*p_dc_var + line.intercept) end end end diff --git a/src/core/objective_storage.jl b/src/core/objective_storage.jl index 90ed08b..b7089eb 100644 --- a/src/core/objective_storage.jl +++ b/src/core/objective_storage.jl @@ -171,14 +171,14 @@ function _objective_itd_min_fuel_cost_polynomial_linquad_storage(pmitd::Abstract # for (i,gen) in nw_ref[:gen] # bus = gen["gen_bus"] - # #to avoid function calls inside of @NLconstraint: + # #to avoid function calls inside of @constraint: # pg = _PM.var(pm, n, :pg, i) # if length(gen["cost"]) == 1 # pm_gen_cost[(n,i)] = gen["cost"][1] # elseif length(gen["cost"]) == 2 - # pm_gen_cost[(n,i)] = JuMP.@NLexpression(pm.model, gen["cost"][1]*pg + gen["cost"][2]) + # pm_gen_cost[(n,i)] = JuMP.@expression(pm.model, gen["cost"][1]*pg + gen["cost"][2]) # elseif length(gen["cost"]) == 3 - # pm_gen_cost[(n,i)] = JuMP.@NLexpression(pm.model, gen["cost"][1]*pg^2 + gen["cost"][2]*pg + gen["cost"][3]) + # pm_gen_cost[(n,i)] = JuMP.@expression(pm.model, gen["cost"][1]*pg^2 + gen["cost"][2]*pg + gen["cost"][3]) # else # pm_gen_cost[(n,i)] = 0.0 # end @@ -202,14 +202,14 @@ function _objective_itd_min_fuel_cost_polynomial_linquad_storage(pmitd::Abstract # for (i,gen) in nw_ref[:gen] # bus = gen["gen_bus"] - # #to avoid function calls inside of @NLconstraint: + # #to avoid function calls inside of @constraint: # pg = _PMD.var(pmd, n, :pg, i) # if length(gen["cost"]) == 1 # pmd_gen_cost[(n,i)] = gen["cost"][1] # elseif length(gen["cost"]) == 2 - # pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmd.model, gen["cost"][1]*sum(pg[c] for c in gen["connections"]) + gen["cost"][2]) + # pmd_gen_cost[(n,i)] = JuMP.@expression(pmd.model, gen["cost"][1]*sum(pg[c] for c in gen["connections"]) + gen["cost"][2]) # elseif length(gen["cost"]) == 3 - # pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmd.model, gen["cost"][1]*sum(pg[c] for c in gen["connections"])^2 + gen["cost"][2]*sum(pg[c] for c in gen["connections"]) + gen["cost"][3]) + # pmd_gen_cost[(n,i)] = JuMP.@expression(pmd.model, gen["cost"][1]*sum(pg[c] for c in gen["connections"])^2 + gen["cost"][2]*sum(pg[c] for c in gen["connections"]) + gen["cost"][3]) # else # pmd_gen_cost[(n,i)] = 0.0 # end @@ -230,7 +230,7 @@ function _objective_itd_min_fuel_cost_polynomial_linquad_storage(pmitd::Abstract # # ITD (Combined objective) - # return JuMP.@NLobjective(pmitd.model, Min, + # return JuMP.@objective(pmitd.model, Min, # sum( # sum( pm_gen_cost[(n,i)] for (i,gen) in nw_ref[:gen] ) # for (n, nw_ref) in _PM.nws(pm)) @@ -267,20 +267,20 @@ function _objective_itd_min_fuel_cost_polynomial_nl_storage(pmitd::AbstractIVRPo # for (i,gen) in nw_ref[:gen] # bus = gen["gen_bus"] - # #to avoid function calls inside of @NLconstraint: + # #to avoid function calls inside of @constraint: # pg = _PM.var(pm, n, :pg, i) # cost_rev = reverse(gen["cost"]) # if length(cost_rev) == 1 - # pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1]) + # pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1]) # elseif length(cost_rev) == 2 - # pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg) + # pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg) # elseif length(cost_rev) == 3 - # pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2) + # pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2) # elseif length(cost_rev) >= 4 # cost_rev_nl = cost_rev[4:end] - # pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2 + sum( v*pg^(d+3) for (d,v) in enumerate(cost_rev_nl)) ) + # pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2 + sum( v*pg^(d+3) for (d,v) in enumerate(cost_rev_nl)) ) # else - # pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, 0.0) + # pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, 0.0) # end # end # end @@ -305,16 +305,16 @@ function _objective_itd_min_fuel_cost_polynomial_nl_storage(pmitd::AbstractIVRPo # cost_rev = reverse(gen["cost"]) # if length(cost_rev) == 1 - # pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1]) + # pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1]) # elseif length(cost_rev) == 2 - # pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*sum(pg[c] for c in gen["connections"])) + # pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*sum(pg[c] for c in gen["connections"])) # elseif length(cost_rev) == 3 - # pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*sum(pg[c] for c in gen["connections"]) + cost_rev[3]*sum(pg[c] for c in gen["connections"])^2) + # pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*sum(pg[c] for c in gen["connections"]) + cost_rev[3]*sum(pg[c] for c in gen["connections"])^2) # elseif length(cost_rev) >= 4 # cost_rev_nl = cost_rev[4:end] - # pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*sum(pg[c] for c in gen["connections"]) + cost_rev[3]*sum(pg[c] for c in gen["connections"])^2 + sum( v*sum(pg[c] for c in gen["connections"])^(d+3) for (d,v) in enumerate(cost_rev_nl)) ) + # pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*sum(pg[c] for c in gen["connections"]) + cost_rev[3]*sum(pg[c] for c in gen["connections"])^2 + sum( v*sum(pg[c] for c in gen["connections"])^(d+3) for (d,v) in enumerate(cost_rev_nl)) ) # else - # pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, 0.0) + # pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, 0.0) # end # end # end @@ -333,7 +333,7 @@ function _objective_itd_min_fuel_cost_polynomial_nl_storage(pmitd::AbstractIVRPo # # ITD (Combined objective) - # return JuMP.@NLobjective(pmitd.model, Min, + # return JuMP.@objective(pmitd.model, Min, # sum( # sum( pm_gen_cost[(n,i)] for (i,gen) in nw_ref[:gen] ) # for (n, nw_ref) in _PM.nws(pm)) @@ -370,16 +370,16 @@ function _objective_itd_min_fuel_cost_polynomial_nl_storage(pmitd::AbstractPower cost_rev = reverse(gen["cost"]) if length(cost_rev) == 1 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1]) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1]) elseif length(cost_rev) == 2 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg) elseif length(cost_rev) == 3 - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2) elseif length(cost_rev) >= 4 cost_rev_nl = cost_rev[4:end] - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2 + sum( v*pg^(d+3) for (d,v) in enumerate(cost_rev_nl)) ) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg + cost_rev[3]*pg^2 + sum( v*pg^(d+3) for (d,v) in enumerate(cost_rev_nl)) ) else - pm_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, 0.0) + pm_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, 0.0) end end end @@ -408,16 +408,16 @@ function _objective_itd_min_fuel_cost_polynomial_nl_storage(pmitd::AbstractPower JuMP.@constraint(pmitd.model, pg_aux == pg) if length(cost_rev) == 1 - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1]) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1]) elseif length(cost_rev) == 2 - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg_aux) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg_aux) elseif length(cost_rev) == 3 - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg_aux + cost_rev[3]*pg_aux^2) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg_aux + cost_rev[3]*pg_aux^2) elseif length(cost_rev) >= 4 cost_rev_nl = cost_rev[4:end] - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, cost_rev[1] + cost_rev[2]*pg_aux + cost_rev[3]*pg_aux^2 + sum( v*pg_aux^(d+3) for (d,v) in enumerate(cost_rev_nl)) ) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, cost_rev[1] + cost_rev[2]*pg_aux + cost_rev[3]*pg_aux^2 + sum( v*pg_aux^(d+3) for (d,v) in enumerate(cost_rev_nl)) ) else - pmd_gen_cost[(n,i)] = JuMP.@NLexpression(pmitd.model, 0.0) + pmd_gen_cost[(n,i)] = JuMP.@expression(pmitd.model, 0.0) end end end @@ -435,7 +435,7 @@ function _objective_itd_min_fuel_cost_polynomial_nl_storage(pmitd::AbstractPower end # ITD (Combined objective) - return JuMP.@NLobjective(pmitd.model, Min, + return JuMP.@objective(pmitd.model, Min, sum( sum( pm_gen_cost[(n,i)] for (i,gen) in nw_ref[:gen] ) for (n, nw_ref) in _PM.nws(pm)) diff --git a/src/form/acp.jl b/src/form/acp.jl index 5c4a7b1..fcc6652 100644 --- a/src/form/acp.jl +++ b/src/form/acp.jl @@ -39,63 +39,29 @@ function constraint_transmission_power_balance(pmitd::AbstractPowerModelITD, pm: pbound_fr = get(var(pmitd, n), :pbound_fr, Dict()); _PM._check_var_keys(pbound_fr, bus_arcs_boundary_from, "active power", "boundary") qbound_fr = get(var(pmitd, n), :qbound_fr, Dict()); _PM._check_var_keys(qbound_fr, bus_arcs_boundary_from, "reactive power", "boundary") - # the check "typeof(p[arc]) <: JuMP.NonlinearExpression" is required for the - # case when p/q are nonlinear expressions instead of decision variables - # once NLExpressions are first order in JuMP it should be possible to - # remove this. - nl_form = length(bus_arcs) > 0 && (typeof(p[iterate(bus_arcs)[1]]) <: JuMP.NonlinearExpression) - - if !nl_form - cstr_p = JuMP.@constraint(pmitd.model, - sum(p[a] for a in bus_arcs) - + sum(p_dc[a_dc] for a_dc in bus_arcs_dc) - + sum(psw[a_sw] for a_sw in bus_arcs_sw) - + sum(pbound_fr[a_pbound_fr][1] for a_pbound_fr in bus_arcs_boundary_from) - == - sum(pg[g] for g in bus_gens) - - sum(ps[s] for s in bus_storage) - - sum(pd for (i,pd) in bus_pd) - - sum(gs for (i,gs) in bus_gs)*vm^2 - ) - else - cstr_p = JuMP.@NLconstraint(pmitd.model, - sum(p[a] for a in bus_arcs) - + sum(p_dc[a_dc] for a_dc in bus_arcs_dc) - + sum(psw[a_sw] for a_sw in bus_arcs_sw) - + sum(pbound_fr[a_pbound_fr][1] for a_pbound_fr in bus_arcs_boundary_from) - == - sum(pg[g] for g in bus_gens) - - sum(ps[s] for s in bus_storage) - - sum(pd for (i,pd) in bus_pd) - - sum(gs for (i,gs) in bus_gs)*vm^2 - ) - end + cstr_p = JuMP.@constraint(pmitd.model, + sum(p[a] for a in bus_arcs) + + sum(p_dc[a_dc] for a_dc in bus_arcs_dc) + + sum(psw[a_sw] for a_sw in bus_arcs_sw) + + sum(pbound_fr[a_pbound_fr][1] for a_pbound_fr in bus_arcs_boundary_from) + == + sum(pg[g] for g in bus_gens) + - sum(ps[s] for s in bus_storage) + - sum(pd for (i,pd) in bus_pd) + - sum(gs for (i,gs) in bus_gs)*vm^2 + ) - if !nl_form - cstr_q = JuMP.@constraint(pmitd.model, - sum(q[a] for a in bus_arcs) - + sum(q_dc[a_dc] for a_dc in bus_arcs_dc) - + sum(qsw[a_sw] for a_sw in bus_arcs_sw) - + sum(qbound_fr[a_qbound_fr][1] for a_qbound_fr in bus_arcs_boundary_from) - == - sum(qg[g] for g in bus_gens) - - sum(qs[s] for s in bus_storage) - - sum(qd for (i,qd) in bus_qd) - + sum(bs for (i,bs) in bus_bs)*vm^2 - ) - else - cstr_q = JuMP.@NLconstraint(pmitd.model, - sum(q[a] for a in bus_arcs) - + sum(q_dc[a_dc] for a_dc in bus_arcs_dc) - + sum(qsw[a_sw] for a_sw in bus_arcs_sw) - + sum(qbound_fr[a_qbound_fr][1] for a_qbound_fr in bus_arcs_boundary_from) - == - sum(qg[g] for g in bus_gens) - - sum(qs[s] for s in bus_storage) - - sum(qd for (i,qd) in bus_qd) - + sum(bs for (i,bs) in bus_bs)*vm^2 - ) - end + cstr_q = JuMP.@constraint(pmitd.model, + sum(q[a] for a in bus_arcs) + + sum(q_dc[a_dc] for a_dc in bus_arcs_dc) + + sum(qsw[a_sw] for a_sw in bus_arcs_sw) + + sum(qbound_fr[a_qbound_fr][1] for a_qbound_fr in bus_arcs_boundary_from) + == + sum(qg[g] for g in bus_gens) + - sum(qs[s] for s in bus_storage) + - sum(qd for (i,qd) in bus_qd) + + sum(bs for (i,bs) in bus_bs)*vm^2 + ) if _IM.report_duals(pmitd) sol(pmitd, n, :bus, i)[:lam_kcl_r] = cstr_p @@ -156,11 +122,11 @@ function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd for (idx,t) in ungrounded_terminals if any(Bs[idx,jdx] != 0 for (jdx, u) in ungrounded_terminals if idx != jdx) || any(Gs[idx,jdx] != 0 for (jdx, u) in ungrounded_terminals if idx != jdx) - cp = JuMP.@NLconstraint(pmitd.model, + cp = JuMP.@constraint(pmitd.model, sum( p[a][t] for (a, conns) in bus_arcs if t in conns) + sum(psw[a][t] for (a, conns) in bus_arcs_sw if t in conns) + sum( pt[a][t] for (a, conns) in bus_arcs_trans if t in conns) - - sum( pg[g][t] for (g, conns) in bus_gens if t in conns) + + sum( -pg[g][t] for (g, conns) in bus_gens if t in conns) + sum( ps[s][t] for (s, conns) in bus_storage if t in conns) + sum( pd[l][t] for (l, conns) in bus_loads if t in conns) + sum(pbound_to[a_pbound_to][t] for a_pbound_to in bus_arcs_boundary_to) @@ -175,11 +141,11 @@ function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd ) push!(cstr_p, cp) - cq = JuMP.@NLconstraint(pmitd.model, + cq = JuMP.@constraint(pmitd.model, sum( q[a][t] for (a, conns) in bus_arcs if t in conns) + sum(qsw[a][t] for (a, conns) in bus_arcs_sw if t in conns) + sum( qt[a][t] for (a, conns) in bus_arcs_trans if t in conns) - - sum( qg[g][t] for (g, conns) in bus_gens if t in conns) + + sum( -qg[g][t] for (g, conns) in bus_gens if t in conns) + sum( qs[s][t] for (s, conns) in bus_storage if t in conns) + sum( qd[l][t] for (l, conns) in bus_loads if t in conns) + sum(qbound_to[a_qbound_to][t] for a_qbound_to in bus_arcs_boundary_to) @@ -194,11 +160,11 @@ function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd ) push!(cstr_q, cq) else - cp = @smart_constraint(pmitd.model, [p, pg, ps, psw, pt, pd, pbound_to, vm], + cp = JuMP.@constraint(pmitd.model, sum( p[a][t] for (a, conns) in bus_arcs if t in conns) + sum(psw[a][t] for (a, conns) in bus_arcs_sw if t in conns) + sum( pt[a][t] for (a, conns) in bus_arcs_trans if t in conns) - - sum( pg[g][t] for (g, conns) in bus_gens if t in conns) + + sum( -pg[g][t] for (g, conns) in bus_gens if t in conns) + sum( ps[s][t] for (s, conns) in bus_storage if t in conns) + sum( pd[l][t] for (l, conns) in bus_loads if t in conns) + sum(pbound_to[a_pbound_to][t] for a_pbound_to in bus_arcs_boundary_to) @@ -208,11 +174,11 @@ function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd ) push!(cstr_p, cp) - cq = @smart_constraint(pmitd.model, [q, qg, qs, qsw, qt, qd, qbound_to, vm], + cq = JuMP.@constraint(pmitd.model, sum( q[a][t] for (a, conns) in bus_arcs if t in conns) + sum(qsw[a][t] for (a, conns) in bus_arcs_sw if t in conns) + sum( qt[a][t] for (a, conns) in bus_arcs_trans if t in conns) - - sum( qg[g][t] for (g, conns) in bus_gens if t in conns) + + sum( -qg[g][t] for (g, conns) in bus_gens if t in conns) + sum( qs[s][t] for (s, conns) in bus_storage if t in conns) + sum( qd[l][t] for (l, conns) in bus_loads if t in conns) + sum(qbound_to[a_qbound_to][t] for a_qbound_to in bus_arcs_boundary_to) diff --git a/src/form/acr.jl b/src/form/acr.jl index 03869cf..3427017 100644 --- a/src/form/acr.jl +++ b/src/form/acr.jl @@ -121,13 +121,13 @@ function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd # pd/qd can be NLexpressions, so cannot be vectorized for (idx, t) in ungrounded_terminals - cp = @smart_constraint(pmitd.model, [p, q, pg, qg, ps, qs, psw, qsw, pt, qt, pd, qd, pbound_to, qbound_to, vr, vi], + cp = JuMP.@constraint(pmitd.model, sum( p[arc][t] for (arc, conns) in bus_arcs if t in conns) + sum(psw[arc][t] for (arc, conns) in bus_arcs_sw if t in conns) + sum( pt[arc][t] for (arc, conns) in bus_arcs_trans if t in conns) + sum(pbound_to[a_pbound_to][t] for a_pbound_to in bus_arcs_boundary_to) == - sum(pg[gen][t] for (gen, conns) in bus_gens if t in conns) + - sum(-pg[gen][t] for (gen, conns) in bus_gens if t in conns) - sum(ps[strg][t] for (strg, conns) in bus_storage if t in conns) - sum(pd[load][t] for (load, conns) in bus_loads if t in conns) + ( -vr[t] * sum(Gt[idx,jdx]*vr[u]-Bt[idx,jdx]*vi[u] for (jdx,u) in ungrounded_terminals) @@ -136,13 +136,13 @@ function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd ) push!(cstr_p, cp) - cq = @smart_constraint(pmitd.model, [p, q, pg, qg, ps, qs, psw, qsw, pt, qt, pd, qd, pbound_to, qbound_to, vr, vi], + cq = JuMP.@constraint(pmitd.model, sum( q[arc][t] for (arc, conns) in bus_arcs if t in conns) + sum(qsw[arc][t] for (arc, conns) in bus_arcs_sw if t in conns) + sum( qt[arc][t] for (arc, conns) in bus_arcs_trans if t in conns) + sum(qbound_to[a_qbound_to][t] for a_qbound_to in bus_arcs_boundary_to) == - sum(qg[gen][t] for (gen, conns) in bus_gens if t in conns) + - sum(-qg[gen][t] for (gen, conns) in bus_gens if t in conns) - sum(qd[load][t] for (load, conns) in bus_loads if t in conns) - sum(qs[strg][t] for (strg, conns) in bus_storage if t in conns) + ( vr[t] * sum(Gt[idx,jdx]*vi[u]+Bt[idx,jdx]*vr[u] for (jdx,u) in ungrounded_terminals) @@ -217,6 +217,6 @@ function constraint_boundary_voltage_angle(pm::_PM.ACRPowerModel, pmd::_PMD.ACRU shift_120degs_rad = deg2rad(120) # TODO: These are non-linear constraints due to transformation to degrees of phase a angle (another way - non-linear may be possible) - JuMP.@NLconstraint(pm.model, vi_to[2] == tan(atan(vi_to[1]/vr_to[1]) - shift_120degs_rad)*vr_to[2]) - JuMP.@NLconstraint(pm.model, vi_to[3] == tan(atan(vi_to[1]/vr_to[1]) + shift_120degs_rad)*vr_to[3]) + JuMP.@constraint(pm.model, vi_to[2] == tan(atan(vi_to[1]/vr_to[1]) - shift_120degs_rad)*vr_to[2]) + JuMP.@constraint(pm.model, vi_to[3] == tan(atan(vi_to[1]/vr_to[1]) + shift_120degs_rad)*vr_to[3]) end diff --git a/src/form/fbs.jl b/src/form/fbs.jl index b41e982..2efd8eb 100644 --- a/src/form/fbs.jl +++ b/src/form/fbs.jl @@ -55,7 +55,7 @@ function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd + sum( pt[arc][t] for (arc, conns) in bus_arcs_trans if t in conns) + sum(pbound_to[a_pbound_to][t] for a_pbound_to in bus_arcs_boundary_to) == - sum(pg[gen][t] for (gen, conns) in bus_gens if t in conns) + - sum(-pg[gen][t] for (gen, conns) in bus_gens if t in conns) - sum(ps[strg][t] for (strg, conns) in bus_storage if t in conns) - sum(pd[load][t] for (load, conns) in bus_loads if t in conns) + ( -vr[t] * sum(Gt[idx,jdx]*vr[u]-Bt[idx,jdx]*vi[u] for (jdx,u) in ungrounded_terminals) @@ -70,7 +70,7 @@ function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd + sum( qt[arc][t] for (arc, conns) in bus_arcs_trans if t in conns) + sum(qbound_to[a_qbound_to][t] for a_qbound_to in bus_arcs_boundary_to) == - sum(qg[gen][t] for (gen, conns) in bus_gens if t in conns) + - sum(-qg[gen][t] for (gen, conns) in bus_gens if t in conns) - sum(qd[load][t] for (load, conns) in bus_loads if t in conns) - sum(qs[strg][t] for (strg, conns) in bus_storage if t in conns) + ( vr[t] * sum(Gt[idx,jdx]*vi[u]+Bt[idx,jdx]*vr[u] for (jdx,u) in ungrounded_terminals) @@ -149,6 +149,6 @@ function constraint_boundary_voltage_angle(pm::_PM.ACRPowerModel, pmd::_PMD.FBSU shift_120degs_rad = deg2rad(120) # TODO: These are non-linear constraints due to transformation to degrees of phase a angle (another way - non-linear may be possible) - JuMP.@NLconstraint(pm.model, vi_to[2] == tan(atan(vi_to[1]/vr_to[1]) - shift_120degs_rad)*vr_to[2]) - JuMP.@NLconstraint(pm.model, vi_to[3] == tan(atan(vi_to[1]/vr_to[1]) + shift_120degs_rad)*vr_to[3]) + JuMP.@constraint(pm.model, vi_to[2] == tan(atan(vi_to[1]/vr_to[1]) - shift_120degs_rad)*vr_to[2]) + JuMP.@constraint(pm.model, vi_to[3] == tan(atan(vi_to[1]/vr_to[1]) + shift_120degs_rad)*vr_to[3]) end diff --git a/src/form/fotp.jl b/src/form/fotp.jl index 94c463b..a4ef592 100644 --- a/src/form/fotp.jl +++ b/src/form/fotp.jl @@ -58,7 +58,7 @@ function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd sum( p[a][t] for (a, conns) in bus_arcs if t in conns) + sum(psw[a][t] for (a, conns) in bus_arcs_sw if t in conns) + sum( pt[a][t] for (a, conns) in bus_arcs_trans if t in conns) - - sum( pg[g][t] for (g, conns) in bus_gens if t in conns) + + sum( -pg[g][t] for (g, conns) in bus_gens if t in conns) + sum( ps[s][t] for (s, conns) in bus_storage if t in conns) + sum( pd[l][t] for (l, conns) in bus_loads if t in conns) + sum(pbound_to[a_pbound_to][t] for a_pbound_to in bus_arcs_boundary_to) @@ -78,7 +78,7 @@ function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd sum( q[a][t] for (a, conns) in bus_arcs if t in conns) + sum(qsw[a][t] for (a, conns) in bus_arcs_sw if t in conns) + sum( qt[a][t] for (a, conns) in bus_arcs_trans if t in conns) - - sum( qg[g][t] for (g, conns) in bus_gens if t in conns) + + sum( -qg[g][t] for (g, conns) in bus_gens if t in conns) + sum( qs[s][t] for (s, conns) in bus_storage if t in conns) + sum( qd[l][t] for (l, conns) in bus_loads if t in conns) + sum(qbound_to[a_qbound_to][t] for a_qbound_to in bus_arcs_boundary_to) @@ -98,7 +98,7 @@ function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd sum( p[a][t] for (a, conns) in bus_arcs if t in conns) + sum(psw[a][t] for (a, conns) in bus_arcs_sw if t in conns) + sum( pt[a][t] for (a, conns) in bus_arcs_trans if t in conns) - - sum( pg[g][t] for (g, conns) in bus_gens if t in conns) + + sum( -pg[g][t] for (g, conns) in bus_gens if t in conns) + sum( ps[s][t] for (s, conns) in bus_storage if t in conns) + sum( pd[l][t] for (l, conns) in bus_loads if t in conns) + sum(pbound_to[a_pbound_to][t] for a_pbound_to in bus_arcs_boundary_to) @@ -112,7 +112,7 @@ function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd sum( q[a][t] for (a, conns) in bus_arcs if t in conns) + sum(qsw[a][t] for (a, conns) in bus_arcs_sw if t in conns) + sum( qt[a][t] for (a, conns) in bus_arcs_trans if t in conns) - - sum( qg[g][t] for (g, conns) in bus_gens if t in conns) + + sum( -qg[g][t] for (g, conns) in bus_gens if t in conns) + sum( qs[s][t] for (s, conns) in bus_storage if t in conns) + sum( qd[l][t] for (l, conns) in bus_loads if t in conns) + sum(qbound_to[a_qbound_to][t] for a_qbound_to in bus_arcs_boundary_to) diff --git a/src/form/fotr.jl b/src/form/fotr.jl index 345da47..d0f1af2 100644 --- a/src/form/fotr.jl +++ b/src/form/fotr.jl @@ -59,7 +59,7 @@ function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd + sum( pt[arc][t] for (arc, conns) in bus_arcs_trans if t in conns) + sum(pbound_to[a_pbound_to][t] for a_pbound_to in bus_arcs_boundary_to) == - sum(pg[gen][t] for (gen, conns) in bus_gens if t in conns) + - sum(-pg[gen][t] for (gen, conns) in bus_gens if t in conns) - sum(ps[strg][t] for (strg, conns) in bus_storage if t in conns) - sum(pd[load][t] for (load, conns) in bus_loads if t in conns) + ( -sum(Gt[idx,jdx]*vr0[t]*vr0[u]-Bt[idx,jdx]*vr0[t]*vi0[u] for (jdx,u) in ungrounded_terminals) @@ -77,7 +77,7 @@ function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd + sum( qt[arc][t] for (arc, conns) in bus_arcs_trans if t in conns) + sum(qbound_to[a_qbound_to][t] for a_qbound_to in bus_arcs_boundary_to) == - sum(qg[gen][t] for (gen, conns) in bus_gens if t in conns) + - sum(-qg[gen][t] for (gen, conns) in bus_gens if t in conns) - sum(qd[load][t] for (load, conns) in bus_loads if t in conns) - sum(qs[strg][t] for (strg, conns) in bus_storage if t in conns) + ( sum(Gt[idx,jdx]*vr0[t]*vi0[u]+Bt[idx,jdx]*vr0[t]*vr0[u] for (jdx,u) in ungrounded_terminals) @@ -159,7 +159,7 @@ function constraint_boundary_voltage_angle(pm::_PM.ACRPowerModel, pmd::_PMD.FOTR shift_120degs_rad = deg2rad(120) # TODO: These are non-linear constraints due to transformation to degrees of phase a angle (another way - non-linear may be possible) - JuMP.@NLconstraint(pm.model, vi_to[2] == tan(atan(vi_to[1]/vr_to[1]) - shift_120degs_rad)*vr_to[2]) - JuMP.@NLconstraint(pm.model, vi_to[3] == tan(atan(vi_to[1]/vr_to[1]) + shift_120degs_rad)*vr_to[3]) + JuMP.@constraint(pm.model, vi_to[2] == tan(atan(vi_to[1]/vr_to[1]) - shift_120degs_rad)*vr_to[2]) + JuMP.@constraint(pm.model, vi_to[3] == tan(atan(vi_to[1]/vr_to[1]) + shift_120degs_rad)*vr_to[3]) end diff --git a/src/form/ivr.jl b/src/form/ivr.jl index 0f5dc78..c8d26e1 100644 --- a/src/form/ivr.jl +++ b/src/form/ivr.jl @@ -34,7 +34,7 @@ function constraint_transmission_current_balance(pmitd::AbstractPowerModelITD, p cibound_fr = get(var(pmitd, n), :cibound_fr, Dict()); _PM._check_var_keys(cibound_fr, bus_arcs_boundary_from, "imaginary current", "boundary") - JuMP.@NLconstraint(pmitd.model, sum(cr[a] for a in bus_arcs) + JuMP.@constraint(pmitd.model, sum(cr[a] for a in bus_arcs) + sum(crdc[d] for d in bus_arcs_dc) + sum(crbound_fr[a_crbound_fr][1] for a_crbound_fr in bus_arcs_boundary_from) == @@ -42,7 +42,7 @@ function constraint_transmission_current_balance(pmitd::AbstractPowerModelITD, p - (sum(pd for pd in values(bus_pd))*vr + sum(qd for qd in values(bus_qd))*vi)/(vr^2 + vi^2) - sum(gs for gs in values(bus_gs))*vr + sum(bs for bs in values(bus_bs))*vi ) - JuMP.@NLconstraint(pmitd.model, sum(ci[a] for a in bus_arcs) + JuMP.@constraint(pmitd.model, sum(ci[a] for a in bus_arcs) + sum(cidc[d] for d in bus_arcs_dc) + sum(cibound_fr[a_cibound_fr][1] for a_cibound_fr in bus_arcs_boundary_from) == @@ -99,24 +99,24 @@ function constraint_distribution_current_balance(pmitd::AbstractPowerModelITD, p ungrounded_terminals = [(idx,t) for (idx,t) in enumerate(terminals) if !grounded[idx]] for (idx, t) in ungrounded_terminals - @smart_constraint(pmitd.model, [cr, crd, crg, crs, crsw, crt, crbound_to, vr], + JuMP.@constraint(pmitd.model, sum(cr[a][t] for (a, conns) in bus_arcs if t in conns) + sum(crsw[a_sw][t] for (a_sw, conns) in bus_arcs_sw if t in conns) + sum(crt[a_trans][t] for (a_trans, conns) in bus_arcs_trans if t in conns) + sum(crbound_to[a_crbound_to][t] for a_crbound_to in bus_arcs_boundary_to) == - sum(crg[g][t] for (g, conns) in bus_gens if t in conns) + - sum(-crg[g][t] for (g, conns) in bus_gens if t in conns) - sum(crs[s][t] for (s, conns) in bus_storage if t in conns) - sum(crd[d][t] for (d, conns) in bus_loads if t in conns) - sum( Gt[idx,jdx]*vr[u] -Bt[idx,jdx]*vi[u] for (jdx,u) in ungrounded_terminals) # shunts ) - @smart_constraint(pmitd.model, [ci, cid, cig, cis, cisw, cit, cibound_to, vi], + JuMP.@constraint(pmitd.model, sum(ci[a][t] for (a, conns) in bus_arcs if t in conns) + sum(cisw[a_sw][t] for (a_sw, conns) in bus_arcs_sw if t in conns) + sum(cit[a_trans][t] for (a_trans, conns) in bus_arcs_trans if t in conns) + sum(cibound_to[a_cibound_to][t] for a_cibound_to in bus_arcs_boundary_to) == - sum(cig[g][t] for (g, conns) in bus_gens if t in conns) + - sum(-cig[g][t] for (g, conns) in bus_gens if t in conns) - sum(cis[s][t] for (s, conns) in bus_storage if t in conns) - sum(cid[d][t] for (d, conns) in bus_loads if t in conns) - sum( Gt[idx,jdx]*vi[u] +Bt[idx,jdx]*vr[u] for (jdx,u) in ungrounded_terminals) # shunts @@ -180,6 +180,6 @@ function constraint_boundary_voltage_angle(pm::_PM.IVRPowerModel, pmd::_PMD.IVRU shift_120degs_rad = deg2rad(120) # TODO: These are non-linear constraints due to transformation to degrees of phase a angle (another way - non-linear may be possible) - JuMP.@NLconstraint(pm.model, vi_to[2] == tan(atan(vi_to[1]/vr_to[1]) - shift_120degs_rad)*vr_to[2]) - JuMP.@NLconstraint(pm.model, vi_to[3] == tan(atan(vi_to[1]/vr_to[1]) + shift_120degs_rad)*vr_to[3]) + JuMP.@constraint(pm.model, vi_to[2] == tan(atan(vi_to[1]/vr_to[1]) - shift_120degs_rad)*vr_to[2]) + JuMP.@constraint(pm.model, vi_to[3] == tan(atan(vi_to[1]/vr_to[1]) + shift_120degs_rad)*vr_to[3]) end diff --git a/src/form/lindist3flow.jl b/src/form/lindist3flow.jl index 5f292c5..0313d82 100644 --- a/src/form/lindist3flow.jl +++ b/src/form/lindist3flow.jl @@ -49,7 +49,7 @@ function constraint_distribution_power_balance(pmitd::AbstractBFPowerModelITD, p sum( p[a][t] for (a, conns) in bus_arcs if t in conns) + sum(psw[a][t] for (a, conns) in bus_arcs_sw if t in conns) + sum( pt[a][t] for (a, conns) in bus_arcs_trans if t in conns) - - sum( pg[g][t] for (g, conns) in bus_gens if t in conns) + + sum( -pg[g][t] for (g, conns) in bus_gens if t in conns) + sum( ps[s][t] for (s, conns) in bus_storage if t in conns) + sum( pd[d][t] for (d, conns) in bus_loads if t in conns) + sum(diag(ref(pm, nw, :shunt, sh, "gs"))[findfirst(isequal(t), conns)]*w[t] for (sh, conns) in bus_shunts if t in conns) @@ -63,7 +63,7 @@ function constraint_distribution_power_balance(pmitd::AbstractBFPowerModelITD, p sum( q[a][t] for (a, conns) in bus_arcs if t in conns) + sum(qsw[a][t] for (a, conns) in bus_arcs_sw if t in conns) + sum( qt[a][t] for (a, conns) in bus_arcs_trans if t in conns) - - sum( qg[g][t] for (g, conns) in bus_gens if t in conns) + + sum( -qg[g][t] for (g, conns) in bus_gens if t in conns) + sum( qs[s][t] for (s, conns) in bus_storage if t in conns) + sum( qd[d][t] for (d, conns) in bus_loads if t in conns) - sum(diag(ref(pm, nw, :shunt, sh, "bs"))[findfirst(isequal(t), conns)]*w[t] for (sh, conns) in bus_shunts if t in conns) diff --git a/src/form/linear.jl b/src/form/linear.jl index 9ad5896..1832f92 100644 --- a/src/form/linear.jl +++ b/src/form/linear.jl @@ -95,7 +95,7 @@ function constraint_distribution_power_balance(pmitd::AbstractPowerModelITD, pmd + sum(pt[a_trans][t] for (a_trans, conns) in bus_arcs_trans if t in conns) + sum(pbound_to[a_pbound_to][t] for a_pbound_to in bus_arcs_boundary_to) == - sum(pg[g][t] for (g, conns) in bus_gens if t in conns) + - sum(-pg[g][t] for (g, conns) in bus_gens if t in conns) - sum(ps[s][t] for (s, conns) in bus_storage if t in conns) - sum(pd[d][t] for (d, conns) in bus_loads if t in conns) - LinearAlgebra.diag(Gt)[idx] diff --git a/src/form_decomposition/acp.jl b/src/form_decomposition/acp.jl index 8460ddf..03f3530 100644 --- a/src/form_decomposition/acp.jl +++ b/src/form_decomposition/acp.jl @@ -38,63 +38,29 @@ function constraint_transmission_power_balance(pm::_PM.AbstractACPModel, n::Int, pbound_load = get(_PM.var(pm, n), :pbound_load, Dict()); _PM._check_var_keys(pbound_load, bus_arcs_boundary_from, "active power", "boundary") qbound_load = get(_PM.var(pm, n), :qbound_load, Dict()); _PM._check_var_keys(qbound_load, bus_arcs_boundary_from, "reactive power", "boundary") - # the check "typeof(p[arc]) <: JuMP.NonlinearExpression" is required for the - # case when p/q are nonlinear expressions instead of decision variables - # once NLExpressions are first order in JuMP it should be possible to - # remove this. - nl_form = length(bus_arcs) > 0 && (typeof(p[iterate(bus_arcs)[1]]) <: JuMP.NonlinearExpression) - - if !nl_form - cstr_p = JuMP.@constraint(pm.model, - sum(p[a] for a in bus_arcs) - + sum(p_dc[a_dc] for a_dc in bus_arcs_dc) - + sum(psw[a_sw] for a_sw in bus_arcs_sw) - + sum(pbound_load[a_pbound_load][1] for a_pbound_load in bus_arcs_boundary_from) - == - sum(pg[g] for g in bus_gens) - - sum(ps[s] for s in bus_storage) - - sum(pd for (i,pd) in bus_pd) - - sum(gs for (i,gs) in bus_gs)*vm^2 - ) - else - cstr_p = JuMP.@NLconstraint(pm.model, - sum(p[a] for a in bus_arcs) - + sum(p_dc[a_dc] for a_dc in bus_arcs_dc) - + sum(psw[a_sw] for a_sw in bus_arcs_sw) - + sum(pbound_load[a_pbound_load][1] for a_pbound_load in bus_arcs_boundary_from) - == - sum(pg[g] for g in bus_gens) - - sum(ps[s] for s in bus_storage) - - sum(pd for (i,pd) in bus_pd) - - sum(gs for (i,gs) in bus_gs)*vm^2 - ) - end + cstr_p = JuMP.@constraint(pm.model, + sum(p[a] for a in bus_arcs) + + sum(p_dc[a_dc] for a_dc in bus_arcs_dc) + + sum(psw[a_sw] for a_sw in bus_arcs_sw) + + sum(pbound_load[a_pbound_load][1] for a_pbound_load in bus_arcs_boundary_from) + == + sum(pg[g] for g in bus_gens) + - sum(ps[s] for s in bus_storage) + - sum(pd for (i,pd) in bus_pd) + - sum(gs for (i,gs) in bus_gs)*vm^2 + ) - if !nl_form - cstr_q = JuMP.@constraint(pm.model, - sum(q[a] for a in bus_arcs) - + sum(q_dc[a_dc] for a_dc in bus_arcs_dc) - + sum(qsw[a_sw] for a_sw in bus_arcs_sw) - + sum(qbound_load[a_qbound_load][1] for a_qbound_load in bus_arcs_boundary_from) - == - sum(qg[g] for g in bus_gens) - - sum(qs[s] for s in bus_storage) - - sum(qd for (i,qd) in bus_qd) - + sum(bs for (i,bs) in bus_bs)*vm^2 - ) - else - cstr_q = JuMP.@NLconstraint(pm.model, - sum(q[a] for a in bus_arcs) - + sum(q_dc[a_dc] for a_dc in bus_arcs_dc) - + sum(qsw[a_sw] for a_sw in bus_arcs_sw) - + sum(qbound_load[a_qbound_load][1] for a_qbound_load in bus_arcs_boundary_from) - == - sum(qg[g] for g in bus_gens) - - sum(qs[s] for s in bus_storage) - - sum(qd for (i,qd) in bus_qd) - + sum(bs for (i,bs) in bus_bs)*vm^2 - ) - end + cstr_q = JuMP.@constraint(pm.model, + sum(q[a] for a in bus_arcs) + + sum(q_dc[a_dc] for a_dc in bus_arcs_dc) + + sum(qsw[a_sw] for a_sw in bus_arcs_sw) + + sum(qbound_load[a_qbound_load][1] for a_qbound_load in bus_arcs_boundary_from) + == + sum(qg[g] for g in bus_gens) + - sum(qs[s] for s in bus_storage) + - sum(qd for (i,qd) in bus_qd) + + sum(bs for (i,bs) in bus_bs)*vm^2 + ) if _IM.report_duals(pm) _PM.sol(pm, n, :bus, i)[:lam_kcl_r] = cstr_p diff --git a/src/form_decomposition/acr.jl b/src/form_decomposition/acr.jl index cae03a5..623996a 100644 --- a/src/form_decomposition/acr.jl +++ b/src/form_decomposition/acr.jl @@ -115,8 +115,8 @@ function constraint_boundary_voltage_angle(pmd::_PMD.ACRUPowerModel, ::Int, t_bu shift_120degs_rad = deg2rad(120) # TODO: These are non-linear constraints due to transformation to degrees of phase a angle (another way - non-linear may be possible) - JuMP.@NLconstraint(pmd.model, vi_source[2] == tan(atan(vi_source[1]/vr_source[1]) - shift_120degs_rad)*vr_source[2]) - JuMP.@NLconstraint(pmd.model, vi_source[3] == tan(atan(vi_source[1]/vr_source[1]) + shift_120degs_rad)*vr_source[3]) + JuMP.@constraint(pmd.model, vi_source[2] == tan(atan(vi_source[1]/vr_source[1]) - shift_120degs_rad)*vr_source[2]) + JuMP.@constraint(pmd.model, vi_source[3] == tan(atan(vi_source[1]/vr_source[1]) + shift_120degs_rad)*vr_source[3]) end diff --git a/src/form_decomposition/boundary.jl b/src/form_decomposition/boundary.jl index e81985a..5799a88 100644 --- a/src/form_decomposition/boundary.jl +++ b/src/form_decomposition/boundary.jl @@ -61,8 +61,8 @@ function constraint_boundary_power(pmd::_PMD.IVRUPowerModel, i::Int; nw::Int=nw_ spg = _PMD.var(pmd, nw, :pg, slack_gen_number) sqg = _PMD.var(pmd, nw, :qg, slack_gen_number) - JuMP.@NLconstraint(pmd.model, p_aux[1] == sum(spg[phase] for phase in boundary["t_connections"])) - JuMP.@NLconstraint(pmd.model, q_aux[1] == sum(sqg[phase] for phase in boundary["t_connections"])) + JuMP.@constraint(pmd.model, p_aux[1] == sum(spg[phase] for phase in boundary["t_connections"])) + JuMP.@constraint(pmd.model, q_aux[1] == sum(sqg[phase] for phase in boundary["t_connections"])) end diff --git a/src/form_decomposition/fbs.jl b/src/form_decomposition/fbs.jl index 1b153b4..77f9eac 100644 --- a/src/form_decomposition/fbs.jl +++ b/src/form_decomposition/fbs.jl @@ -45,8 +45,8 @@ function constraint_boundary_voltage_angle(pmd::_PMD.FBSUBFPowerModel, ::Int, t_ shift_120degs_rad = deg2rad(120) # TODO: These are non-linear constraints due to transformation to degrees of phase a angle (another way - non-linear may be possible) - JuMP.@NLconstraint(pmd.model, vi_source[2] == tan(atan(vi_source[1]/vr_source[1]) - shift_120degs_rad)*vr_source[2]) - JuMP.@NLconstraint(pmd.model, vi_source[3] == tan(atan(vi_source[1]/vr_source[1]) + shift_120degs_rad)*vr_source[3]) + JuMP.@constraint(pmd.model, vi_source[2] == tan(atan(vi_source[1]/vr_source[1]) - shift_120degs_rad)*vr_source[2]) + JuMP.@constraint(pmd.model, vi_source[3] == tan(atan(vi_source[1]/vr_source[1]) + shift_120degs_rad)*vr_source[3]) end diff --git a/src/form_decomposition/fotr.jl b/src/form_decomposition/fotr.jl index 11ea2a8..fea5d33 100644 --- a/src/form_decomposition/fotr.jl +++ b/src/form_decomposition/fotr.jl @@ -45,8 +45,8 @@ function constraint_boundary_voltage_angle(pmd::_PMD.FOTRUPowerModel, ::Int, t_b shift_120degs_rad = deg2rad(120) # TODO: These are non-linear constraints due to transformation to degrees of phase a angle (another way - non-linear may be possible) - JuMP.@NLconstraint(pmd.model, vi_source[2] == tan(atan(vi_source[1]/vr_source[1]) - shift_120degs_rad)*vr_source[2]) - JuMP.@NLconstraint(pmd.model, vi_source[3] == tan(atan(vi_source[1]/vr_source[1]) + shift_120degs_rad)*vr_source[3]) + JuMP.@constraint(pmd.model, vi_source[2] == tan(atan(vi_source[1]/vr_source[1]) - shift_120degs_rad)*vr_source[2]) + JuMP.@constraint(pmd.model, vi_source[3] == tan(atan(vi_source[1]/vr_source[1]) + shift_120degs_rad)*vr_source[3]) end diff --git a/src/form_decomposition/ivr.jl b/src/form_decomposition/ivr.jl index b4921e8..dea4187 100644 --- a/src/form_decomposition/ivr.jl +++ b/src/form_decomposition/ivr.jl @@ -30,7 +30,7 @@ function constraint_transmission_current_balance(pm::_PM.AbstractIVRModel, n::In pbound_load = get(_PM.var(pm, n), :pbound_load, Dict()); _PM._check_var_keys(pbound_load, bus_arcs_boundary_from, "active power", "boundary") qbound_load = get(_PM.var(pm, n), :qbound_load, Dict()); _PM._check_var_keys(qbound_load, bus_arcs_boundary_from, "reactive power", "boundary") - JuMP.@NLconstraint(pm.model, sum(cr[a] for a in bus_arcs) + JuMP.@constraint(pm.model, sum(cr[a] for a in bus_arcs) + sum(crdc[d] for d in bus_arcs_dc) + (sum(pbound_load[a_pbound_load][1] for a_pbound_load in bus_arcs_boundary_from)*vr + sum(qbound_load[a_qbound_load][1] for a_qbound_load in bus_arcs_boundary_from)*vi)/(vr^2 + vi^2) == @@ -38,7 +38,7 @@ function constraint_transmission_current_balance(pm::_PM.AbstractIVRModel, n::In - (sum(pd for pd in values(bus_pd))*vr + sum(qd for qd in values(bus_qd))*vi)/(vr^2 + vi^2) - sum(gs for gs in values(bus_gs))*vr + sum(bs for bs in values(bus_bs))*vi ) - JuMP.@NLconstraint(pm.model, sum(ci[a] for a in bus_arcs) + JuMP.@constraint(pm.model, sum(ci[a] for a in bus_arcs) + sum(cidc[d] for d in bus_arcs_dc) + (sum(pbound_load[a_pbound_load][1] for a_pbound_load in bus_arcs_boundary_from)*vi - sum(qbound_load[a_qbound_load][1] for a_qbound_load in bus_arcs_boundary_from)*vr)/(vr^2 + vi^2) == @@ -95,8 +95,8 @@ function constraint_boundary_voltage_angle(pmd::_PMD.IVRUPowerModel, ::Int, t_bu shift_120degs_rad = deg2rad(120) # TODO: These are non-linear constraints due to transformation to degrees of phase a angle (another way - non-linear may be possible) - JuMP.@NLconstraint(pmd.model, vi_source[2] == tan(atan(vi_source[1]/vr_source[1]) - shift_120degs_rad)*vr_source[2]) - JuMP.@NLconstraint(pmd.model, vi_source[3] == tan(atan(vi_source[1]/vr_source[1]) + shift_120degs_rad)*vr_source[3]) + JuMP.@constraint(pmd.model, vi_source[2] == tan(atan(vi_source[1]/vr_source[1]) - shift_120degs_rad)*vr_source[2]) + JuMP.@constraint(pmd.model, vi_source[3] == tan(atan(vi_source[1]/vr_source[1]) + shift_120degs_rad)*vr_source[3]) end