Skip to content

Commit 00736fe

Browse files
committed
Update with upstream changes in MOI
1 parent 7a90ad8 commit 00736fe

File tree

6 files changed

+17
-201
lines changed

6 files changed

+17
-201
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Manifest.toml

Diff for: .travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ julia:
77
- 1
88
notifications:
99
email: false
10+
-before_script:
11+
- julia -e 'using Pkg; Pkg.add(PackageSpec(name="MathOptInterface", rev="bl/complex_operations"))'

Diff for: Manifest.toml

-182
This file was deleted.

Diff for: Project.toml

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ version = "0.0.1"
77
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
88
MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
99

10+
[compat]
11+
MathOptInterface = "0.9.17"
12+
MutableArithmetics = "0.2.10"
13+
julia = "1"
14+
1015
[extras]
1116
CSDP = "0a46da34-8e4b-519e-b418-48813639ff34"
1217
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

Diff for: src/Bridges/Constraint/Constraint.jl

+4-1
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

Diff for: src/Bridges/Constraint/split_zero.jl

+5-18
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
real::MOI.ConstraintIndex{F, MOI.Zeros}
183
imag::MOI.ConstraintIndex{F, MOI.Zeros}
@@ -22,11 +7,12 @@ function MOI.Bridges.Constraint.bridge_constraint(
227
f::G,
238
set::MOI.Zeros
249
) where {T, F, G}
25-
real_con = MOI.add_constraint(model, operate_coefficients(real, T, f), set)
26-
imag_con = MOI.add_constraint(model, operate_coefficients(imag, T, f), set)
10+
real_con = MOI.add_constraint(model, real(f), set)
11+
imag_con = MOI.add_constraint(model, MOI.Utilities.operate(imag, T, f), set)
2712
return SplitZeroBridge{T, F, G}(real_con, imag_con)
2813
end
2914

15+
# We don't support `MOI.VectorOfVariables` as it would be a self-loop in the bridge graph
3016
function MOI.supports_constraint(
3117
::Type{SplitZeroBridge{T}}, ::Type{<:MOI.Utilities.TypedLike{Complex{T}}},
3218
::Type{MOI.Zeros}) where T
@@ -39,7 +25,8 @@ end
3925
function MOI.Bridges.Constraint.concrete_bridge_type(
4026
::Type{<:SplitZeroBridge{T}}, G::Type{<:MOI.Utilities.TypedLike},
4127
::Type{MOI.Zeros}) where T
42-
return SplitZeroBridge{T, similar_type(G, T), G}
28+
F = MA.promote_operation(imag, G)
29+
return SplitZeroBridge{T, F, G}
4330
end
4431

4532
# Attributes, Bridge acting as a model

0 commit comments

Comments
 (0)