jump-dev / ComplexOptInterface.jl
Showing 2 of 5 files from the diff.

@@ -1,18 +1,3 @@
Loading
1 -
function operate_coefficient(f, T::Type, term::MOI.ScalarAffineTerm)
2 -
    MOI.ScalarAffineTerm(f(term.coefficient), term.variable_index)
3 -
end
4 -
function operate_coefficient(f, T::Type, term::MOI.VectorAffineTerm)
5 -
    return MOI.VectorAffineTerm(term.output_index, operate_coefficient(f, T, term.scalar_term))
6 -
end
7 -
function operate_coefficients(f, T::Type, func::MOI.VectorAffineFunction)
8 -
    return MOI.VectorAffineFunction(
9 -
        [operate_coefficient(f, T, term) for term in func.terms],
10 -
        map(f, func.constants)
11 -
    )
12 -
end
13 -
14 -
similar_type(::Type{<:MOI.VectorAffineFunction}, T::Type) = MOI.VectorAffineFunction{T}
15 -
16 1
struct SplitZeroBridge{T, F<:MOI.Utilities.TypedLike{T}, G<:MOI.Utilities.TypedLike{Complex{T}}} <: MOI.Bridges.Constraint.AbstractBridge
17 2
    dimension::Int
18 3
    constraint::MOI.ConstraintIndex{F, MOI.Zeros}
@@ -27,8 +12,8 @@
Loading
27 12
    f::G,
28 13
    set::MOI.Zeros
29 14
) where {T, F, G}
30 -
    real_part = operate_coefficients(real, T, f)
31 -
    imag_part = operate_coefficients(imag, T, f)
15 +
    real_part = real(f)
16 +
    imag_part = MOI.Utilities.operate(imag, T, f)
32 17
    real_indices = _nonzero_indices(real_part)
33 18
    imag_indices = _nonzero_indices(imag_part)
34 19
    func = MOIU.operate(
@@ -40,6 +25,7 @@
Loading
40 25
    return SplitZeroBridge{T, F, G}(MOI.dimension(set), constraint, real_indices, imag_indices)
41 26
end
42 27
28 +
# We don't support `MOI.VectorOfVariables` as it would be a self-loop in the bridge graph
43 29
function MOI.supports_constraint(
44 30
    ::Type{SplitZeroBridge{T}}, ::Type{<:MOI.Utilities.TypedLike{Complex{T}}},
45 31
    ::Type{MOI.Zeros}) where T
@@ -52,7 +38,8 @@
Loading
52 38
function MOI.Bridges.Constraint.concrete_bridge_type(
53 39
    ::Type{<:SplitZeroBridge{T}}, G::Type{<:MOI.Utilities.TypedLike},
54 40
    ::Type{MOI.Zeros}) where T
55 -
    return SplitZeroBridge{T, similar_type(G, T), G}
41 +
    F = MA.promote_operation(imag, G)
42 +
    return SplitZeroBridge{T, F, G}
56 43
end
57 44
58 45
# Attributes, Bridge acting as a model

@@ -1,6 +1,9 @@
Loading
1 1
module Constraint
2 2
3 -
using MathOptInterface
3 +
import MutableArithmetics
4 +
const MA = MutableArithmetics
5 +
6 +
import MathOptInterface
4 7
const MOI = MathOptInterface
5 8
const MOIU = MOI.Utilities
6 9
const MOIB = MOI.Bridges
Files Coverage
src 76.67%
Project Totals (6 files) 76.67%
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