From 7919b2fed772b2a64938a40e262364df99cc251c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 31 Jul 2024 21:50:17 +0200 Subject: [PATCH] Fix format --- .../Constraint/bridges/linear_combination.jl | 13 ++--- src/Bridges/Variable/bridges/set_dot.jl | 16 ++---- src/Test/test_conic.jl | 54 +++++++++++++------ 3 files changed, 46 insertions(+), 37 deletions(-) diff --git a/src/Bridges/Constraint/bridges/linear_combination.jl b/src/Bridges/Constraint/bridges/linear_combination.jl index ef21fe735f..2656cea235 100644 --- a/src/Bridges/Constraint/bridges/linear_combination.jl +++ b/src/Bridges/Constraint/bridges/linear_combination.jl @@ -31,8 +31,8 @@ end function _map_function(set::MOI.LinearCombinationInSet, func) scalars = MOI.Utilities.eachscalar(func) return MOI.Utilities.vectorize([ - sum(scalars[j] * set.vectors[j][i] for j in eachindex(scalars)) - for i in 1:MOI.dimension(set.set) + sum(scalars[j] * set.vectors[j][i] for j in eachindex(scalars)) for + i in 1:MOI.dimension(set.set) ]) end @@ -61,13 +61,10 @@ function MOI.Bridges.inverse_map_set( return bridge.set end -function MOI.Bridges.adjoint_map_function( - bridge::LinearCombinationBridge, - func, -) +function MOI.Bridges.adjoint_map_function(bridge::LinearCombinationBridge, func) scalars = MOI.Utilities.eachscalar(func) return MOI.Utilities.vectorize([ - MOI.Utilities.set_dot(vector, scalars, bridge.set.set) - for vector in bridge.set.vectors + MOI.Utilities.set_dot(vector, scalars, bridge.set.set) for + vector in bridge.set.vectors ]) end diff --git a/src/Bridges/Variable/bridges/set_dot.jl b/src/Bridges/Variable/bridges/set_dot.jl index 93fb3f8f45..a2468f4b9c 100644 --- a/src/Bridges/Variable/bridges/set_dot.jl +++ b/src/Bridges/Variable/bridges/set_dot.jl @@ -4,8 +4,7 @@ # Use of this source code is governed by an MIT-style license that can be found # in the LICENSE.md file or at https://opensource.org/licenses/MIT. -struct DotProductsBridge{T,S,A,V} <: - SetMapBridge{T,S,MOI.SetDotProducts{S,A,V}} +struct DotProductsBridge{T,S,A,V} <: SetMapBridge{T,S,MOI.SetDotProducts{S,A,V}} variables::Vector{MOI.VariableIndex} constraint::MOI.ConstraintIndex{MOI.VectorOfVariables,S} set::MOI.SetDotProducts{S,A,V} @@ -59,18 +58,11 @@ function MOI.Bridges.map_function( ) end -function MOI.Bridges.map_function( - bridge::DotProductsBridge{T}, - func, -) where {T} +function MOI.Bridges.map_function(bridge::DotProductsBridge{T}, func) where {T} scalars = MOI.Utilities.eachscalar(func) return MOI.Utilities.vectorize([ - MOI.Utilities.set_dot( - vector, - scalars, - bridge.set.set, - ) - for vector in bridge.set.vectors + MOI.Utilities.set_dot(vector, scalars, bridge.set.set) for + vector in bridge.set.vectors ]) end diff --git a/src/Test/test_conic.jl b/src/Test/test_conic.jl index b3add76ded..48f05000a6 100644 --- a/src/Test/test_conic.jl +++ b/src/Test/test_conic.jl @@ -5801,7 +5801,11 @@ function test_conic_PositiveSemidefinite_RankOne_polynomial( MOI.PositiveSemidefiniteFactorization(T[1, 1]), ]), ) - @requires MOI.supports_constraint(model, MOI.VectorAffineFunction{T}, typeof(set)) + @requires MOI.supports_constraint( + model, + MOI.VectorAffineFunction{T}, + typeof(set), + ) @requires MOI.supports_incremental_interface(model) @requires MOI.supports(model, MOI.ObjectiveSense()) @requires MOI.supports(model, MOI.ObjectiveFunction{MOI.VariableIndex}()) @@ -5839,17 +5843,23 @@ function setup_test( model::MOIU.MockOptimizer, ::Config{T}, ) where {T<:Real} - A = MOI.TriangleVectorization{T,MOI.PositiveSemidefiniteFactorization{T,Vector{T}}} + A = MOI.TriangleVectorization{ + T, + MOI.PositiveSemidefiniteFactorization{T,Vector{T}}, + } MOIU.set_mock_optimize!( model, (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, T[-1], - (MOI.VectorAffineFunction{T}, MOI.SetDotProducts{ - MOI.PositiveSemidefiniteConeTriangle, - A, - Vector{A}, - }) => [T[0, 1]], + ( + MOI.VectorAffineFunction{T}, + MOI.SetDotProducts{ + MOI.PositiveSemidefiniteConeTriangle, + A, + Vector{A}, + }, + ) => [T[0, 1]], ), ) return @@ -5877,14 +5887,18 @@ function test_conic_PositiveSemidefinite_RankOne_moment( @requires MOI.supports_add_constrained_variables(model, typeof(set)) @requires MOI.supports_incremental_interface(model) @requires MOI.supports(model, MOI.ObjectiveSense()) - @requires MOI.supports(model, MOI.ObjectiveFunction{MOI.ScalarAffineFunction{T}}()) - y, cy = MOI.add_constrained_variables( + @requires MOI.supports( model, - set, + MOI.ObjectiveFunction{MOI.ScalarAffineFunction{T}}(), ) + y, cy = MOI.add_constrained_variables(model, set) c = MOI.add_constraint(model, T(1) * y[1] + T(1) * y[2], MOI.EqualTo(T(1))) MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE) - MOI.set(model, MOI.ObjectiveFunction{MOI.ScalarAffineFunction{T}}(), T(3) * y[1] - T(1) * y[2]) + MOI.set( + model, + MOI.ObjectiveFunction{MOI.ScalarAffineFunction{T}}(), + T(3) * y[1] - T(1) * y[2], + ) if _supports(config, MOI.optimize!) @test MOI.get(model, MOI.TerminationStatus()) == MOI.OPTIMIZE_NOT_CALLED MOI.optimize!(model) @@ -5912,18 +5926,24 @@ function setup_test( model::MOIU.MockOptimizer, ::Config{T}, ) where {T<:Real} - A = MOI.TriangleVectorization{T,MOI.PositiveSemidefiniteFactorization{T,Vector{T}}} + A = MOI.TriangleVectorization{ + T, + MOI.PositiveSemidefiniteFactorization{T,Vector{T}}, + } MOIU.set_mock_optimize!( model, (mock::MOIU.MockOptimizer) -> MOIU.mock_optimize!( mock, T[0, 1], (MOI.ScalarAffineFunction{T}, MOI.EqualTo{T}) => [T(-1)], - (MOI.VectorOfVariables, MOI.LinearCombinationInSet{ - MOI.PositiveSemidefiniteConeTriangle, - A, - Vector{A}, - }) => [T[4, 0]], + ( + MOI.VectorOfVariables, + MOI.LinearCombinationInSet{ + MOI.PositiveSemidefiniteConeTriangle, + A, + Vector{A}, + }, + ) => [T[4, 0]], ), ) return