Skip to content

Update with upstream changes in MOI #2

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

Merged
merged 2 commits into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Manifest.toml
182 changes: 0 additions & 182 deletions Manifest.toml

This file was deleted.

2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"

[compat]
MathOptInterface = "0.9.17"
MathOptInterface = "0.9.18"
MutableArithmetics = "0.2.10"
julia = "1"

Expand Down
5 changes: 4 additions & 1 deletion src/Bridges/Constraint/Constraint.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module Constraint

using MathOptInterface
import MutableArithmetics
const MA = MutableArithmetics

import MathOptInterface
const MOI = MathOptInterface
const MOIU = MOI.Utilities
const MOIB = MOI.Bridges
Expand Down
23 changes: 5 additions & 18 deletions src/Bridges/Constraint/split_zero.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
function operate_coefficient(f, T::Type, term::MOI.ScalarAffineTerm)
MOI.ScalarAffineTerm(f(term.coefficient), term.variable_index)
end
function operate_coefficient(f, T::Type, term::MOI.VectorAffineTerm)
return MOI.VectorAffineTerm(term.output_index, operate_coefficient(f, T, term.scalar_term))
end
function operate_coefficients(f, T::Type, func::MOI.VectorAffineFunction)
return MOI.VectorAffineFunction(
[operate_coefficient(f, T, term) for term in func.terms],
map(f, func.constants)
)
end

similar_type(::Type{<:MOI.VectorAffineFunction}, T::Type) = MOI.VectorAffineFunction{T}

struct SplitZeroBridge{T, F<:MOI.Utilities.TypedLike{T}, G<:MOI.Utilities.TypedLike{Complex{T}}} <: MOI.Bridges.Constraint.AbstractBridge
dimension::Int
constraint::MOI.ConstraintIndex{F, MOI.Zeros}
Expand All @@ -27,8 +12,8 @@ function MOI.Bridges.Constraint.bridge_constraint(
f::G,
set::MOI.Zeros
) where {T, F, G}
real_part = operate_coefficients(real, T, f)
imag_part = operate_coefficients(imag, T, f)
real_part = real(f)
imag_part = MOI.Utilities.operate(imag, T, f)
real_indices = _nonzero_indices(real_part)
imag_indices = _nonzero_indices(imag_part)
func = MOIU.operate(
Expand All @@ -40,6 +25,7 @@ function MOI.Bridges.Constraint.bridge_constraint(
return SplitZeroBridge{T, F, G}(MOI.dimension(set), constraint, real_indices, imag_indices)
end

# We don't support `MOI.VectorOfVariables` as it would be a self-loop in the bridge graph
function MOI.supports_constraint(
::Type{SplitZeroBridge{T}}, ::Type{<:MOI.Utilities.TypedLike{Complex{T}}},
::Type{MOI.Zeros}) where T
Expand All @@ -52,7 +38,8 @@ end
function MOI.Bridges.Constraint.concrete_bridge_type(
::Type{<:SplitZeroBridge{T}}, G::Type{<:MOI.Utilities.TypedLike},
::Type{MOI.Zeros}) where T
return SplitZeroBridge{T, similar_type(G, T), G}
F = MA.promote_operation(imag, G)
return SplitZeroBridge{T, F, G}
end

# Attributes, Bridge acting as a model
Expand Down