-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Support for Julia v0.7/v1.0 (#106)
Updates ThreePhasePowerModels to support Julia v0.7/v1.0 in addition to v0.6.
- Loading branch information
1 parent
0bb5c24
commit 1869fe0
Showing
27 changed files
with
234 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
julia 0.6 0.7- | ||
julia 0.6 | ||
|
||
JuMP 0.17 0.19- | ||
PowerModels 0.8.8 0.9- | ||
InfrastructureModels 0.0.4 0.2- | ||
Memento 0.8 | ||
|
||
Compat 1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[deps] | ||
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,104 @@ | ||
# https://stackoverflow.com/questions/39039553/lower-triangular-matrix-in-julia | ||
function vec2utri{T}(v::Vector{T}) | ||
function vec2utri(v::Vector{T}) where T | ||
d = length(v) | ||
n = Int((sqrt(8d+1)+1)/2) | ||
n*(n-1)/2 == d || error("vec2utri: length of vector is not triangular") | ||
[ i<j ? v[Int((j-1)*(j-2)/2)+i] : 0 for i=1:n, j=1:n ] | ||
end | ||
|
||
function vec2ltri{T}(v::Vector{T}) | ||
function vec2ltri(v::Vector{T}) where T | ||
vec2utri(v)' | ||
end | ||
|
||
function mat2utrivec{T}(m::Matrix{T}) | ||
assert(size(m,1) == size(m,2)) | ||
function mat2utrivec(m::Matrix{T}) where T | ||
@assert size(m,1) == size(m,2) | ||
n = size(m,1) | ||
[m[i,j] for i=1:n, j=1:n if i < j] | ||
end | ||
|
||
function mat2ltrivec{T}(m::Matrix{T}) | ||
assert(size(m,1) == size(m,2)) | ||
function mat2ltrivec(m::Matrix{T}) where T | ||
@assert size(m,1) == size(m,2) | ||
n = size(m,1) | ||
[m[j,i] for i=1:n, j=1:n if i < j] | ||
end | ||
|
||
function make_hermitian_matrix_variable(diag, lowertrianglereal, lowertriangleimag) | ||
matrixreal = diagm( diag) + vec2ltri(lowertrianglereal) + vec2utri(lowertrianglereal) | ||
matriximag = diagm(0*diag) + vec2ltri(lowertriangleimag) - vec2utri(lowertriangleimag) | ||
#TODO if not multiplied with 0, array is not a JuMP type | ||
#TODO clean up | ||
matrixreal = [] | ||
if length(diag) == 3 | ||
matrixreal = [ | ||
diag[1] lowertrianglereal[1] lowertrianglereal[2]; | ||
lowertrianglereal[1] diag[2] lowertrianglereal[3]; | ||
lowertrianglereal[2] lowertrianglereal[3] diag[3] | ||
] | ||
elseif length(diag) == 4 | ||
matrixreal = [ | ||
diag[1] lowertrianglereal[1] lowertrianglereal[2] lowertrianglereal[4]; | ||
lowertrianglereal[1] diag[2] lowertrianglereal[3] lowertrianglereal[5]; | ||
lowertrianglereal[2] lowertrianglereal[3] diag[3] lowertrianglereal[6]; | ||
lowertrianglereal[4] lowertrianglereal[5] lowertrianglereal[6] diag[4] | ||
] | ||
elseif length(diag) == 5 | ||
matrixreal = [ | ||
diag[1] lowertrianglereal[1] lowertrianglereal[2] lowertrianglereal[4] lowertrianglereal[7]; | ||
lowertrianglereal[1] diag[2] lowertrianglereal[3] lowertrianglereal[5] lowertrianglereal[8]; | ||
lowertrianglereal[2] lowertrianglereal[3] diag[3] lowertrianglereal[6] lowertrianglereal[9]; | ||
lowertrianglereal[4] lowertrianglereal[5] lowertrianglereal[6] diag[4] lowertrianglereal[10]; | ||
lowertrianglereal[7] lowertrianglereal[8] lowertrianglereal[9] lowertrianglereal[10] diag[5] | ||
] | ||
end | ||
|
||
matriximag = [] | ||
if length(diag) == 3 | ||
matriximag = [ | ||
0 -lowertriangleimag[1] -lowertriangleimag[2]; | ||
lowertriangleimag[1] 0 -lowertriangleimag[3]; | ||
lowertriangleimag[2] lowertriangleimag[3] 0 | ||
] | ||
elseif length(diag) == 4 | ||
matriximag = [ | ||
0 -lowertriangleimag[1] -lowertriangleimag[2] -lowertriangleimag[4]; | ||
lowertriangleimag[1] 0 -lowertriangleimag[3] -lowertriangleimag[5]; | ||
lowertriangleimag[2] lowertriangleimag[3] 0 -lowertriangleimag[6]; | ||
lowertriangleimag[4] lowertriangleimag[5] lowertriangleimag[6] 0 | ||
] | ||
elseif length(diag) == 5 | ||
matriximag = [ | ||
0 -lowertriangleimag[1] -lowertriangleimag[2] -lowertriangleimag[4] -lowertriangleimag[7]; | ||
lowertriangleimag[1] 0 -lowertriangleimag[3] -lowertriangleimag[5] -lowertriangleimag[8]; | ||
lowertriangleimag[2] lowertriangleimag[3] 0 -lowertriangleimag[6] -lowertriangleimag[9]; | ||
lowertriangleimag[4] lowertriangleimag[5] lowertriangleimag[6] 0 -lowertriangleimag[10]; | ||
lowertriangleimag[7] lowertriangleimag[8] lowertriangleimag[9] lowertriangleimag[10] 0 | ||
] | ||
end | ||
return matrixreal, matriximag | ||
end | ||
|
||
function make_full_matrix_variable(diag, lowertriangle, uppertriangle) | ||
matrix = diagm(diag) + vec2ltri(lowertriangle) + vec2utri(uppertriangle) | ||
#TODO clean up | ||
matrix = [] | ||
if length(diag) == 3 | ||
matrix = [ | ||
diag[1] uppertriangle[1] uppertriangle[2]; | ||
lowertriangle[1] diag[2] uppertriangle[3]; | ||
lowertriangle[2] lowertriangle[3] diag[3] | ||
] | ||
elseif length(diag) == 4 | ||
matrix = [ | ||
diag[1] uppertriangle[1] uppertriangle[2] uppertriangle[4]; | ||
lowertriangle[1] diag[2] uppertriangle[3] uppertriangle[5]; | ||
lowertriangle[2] lowertriangle[3] diag[3] uppertriangle[6]; | ||
lowertriangle[4] lowertriangle[5] lowertriangle[6] diag[4] | ||
] | ||
elseif length(diag) == 5 | ||
matrix = [ | ||
diag[1] uppertriangle[1] uppertriangle[2] uppertriangle[4] uppertriangle[7]; | ||
lowertriangle[1] diag[2] uppertriangle[3] uppertriangle[5] uppertriangle[8]; | ||
lowertriangle[2] lowertriangle[3] diag[3] uppertriangle[6] uppertriangle[9]; | ||
lowertriangle[4] lowertriangle[5] lowertriangle[6] diag[4] uppertriangle[10] | ||
lowertriangle[7] lowertriangle[8] lowertriangle[9] lowertriangle[10] diag[5] | ||
] | ||
end | ||
# matrix = diagm(0 => diag) + vec2ltri(lowertriangle) + vec2utri(uppertriangle) | ||
return matrix | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.