Skip to content

Commit

Permalink
JuMP v0.19 / MathOptInterface Update (#137)
Browse files Browse the repository at this point in the history
* UPD: MOI 0.8.1 and JuMP 0.19-beta2 compatibility

Change `using JuMP` to `import JuMP`

* `norm(x) <= t` --> `[t, x...] in SecondOrderCone()`
* `lowerbound`, `upperbound`, and `basename` in `@variable` to `lower_bound`, `upper_bound`, and `base_name`, respectively.
* `setupperbound` --> `set_upper_bound`
* `setlowerbound` --> `set_lower_bound`

Update one test, probably due to numerical instability from optimizer change.

* REF: Remove support for Julia < v1.0

changes to use `import` instead of `using`

removes all reverse compatibility code for julia versions lower than v1.0

adds unit testing on julia 1.1 and nightly (allowed failure)

removes compat (no longer required)

* UPD: add Juniper to manifest

* UPD: manifest.toml

* UPD: ACR to moi

* FIX: relax atol for numerical stability on linux tests

* UPD: Pkg3 syntax

updates to package 3 syntax

* UPD: Pkg3 syntax

* UPD: Version bump

* UPD: Changelog, manifest, travis

* UPD: InfrastructureModels version bound / Manifest

* FIX: missed conflict during rebase

* FIX: docs build

* FIX: jump syntax update on transformers

* FIX: PowerModels in manifest

* UPD: project.toml updates and NFAForm addition

* UPD: manifest.toml for powermodels v0.10

* FIX: `JuMP.getvalue` depeciated -> `JuMP.value`

* FIX: failing storage multinetwork test
  • Loading branch information
pseudocubic authored May 14, 2019
1 parent 451a86e commit 952b966
Show file tree
Hide file tree
Showing 17 changed files with 131 additions and 135 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ ThreePhasePowerModels.jl Change Log
### staged
- nothing

### v0.3.0
- Update to JuMP v0.19/MathOptInterface

### v0.2.1
- Add transformer support to active power only models
- Fix bug in source_ids of new components created for transformer support
Expand Down
40 changes: 17 additions & 23 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee"
version = "0.8.10"

[[BinaryProvider]]
deps = ["Libdl", "Pkg", "SHA", "Test"]
git-tree-sha1 = "055eb2690182ebc31087859c3dd8598371d3ef9e"
deps = ["Libdl", "SHA"]
git-tree-sha1 = "c7361ce8a2129f20b0e05a89f7070820cfed6648"
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
version = "0.5.3"
version = "0.5.4"

[[Calculus]]
deps = ["Compat"]
Expand Down Expand Up @@ -76,10 +76,10 @@ uuid = "f6369f11-7733-5829-9624-2563aa707210"
version = "0.10.3"

[[InfrastructureModels]]
deps = ["Compat", "JuMP", "LinearAlgebra", "Memento", "Random", "Test"]
git-tree-sha1 = "7e123cb8dd591c6e5aa90885fbce41d34cc8ed0c"
deps = ["JuMP", "Memento"]
git-tree-sha1 = "ec3f1ba27dbfd29a93f3c520ee189ce32deec049"
uuid = "2030c09a-7f63-5d83-885d-db604e0e9cc0"
version = "0.0.14"
version = "0.2.0"

[[InteractiveUtils]]
deps = ["Markdown"]
Expand All @@ -92,10 +92,10 @@ uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.20.0"

[[JuMP]]
deps = ["Calculus", "Compat", "ForwardDiff", "Libdl", "MathProgBase", "Pkg", "ReverseDiffSparse", "Serialization"]
git-tree-sha1 = "3bd8e52f7aeb2736a8e1b0d8ae8d01c2c85fea24"
deps = ["Calculus", "DataStructures", "ForwardDiff", "LinearAlgebra", "MathOptInterface", "NaNMath", "Random", "SparseArrays", "Statistics"]
git-tree-sha1 = "5df42febdee8ac7db9de66c712e439a6ff06459d"
uuid = "4076af6c-e467-56ae-b986-b466b2749572"
version = "0.18.5"
version = "0.19.1"

[[LibGit2]]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
Expand All @@ -114,11 +114,11 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[MathProgBase]]
deps = ["Compat"]
git-tree-sha1 = "3bf2e534e635df810e5f4b4f1a8b6de9004a0d53"
uuid = "fdba3010-5040-5b88-9595-932c9decdf73"
version = "0.7.7"
[[MathOptInterface]]
deps = ["Compat", "Unicode"]
git-tree-sha1 = "5d3de69c9220610d0336ab45d3eb8b6ac7a7c807"
uuid = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
version = "0.8.4"

[[Memento]]
deps = ["Dates", "Distributed", "JSON", "Serialization", "Sockets", "Syslogs", "Test", "TimeZones", "UUIDs"]
Expand Down Expand Up @@ -158,10 +158,10 @@ deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUID
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[PowerModels]]
deps = ["InfrastructureModels", "JSON", "JuMP", "LinearAlgebra", "Memento", "SparseArrays"]
git-tree-sha1 = "5b463afe0411913338991157bfb3c953346c77bd"
deps = ["InfrastructureModels", "JSON", "JuMP", "LinearAlgebra", "MathOptInterface", "Memento", "SparseArrays"]
git-tree-sha1 = "07ab528b4c9316a17cdd8d207f260c11efa6688d"
uuid = "c36e90e8-916a-50a6-bd94-075b64ef4655"
version = "0.9.6"
version = "0.10.0"

[[Printf]]
deps = ["Unicode"]
Expand All @@ -175,12 +175,6 @@ uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[ReverseDiffSparse]]
deps = ["Calculus", "Compat", "DataStructures", "ForwardDiff", "MathProgBase", "NaNMath"]
git-tree-sha1 = "cbbc2c710abea5cfe71459ce4711d80a212aac5a"
uuid = "89212889-6d3f-5f97-b412-7825138f6c9c"
version = "0.8.6"

[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"

Expand Down
21 changes: 10 additions & 11 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@ name = "ThreePhasePowerModels"
uuid = "8503087a-994b-5095-bd6e-f54267f2dd19"
authors = ["David M Fobes <[email protected]>", "Carleton Coffrin"]
repo = "https://github.com/lanl-ansi/ThreePhasePowerModels.jl.git"
version = "0.2.1"
version = "0.3.0"

[deps]
InfrastructureModels = "2030c09a-7f63-5d83-885d-db604e0e9cc0"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9"
PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655"

[compat]
# Cbc = ">= 0.4"
InfrastructureModels = "< 0.2"
# Ipopt = ">= 0.4"
JuMP = "< 0.19"
# Juniper = "< 0.4"
Cbc = ">= 0.4"
InfrastructureModels = "^0.2"
Ipopt = ">= 0.4"
JuMP = "^0.19.1"
Juniper = ">= 0.4"
Memento = ">= 0.8, < 0.13"
# Pavito = ">= 0.1.1"
PowerModels = "^0.9"
# SCS = ">= 0.4.1"
PowerModels = "^0.10"
SCS = ">= 0.4"
julia = "^1"

[extras]
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9"
Juniper = "2ddba703-00a4-53a7-87a5-e8b9971dde84"
Pavito = "cd433a01-47d1-575d-afb7-6db927ee8d8f"
SCS = "c946c3f1-0d1f-5ce8-9dea-7daa1f7e2d13"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Cbc", "Ipopt", "Juniper", "Pavito", "SCS", "Test"]
test = ["Cbc", "Ipopt", "Juniper", "SCS", "Test"]
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
InfrastructureModels = "2030c09a-7f63-5d83-885d-db604e0e9cc0"
PowerModels = "c36e90e8-916a-50a6-bd94-075b64ef4655"
3 changes: 1 addition & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ using Documenter, ThreePhasePowerModels

makedocs(
modules = [ThreePhasePowerModels],
format = :html,
format = Documenter.HTML(analytics = ""),
sitename = "ThreePhasePowerModels",
authors = "Carleton Coffrin, David Fobes, Frederik Geth and contributors.",
analytics = "",
pages = [
"Home" => "index.md",
"Manual" => [
Expand Down
6 changes: 3 additions & 3 deletions src/core/relaxation_scheme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function relaxation_psd_to_soc_real_conic(m, mx)
n_elements = size(mx,1)
for i in 1:n_elements-1
for j in i+1:n_elements
JuMP.@constraint(m, norm([2*mx[i,j], mx[i,i]-mx[j,j]]) <= mx[i,i]+mx[j,j])
JuMP.@constraint(m, [mx[i,i]+mx[j,j], 2*mx[i,j], mx[i,i]-mx[j,j]] in JuMP.SecondOrderCone())
end
end
end
Expand All @@ -93,7 +93,7 @@ function relaxation_psd_to_soc_complex_conic(m, mxreal, mximag)
n_elements = size(mxreal,1)
for i in 1:n_elements-1
for j in i+1:n_elements
JuMP.@constraint(m, norm([2*mxreal[i,j], 2*mximag[i,j], mxreal[i,i]-mxreal[j,j]]) <= mxreal[i,i]+mxreal[j,j])
JuMP.@constraint(m, [mxreal[i,i]+mxreal[j,j], 2*mxreal[i,j], 2*mximag[i,j], mxreal[i,i]-mxreal[j,j]] in JuMP.SecondOrderCone())
end
end
end
Expand Down Expand Up @@ -171,6 +171,6 @@ function relaxation_psd_to_psd_real(m, mxreal, mximag; ndim=3)
j = i+(ndim-1)
mr = mxreal[i:j, i:j]
mi = mximag[i:j, i:j]
JuMP.@SDconstraint(m, [mr -mi; mi mr] >=0)
JuMP.@constraint(m, [mr -mi; mi mr] in JuMP.PSDCone())
end
end
52 changes: 26 additions & 26 deletions src/core/variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ function variable_tp_voltage_magnitude_sqr(pm::PMs.GenericPowerModel; nw::Int=pm

if bounded
W = PMs.var(pm, nw)[:w] = JuMP.@variable(pm.model,
[i in bus_cnd], basename="$(nw)_w",
lowerbound = PMs.ref(pm, nw, :bus, i[1], "vmin", i[2])^2,
upperbound = PMs.ref(pm, nw, :bus, i[1], "vmax", i[2])^2,
[i in bus_cnd], base_name="$(nw)_w",
lower_bound = PMs.ref(pm, nw, :bus, i[1], "vmin", i[2])^2,
upper_bound = PMs.ref(pm, nw, :bus, i[1], "vmax", i[2])^2,
start = PMs.getval(PMs.ref(pm, nw, :bus, i[1]), "w_start", i[2], 1.001)
)
else
W = PMs.var(pm, nw)[:w] = JuMP.@variable(pm.model,
[i in bus_cnd], basename="$(nw)_w",
lowerbound = 0,
[i in bus_cnd], base_name="$(nw)_w",
lower_bound = 0,
start = PMs.getval(PMs.ref(pm, nw, :bus, i[1]), "w_start", i[2], 1.001)
)
end
Expand All @@ -57,36 +57,36 @@ function variable_tp_voltage_product(pm::PMs.GenericPowerModel; nw::Int=pm.cnw,
append!(bus_cnd, bp_cndf_cndt)

WR = PMs.var(pm, nw)[:wr] = JuMP.@variable(pm.model,
[b in bus_cnd], basename="$(nw)_wr",
[b in bus_cnd], base_name="$(nw)_wr",
start = PMs.getval(b[1] != b[2] ? PMs.ref(pm, nw, :buspairs, b[1:2]) : PMs.ref(pm, nw, :bus, b[1]), "wr_start", b[3], 1.0)
)

WI = PMs.var(pm, nw)[:wi] = JuMP.@variable(pm.model,
[b in bus_cnd], basename="$(nw)_wi",
[b in bus_cnd], base_name="$(nw)_wi",
start = PMs.getval(b[1] != b[2] ? PMs.ref(pm, nw, :buspairs, b[1:2]) : PMs.ref(pm, nw, :bus, b[1]), "wi_start", b[3])
)

if bounded
# Diagonal bounds
wr_min, wr_max, wi_min, wi_max = PMs.calc_voltage_product_bounds(PMs.ref(pm, nw, :buspairs), cnd)
for (i, j) in PMs.ids(pm, nw, :buspairs)
PMs.JuMP.setupperbound(WR[(i, j, cnd, cnd)], wr_max[(i,j)])
PMs.JuMP.setupperbound(WI[(i, j, cnd, cnd)], wi_max[(i,j)])
JuMP.set_upper_bound(WR[(i, j, cnd, cnd)], wr_max[(i,j)])
JuMP.set_upper_bound(WI[(i, j, cnd, cnd)], wi_max[(i,j)])

JuMP.setlowerbound(WR[(i, j, cnd, cnd)], wr_min[(i,j)])
JuMP.setlowerbound(WI[(i, j, cnd, cnd)], wi_min[(i,j)])
JuMP.set_lower_bound(WR[(i, j, cnd, cnd)], wr_min[(i,j)])
JuMP.set_lower_bound(WI[(i, j, cnd, cnd)], wi_min[(i,j)])
end

# Off-diagonal bounds
for c in PMs.conductor_ids(pm)
if c != cnd
wr_min, wr_max, wi_min, wi_max = calc_tp_voltage_product_bounds(pm, bus_cnd)
for k in bus_cnd
PMs.JuMP.setupperbound(WR[k], wr_max[k])
PMs.JuMP.setupperbound(WI[k], wi_max[k])
JuMP.set_upper_bound(WR[k], wr_max[k])
JuMP.set_upper_bound(WI[k], wi_max[k])

JuMP.setlowerbound(WR[k], wr_min[k])
JuMP.setlowerbound(WI[k], wi_min[k])
JuMP.set_lower_bound(WR[k], wr_min[k])
JuMP.set_lower_bound(WI[k], wi_min[k])
end
end
end
Expand Down Expand Up @@ -123,7 +123,7 @@ end
""
function variable_active_bus_power_slack(pm::PMs.GenericPowerModel; nw::Int=pm.cnw, cnd::Int=pm.ccnd)
PMs.var(pm, nw, cnd)[:p_slack] = JuMP.@variable(pm.model,
[i in PMs.ids(pm, nw, :bus)], basename="$(nw)_$(cnd)_p_slack",
[i in PMs.ids(pm, nw, :bus)], base_name="$(nw)_$(cnd)_p_slack",
start = PMs.getval(PMs.ref(pm, nw, :bus, i), "p_slack_start", cnd)
)
end
Expand All @@ -132,7 +132,7 @@ end
""
function variable_reactive_bus_power_slack(pm::PMs.GenericPowerModel; nw::Int=pm.cnw, cnd::Int=pm.ccnd)
PMs.var(pm, nw, cnd)[:q_slack] = JuMP.@variable(pm.model,
[i in PMs.ids(pm, nw, :bus)], basename="$(nw)_$(cnd)_q_slack",
[i in PMs.ids(pm, nw, :bus)], base_name="$(nw)_$(cnd)_q_slack",
start = PMs.getval(PMs.ref(pm, nw, :bus, i), "q_slack_start", cnd)
)
end
Expand All @@ -149,16 +149,16 @@ function variable_tp_trans_active_flow(pm::PMs.GenericPowerModel; nw::Int=pm.cnw
for cnd in PMs.conductor_ids(pm)
PMs.var(pm, nw, cnd)[:pt] = JuMP.@variable(pm.model,
[(l,i,j) in PMs.ref(pm, nw, :arcs_trans)],
basename="$(nw)_$(cnd)_p_trans",
base_name="$(nw)_$(cnd)_p_trans",
start=0
)
if bounded
for arc in PMs.ref(pm, nw, :arcs_trans)
tr_id = arc[1]
flow_lb = -PMs.ref(pm, nw, :trans, tr_id, "rate_a")[cnd]
flow_ub = PMs.ref(pm, nw, :trans, tr_id, "rate_a")[cnd]
JuMP.setlowerbound(PMs.var(pm, nw, cnd, :pt, arc), flow_lb)
JuMP.setupperbound(PMs.var(pm, nw, cnd, :pt, arc), flow_ub)
JuMP.set_lower_bound(PMs.var(pm, nw, cnd, :pt, arc), flow_lb)
JuMP.set_upper_bound(PMs.var(pm, nw, cnd, :pt, arc), flow_ub)
end
end
end
Expand All @@ -170,16 +170,16 @@ function variable_tp_trans_reactive_flow(pm::PMs.GenericPowerModel; nw::Int=pm.c
for cnd in PMs.conductor_ids(pm)
PMs.var(pm, nw, cnd)[:qt] = JuMP.@variable(pm.model,
[(l,i,j) in PMs.ref(pm, nw, :arcs_trans)],
basename="$(nw)_$(cnd)_q_trans",
base_name="$(nw)_$(cnd)_q_trans",
start=0
)
if bounded
for arc in PMs.ref(pm, nw, :arcs_trans)
tr_id = arc[1]
flow_lb = -PMs.ref(pm, nw, :trans, tr_id, "rate_a")[cnd]
flow_ub = PMs.ref(pm, nw, :trans, tr_id, "rate_a")[cnd]
JuMP.setlowerbound(PMs.var(pm, nw, cnd, :qt, arc), flow_lb)
JuMP.setupperbound(PMs.var(pm, nw, cnd, :qt, arc), flow_ub)
JuMP.set_lower_bound(PMs.var(pm, nw, cnd, :qt, arc), flow_lb)
JuMP.set_upper_bound(PMs.var(pm, nw, cnd, :qt, arc), flow_ub)
end
end
end
Expand All @@ -193,13 +193,13 @@ function variable_tp_oltc_tap(pm::PMs.GenericPowerModel; nw::Int=pm.cnw, bounded
for c in 1:nphases
PMs.var(pm, nw, c)[:tap] = JuMP.@variable(pm.model,
[i in oltc_ids],
basename="$(nw)_tm",
base_name="$(nw)_tm",
start=PMs.ref(pm, nw, :trans, i, "tm")[c]
)
if bounded
for tr_id in oltc_ids
JuMP.setlowerbound(PMs.var(pm, nw, c)[:tap][tr_id], PMs.ref(pm, nw, :trans, tr_id, "tm_min")[c])
JuMP.setupperbound(PMs.var(pm, nw, c)[:tap][tr_id], PMs.ref(pm, nw, :trans, tr_id, "tm_max")[c])
JuMP.set_lower_bound(PMs.var(pm, nw, c)[:tap][tr_id], PMs.ref(pm, nw, :trans, tr_id, "tm_min")[c])
JuMP.set_upper_bound(PMs.var(pm, nw, c)[:tap][tr_id], PMs.ref(pm, nw, :trans, tr_id, "tm_max")[c])
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/form/acr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ function variable_tp_voltage(pm::PMs.GenericPowerModel{T}; kwargs...) where T <:
vr = vm*cos(theta[c])
vi = vm*sin(theta[c])
for id in PMs.ids(pm, :bus)
JuMP.setvalue(PMs.var(pm, pm.cnw, c, :vr, id), vr)
JuMP.setvalue(PMs.var(pm, pm.cnw, c, :vi, id), vi)
JuMP.set_start_value(PMs.var(pm, pm.cnw, c, :vr, id), vr)
JuMP.set_start_value(PMs.var(pm, pm.cnw, c, :vi, id), vi)
end
end
end
Expand Down
Loading

2 comments on commit 952b966

@pseudocubic
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/741

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.0 -m "<description of version>" 952b9663814ae05c5730bf7af89428b80ac5cf31
git push origin v0.3.0

Please sign in to comment.