Skip to content

Commit 4371f68

Browse files
authored
Update with upstream changes in MOI (#2)
* Update with upstream changes in MOI * Update CI script with MOI v0.9.18
1 parent e98935d commit 4371f68

File tree

5 files changed

+11
-202
lines changed

5 files changed

+11
-202
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Manifest.toml

Manifest.toml

Lines changed: 0 additions & 182 deletions
This file was deleted.

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
99
MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
1010

1111
[compat]
12-
MathOptInterface = "0.9.17"
12+
MathOptInterface = "0.9.18"
1313
MutableArithmetics = "0.2.10"
1414
julia = "1"
1515

src/Bridges/Constraint/Constraint.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module Constraint
22

3-
using MathOptInterface
3+
import MutableArithmetics
4+
const MA = MutableArithmetics
5+
6+
import MathOptInterface
47
const MOI = MathOptInterface
58
const MOIU = MOI.Utilities
69
const MOIB = MOI.Bridges

src/Bridges/Constraint/split_zero.jl

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
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-
161
struct SplitZeroBridge{T, F<:MOI.Utilities.TypedLike{T}, G<:MOI.Utilities.TypedLike{Complex{T}}} <: MOI.Bridges.Constraint.AbstractBridge
172
dimension::Int
183
constraint::MOI.ConstraintIndex{F, MOI.Zeros}
@@ -27,8 +12,8 @@ function MOI.Bridges.Constraint.bridge_constraint(
2712
f::G,
2813
set::MOI.Zeros
2914
) 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)
3217
real_indices = _nonzero_indices(real_part)
3318
imag_indices = _nonzero_indices(imag_part)
3419
func = MOIU.operate(
@@ -40,6 +25,7 @@ function MOI.Bridges.Constraint.bridge_constraint(
4025
return SplitZeroBridge{T, F, G}(MOI.dimension(set), constraint, real_indices, imag_indices)
4126
end
4227

28+
# We don't support `MOI.VectorOfVariables` as it would be a self-loop in the bridge graph
4329
function MOI.supports_constraint(
4430
::Type{SplitZeroBridge{T}}, ::Type{<:MOI.Utilities.TypedLike{Complex{T}}},
4531
::Type{MOI.Zeros}) where T
@@ -52,7 +38,8 @@ end
5238
function MOI.Bridges.Constraint.concrete_bridge_type(
5339
::Type{<:SplitZeroBridge{T}}, G::Type{<:MOI.Utilities.TypedLike},
5440
::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}
5643
end
5744

5845
# Attributes, Bridge acting as a model

0 commit comments

Comments
 (0)