Skip to content

Commit

Permalink
JuMP Updates (#40)
Browse files Browse the repository at this point in the history
* update debug models to use two sided constraints
* update packages to latest versions
* update jump models to new NL interface, update jump version lower bound in compat
* update to latest ipopt and moi versions
  • Loading branch information
ccoffrin committed Jan 11, 2024
1 parent 1867107 commit 7e9966a
Show file tree
Hide file tree
Showing 9 changed files with 856 additions and 473 deletions.
901 changes: 617 additions & 284 deletions Manifest.toml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
[compat]
ADNLPModels = "0.7"
Ipopt = "1"
JuMP = "1"
JuMP = "1.15"
Nonconvex = "2"
NonconvexIpopt = "0.4"
Optim = "1"
Optimization = "3"
OptimizationMOI = "0.1"
PowerModels = "0.19"
OptimizationMOI = "0.3"
PowerModels = "0.20"
Symbolics = "5"
2 changes: 0 additions & 2 deletions debug/nlpmodels-jump.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ for (i,branch) in ref[:branch]

# Voltage angle difference limit
@constraint(model, branch["angmin"] <= va_fr - va_to <= branch["angmax"])
#@constraint(model, va_fr - va_to <= branch["angmax"])
#@constraint(model, va_fr - va_to >= branch["angmin"])

# Apparent power limit, from side and to side
@constraint(model, p_fr^2 + q_fr^2 <= branch["rate_a"]^2)
Expand Down
2 changes: 0 additions & 2 deletions debug/nonconvex-jump.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ for (i,branch) in ref[:branch]

# Voltage angle difference limit
@constraint(model, branch["angmin"] <= va_fr - va_to <= branch["angmax"])
#@constraint(model, va_fr - va_to <= branch["angmax"])
#@constraint(model, va_fr - va_to >= branch["angmin"])

# Apparent power limit, from side and to side
@constraint(model, p_fr^2 + q_fr^2 <= branch["rate_a"]^2)
Expand Down
10 changes: 5 additions & 5 deletions jump.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ function solve_opf(file_name)
b_to = branch["b_to"]

# From side of the branch flow
JuMP.@NLconstraint(model, p_fr == (g+g_fr)/ttm*vm_fr^2 + (-g*tr+b*ti)/ttm*(vm_fr*vm_to*cos(va_fr-va_to)) + (-b*tr-g*ti)/ttm*(vm_fr*vm_to*sin(va_fr-va_to)) )
JuMP.@NLconstraint(model, q_fr == -(b+b_fr)/ttm*vm_fr^2 - (-b*tr-g*ti)/ttm*(vm_fr*vm_to*cos(va_fr-va_to)) + (-g*tr+b*ti)/ttm*(vm_fr*vm_to*sin(va_fr-va_to)) )
JuMP.@constraint(model, p_fr == (g+g_fr)/ttm*vm_fr^2 + (-g*tr+b*ti)/ttm*(vm_fr*vm_to*cos(va_fr-va_to)) + (-b*tr-g*ti)/ttm*(vm_fr*vm_to*sin(va_fr-va_to)) )
JuMP.@constraint(model, q_fr == -(b+b_fr)/ttm*vm_fr^2 - (-b*tr-g*ti)/ttm*(vm_fr*vm_to*cos(va_fr-va_to)) + (-g*tr+b*ti)/ttm*(vm_fr*vm_to*sin(va_fr-va_to)) )

# To side of the branch flow
JuMP.@NLconstraint(model, p_to == (g+g_to)*vm_to^2 + (-g*tr-b*ti)/ttm*(vm_to*vm_fr*cos(va_to-va_fr)) + (-b*tr+g*ti)/ttm*(vm_to*vm_fr*sin(va_to-va_fr)) )
JuMP.@NLconstraint(model, q_to == -(b+b_to)*vm_to^2 - (-b*tr+g*ti)/ttm*(vm_to*vm_fr*cos(va_to-va_fr)) + (-g*tr-b*ti)/ttm*(vm_to*vm_fr*sin(va_to-va_fr)) )
JuMP.@constraint(model, p_to == (g+g_to)*vm_to^2 + (-g*tr-b*ti)/ttm*(vm_to*vm_fr*cos(va_to-va_fr)) + (-b*tr+g*ti)/ttm*(vm_to*vm_fr*sin(va_to-va_fr)) )
JuMP.@constraint(model, q_to == -(b+b_to)*vm_to^2 - (-b*tr+g*ti)/ttm*(vm_to*vm_fr*cos(va_to-va_fr)) + (-g*tr-b*ti)/ttm*(vm_to*vm_fr*sin(va_to-va_fr)) )

# Voltage angle difference limit
JuMP.@constraint(model, branch["angmin"] <= va_fr - va_to <= branch["angmax"])
Expand Down Expand Up @@ -116,7 +116,7 @@ function solve_opf(file_name)
solve_time = time() - time_solve_start
total_time = time() - time_data_start

nlp_block = JuMP.MOI.get(model, JuMP.MOI.NLPBlock())
nlp_block = JuMP.MOI.get(JuMP.unsafe_backend(model), JuMP.MOI.NLPBlock())
total_callback_time =
nlp_block.evaluator.eval_objective_timer +
nlp_block.evaluator.eval_objective_gradient_timer +
Expand Down

0 comments on commit 7e9966a

Please sign in to comment.