Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for skew-symmetric matrix variables #2146

Closed
frederikgeth opened this issue Jan 31, 2020 · 2 comments · Fixed by #2416
Closed

Support for skew-symmetric matrix variables #2146

frederikgeth opened this issue Jan 31, 2020 · 2 comments · Fixed by #2416

Comments

@frederikgeth
Copy link

I contribute to PowerModelsDistribution. Ideally, we would like to use JuMP's support for matrix variables with symmetry more broadly.

As we start from a complex-value problem with Hermitian matrix variables, we would love to see support for both symmetric (real part) and skew-symmetric (imaginary part) matrix variables. We have a work-around, but the printing of the variables looks different from other variables.

We can do something like the following to make sets of full and symmetric matrix variables:

Dict(i => JuMP.@variable(pm.model,
            [c in 1:N, d in 1:N], base_name="P_$(i)",
        ) for i in ids  )
Dict(i => JuMP.@variable(pm.model,
            [c in 1:N, d in 1:N], base_name="Wr_$(i)", Symmetric
        ) for i in ids  )

but the following is not supported:

Dict(i => JuMP.@variable(pm.model,
            [c in 1:N, d in 1:N], base_name="Wi_$(i)", SkewSymmetric
        ) for i in ids  )

Ideally, this would have (support for) zeros on the diagonal as well.

After some preliminary digging, it seems Julia does not have skew symmetric matrix variable primitives (https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#Special-matrices-1, somewhat related discussion in JuliaLang/LinearAlgebra.jl#417)

@blegat
Copy link
Member

blegat commented Feb 1, 2020

The proper way would be to define a SkewMatrixSpace similar to
https://github.com/JuliaOpt/JuMP.jl/blob/master/src/sd.jl#L1
and a SkewMatrixShape similar to
https://github.com/JuliaOpt/JuMP.jl/blob/master/src/sd.jl#L76
and a build_variable similar to
https://github.com/JuliaOpt/JuMP.jl/blob/master/src/sd.jl#L163
So that the user can do

@variable(model, x[1:3, 1:3] in SkewMatrixSpace()) 

@frederikgeth
Copy link
Author

Thanks, @blegat, those pointers helped a lot. I found a way to make it work in PR #2147.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants