Skip to content

Commit

Permalink
Update to latest JuMP PR
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Jun 28, 2023
1 parent 5b16199 commit c4538bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
21 changes: 6 additions & 15 deletions src/core/objective.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit c4538bb

Please sign in to comment.