diff --git a/src/core/objective.jl b/src/core/objective.jl index 0d116d18..f47e400e 100644 --- a/src/core/objective.jl +++ b/src/core/objective.jl @@ -123,15 +123,6 @@ function objective_min_fuel_and_flow_cost_polynomial(pm::AbstractPowerModel; kwa end end -function _unstable_pow(x, p) - if p == 0 - return 1 - elseif p == 1 - return x - end - return x^p -end - "" function _objective_min_fuel_and_flow_cost_polynomial_linquad(pm::AbstractPowerModel; report::Bool=true) gen_cost = Dict() @@ -142,7 +133,7 @@ function _objective_min_fuel_and_flow_cost_polynomial_linquad(pm::AbstractPowerM pg = sum( var(pm, n, :pg, i)[c] for c in conductor_ids(pm, n) ) gen_cost[(n, i)] = JuMP.@expression( pm.model, - sum(v * _unstable_pow(pg, d-1) for (d, v) in enumerate(reverse(gen["cost"]))), + sum(v * pg^(d-1) for (d, v) in enumerate(reverse(gen["cost"]))), ) end @@ -151,7 +142,7 @@ function _objective_min_fuel_and_flow_cost_polynomial_linquad(pm::AbstractPowerM p_dc = sum( var(pm, n, :p_dc, from_idx[i])[c] for c in conductor_ids(pm, n) ) dcline_cost[(n, i)] = JuMP.@expression( pm.model, - sum(v * _unstable_pow(p_dc, d-1) for (d, v) in enumerate(reverse(dcline["cost"]))), + sum(v * p_dc^(d-1) for (d, v) in enumerate(reverse(dcline["cost"]))), ) end end @@ -272,7 +263,7 @@ function _objective_min_fuel_and_flow_cost_polynomial_nl(pm::AbstractPowerModel; pg = sum( var(pm, n, :pg, i)[c] for c in conductor_ids(pm, n)) gen_cost[(n,i)] = JuMP.@expression( pm.model, - sum(v * _unstable_pow(pg, d-1) for (d, v) in enumerate(reverse(gen["cost"]))), + sum(v * pg^(d-1) for (d, v) in enumerate(reverse(gen["cost"]))), ) end @@ -282,7 +273,7 @@ function _objective_min_fuel_and_flow_cost_polynomial_nl(pm::AbstractPowerModel; p_dc = sum( var(pm, n, :p_dc, from_idx[i])[c] for c in conductor_ids(pm, n)) dcline_cost[(n,i)] = JuMP.@expression( pm.model, - sum(v * _unstable_pow(p_dc, d-1) for (d, v) in enumerate(reverse(dcline["cost"]))), + sum(v * p_dc^(d-1) for (d, v) in enumerate(reverse(dcline["cost"]))), ) end end @@ -315,7 +306,7 @@ function _objective_min_fuel_cost_polynomial_linquad(pm::AbstractPowerModel; rep pg = sum( var(pm, n, :pg, i)[c] for c in conductor_ids(pm, n) ) gen_cost[(n, i)] = JuMP.@expression( pm.model, - sum(v * _unstable_pow(pg, d-1) for (d, v) in enumerate(reverse(gen["cost"]))), + sum(v * pg^(d-1) for (d, v) in enumerate(reverse(gen["cost"]))), ) end end @@ -336,7 +327,7 @@ function _objective_min_fuel_cost_polynomial_nl(pm::AbstractPowerModel; report:: pg = sum( var(pm, n, :pg, i)[c] for c in conductor_ids(pm, n)) gen_cost[(n,i)] = JuMP.@expression( pm.model, - sum(v * _unstable_pow(pg, d-1) for (d, v) in enumerate(reverse(gen["cost"]))), + sum(v * pg^(d-1) for (d, v) in enumerate(reverse(gen["cost"]))), ) end end diff --git a/test/runtests.jl b/test/runtests.jl index 9d5f1aca..03ac33aa 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,5 @@ import Pkg -Pkg.pkg"add JuMP#od/nlp-expr MathOptInterface#master Ipopt#od/nlp-expr" +Pkg.pkg"add JuMP#od/nlp-expr" using PowerModels import InfrastructureModels