jump-dev / ComplexOptInterface.jl
Showing 1 of 3 files from the diff.
Other files ignored by Codecov
test/jump.jl has changed.
README.md has changed.

@@ -7,6 +7,33 @@
Loading
7 7
    return JuMP.add_bridge(model, Bridges.Constraint.SplitZeroBridge)
8 8
end
9 9
10 +
struct ComplexPlane end
11 +
12 +
struct ComplexVariable{S,T,U,V} <: JuMP.AbstractVariable
13 +
    info::JuMP.VariableInfo{S,T,U,V}
14 +
end
15 +
16 +
function JuMP.build_variable(::Function, v::JuMP.ScalarVariable, ::ComplexPlane)
17 +
    return ComplexVariable(v.info)
18 +
end
19 +
20 +
function JuMP.add_variable(
21 +
    model::JuMP.Model,
22 +
    v::ComplexVariable,
23 +
    name::String = "",
24 +
)
25 +
    model.is_model_dirty = true
26 +
    var = JuMP.ScalarVariable(v.info)
27 +
    real_part = JuMP.add_variable(model, _real(var), _real(name))
28 +
    imag_part = JuMP.add_variable(model, _imag(var), _imag(name))
29 +
    # Efficiently build `real_part + imag_part * im`
30 +
    return JuMP.GenericAffExpr{ComplexF64,JuMP.VariableRef}(
31 +
        zero(ComplexF64),
32 +
        real_part => one(ComplexF64),
33 +
        imag_part => convert(ComplexF64, im),
34 +
    )
35 +
end
36 +
10 37
struct HermitianPSDCone end
11 38
12 39
struct HermitianMatrixShape <: JuMP.AbstractShape
@@ -64,8 +91,8 @@
Loading
64 91
    )
65 92
end
66 93
67 -
_real(s::String) = s
68 -
_imag(s::String) = s
94 +
_real(s::String) = string("real(", s, ")")
95 +
_imag(s::String) = string("imag(", s, ")")
69 96
70 97
_real(v::JuMP.ScalarVariable) = _mapinfo(real, v)
71 98
_imag(v::JuMP.ScalarVariable) = _mapinfo(imag, v)
Files Coverage
src 58.70%
Project Totals (5 files) 58.70%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading