From 6afb1dc014b3070a3a45292f251d90f471025f8c Mon Sep 17 00:00:00 2001 From: odow Date: Tue, 18 Feb 2025 15:28:50 +1300 Subject: [PATCH] Add blank lines between definitions --- perf/bellman_ford.jl | 5 +++++ src/Bridges/Constraint/single_bridge_optimizer.jl | 1 + src/Bridges/Variable/set_map.jl | 1 + src/FileFormats/MOF/write.jl | 1 + src/FileFormats/SDPA/SDPA.jl | 2 ++ src/Test/test_basic_constraint.jl | 4 ++++ src/Test/test_model.jl | 1 + src/Utilities/cachingoptimizer.jl | 8 ++++++++ src/Utilities/mockoptimizer.jl | 2 ++ src/Utilities/struct_of_constraints.jl | 2 ++ src/Utilities/vector_of_constraints.jl | 1 + src/constraints.jl | 5 +++++ src/instantiate.jl | 1 + src/modifications.jl | 2 ++ test/Bridges/bridge_optimizer.jl | 3 +++ test/Bridges/lazy_bridge_optimizer.jl | 2 ++ test/FileFormats/MOF/MOF.jl | 1 + test/FileFormats/SDPA/SDPA.jl | 1 + test/Utilities/cachingoptimizer.jl | 3 +++ test/Utilities/mutable_arithmetics.jl | 2 ++ test/dummy.jl | 2 ++ 21 files changed, 50 insertions(+) diff --git a/perf/bellman_ford.jl b/perf/bellman_ford.jl index 8ce6b0dff8..e00fe2470a 100644 --- a/perf/bellman_ford.jl +++ b/perf/bellman_ford.jl @@ -28,6 +28,7 @@ function MOI.supports_constraint( ) where {T} return false end + function MOI.supports_constraint( ::SDPAModel{T}, ::Type{MOI.VariableIndex}, @@ -35,6 +36,7 @@ function MOI.supports_constraint( ) where {T} return false end + function MOI.supports_constraint( ::SDPAModel{T}, ::Type{MOI.VariableIndex}, @@ -42,6 +44,7 @@ function MOI.supports_constraint( ) where {T} return false end + function MOI.supports_constraint( ::SDPAModel{T}, ::Type{MOI.VariableIndex}, @@ -49,6 +52,7 @@ function MOI.supports_constraint( ) where {T} return false end + function MOI.supports_constraint( ::SDPAModel, ::Type{MOI.VectorOfVariables}, @@ -56,6 +60,7 @@ function MOI.supports_constraint( ) return false end + function MOI.supports( ::SDPAModel{T}, ::MOI.ObjectiveFunction{MOI.ScalarQuadraticFunction{T}}, diff --git a/src/Bridges/Constraint/single_bridge_optimizer.jl b/src/Bridges/Constraint/single_bridge_optimizer.jl index 2a0446d8b9..f388c68f6d 100644 --- a/src/Bridges/Constraint/single_bridge_optimizer.jl +++ b/src/Bridges/Constraint/single_bridge_optimizer.jl @@ -86,6 +86,7 @@ function MOI.Bridges.is_bridged( return MOI.Bridges.is_bridged(b, MOI.VariableIndex, S) && haskey(Constraint.bridges(b), ci) end + function MOI.Bridges.is_bridged( b::SingleBridgeOptimizer, ci::MOI.ConstraintIndex{MOI.VectorOfVariables,S}, diff --git a/src/Bridges/Variable/set_map.jl b/src/Bridges/Variable/set_map.jl index d34685e661..653a7f1c25 100644 --- a/src/Bridges/Variable/set_map.jl +++ b/src/Bridges/Variable/set_map.jl @@ -113,6 +113,7 @@ function MOI.delete( MOI.delete(model, bridge.variable) return end + function MOI.delete( model::MOI.ModelLike, bridge::SetMapBridge{T,S1,S2}, diff --git a/src/FileFormats/MOF/write.jl b/src/FileFormats/MOF/write.jl index c229751b5c..5a699bb3bb 100644 --- a/src/FileFormats/MOF/write.jl +++ b/src/FileFormats/MOF/write.jl @@ -476,6 +476,7 @@ head_name(::Type{MOI.LogDetConeSquare}) = "LogDetConeSquare" function head_name(::Type{MOI.PositiveSemidefiniteConeTriangle}) return "PositiveSemidefiniteConeTriangle" end + function head_name(::Type{MOI.PositiveSemidefiniteConeSquare}) return "PositiveSemidefiniteConeSquare" end diff --git a/src/FileFormats/SDPA/SDPA.jl b/src/FileFormats/SDPA/SDPA.jl index d47837333e..8c73e04fa8 100644 --- a/src/FileFormats/SDPA/SDPA.jl +++ b/src/FileFormats/SDPA/SDPA.jl @@ -30,6 +30,7 @@ function MOI.supports_constraint( ) where {T} return false end + function MOI.supports_constraint( ::Model, ::Type{MOI.VariableIndex}, @@ -300,6 +301,7 @@ function _dim_to_set(s::AbstractString) return MOI.Nonnegatives(-block_dim) end end + function _parse_dimensions(dims::AbstractString) isvalid(char) = isdigit(char) || char == '-' is_delimiter(char) = isspace(char) || char == ',' diff --git a/src/Test/test_basic_constraint.jl b/src/Test/test_basic_constraint.jl index 451bda0ac6..ec897c8472 100644 --- a/src/Test/test_basic_constraint.jl +++ b/src/Test/test_basic_constraint.jl @@ -100,6 +100,7 @@ _set(::Type{MOI.Integer}) = MOI.Integer() function _set(::Type{T}, ::Type{MOI.Semicontinuous}) where {T} return MOI.Semicontinuous(zero(T), one(T)) end + function _set(::Type{T}, ::Type{MOI.Semiinteger}) where {T} return MOI.Semiinteger(zero(T), one(T)) end @@ -124,12 +125,15 @@ _set(::Type{MOI.NormNuclearCone}) = MOI.NormNuclearCone(2, 3) function _set(::Type{MOI.PositiveSemidefiniteConeTriangle}) return MOI.PositiveSemidefiniteConeTriangle(3) end + function _set(::Type{MOI.PositiveSemidefiniteConeSquare}) return MOI.PositiveSemidefiniteConeSquare(3) end + function _set(::Type{MOI.HermitianPositiveSemidefiniteConeTriangle}) return MOI.HermitianPositiveSemidefiniteConeTriangle(3) end + function _set(::Type{MOI.Scaled{MOI.PositiveSemidefiniteConeTriangle}}) return MOI.Scaled{MOI.PositiveSemidefiniteConeTriangle}(3) end diff --git a/src/Test/test_model.jl b/src/Test/test_model.jl index 587b7c9d16..4fa013deb4 100644 --- a/src/Test/test_model.jl +++ b/src/Test/test_model.jl @@ -106,6 +106,7 @@ function MOI.get(::BadModelAttributeModel, ::MOI.ListOfModelAttributesSet) end struct UnknownVariableAttribute <: MOI.AbstractVariableAttribute end + struct BadVariableAttributeModel{T} <: BadModel{T} BadVariableAttributeModel(T = Float64) = new{T}() end diff --git a/src/Utilities/cachingoptimizer.jl b/src/Utilities/cachingoptimizer.jl index 4da7a0a646..0719892663 100644 --- a/src/Utilities/cachingoptimizer.jl +++ b/src/Utilities/cachingoptimizer.jl @@ -272,9 +272,11 @@ function pass_nonvariable_constraints( constraint_types, ) end + function final_touch(m::CachingOptimizer, index_map) return final_touch(m.model_cache, index_map) end + function MOI.copy_to(m::CachingOptimizer, src::MOI.ModelLike) if m.state == ATTACHED_OPTIMIZER reset_optimizer(m) @@ -394,6 +396,7 @@ function MOI.supports_add_constrained_variable( MOI.supports_add_constrained_variable(m.optimizer, S)::Bool ) end + function MOI.add_constrained_variable( m::CachingOptimizer, set::S, @@ -1032,6 +1035,7 @@ function MOI.supports( ) return MOI.supports(model.model_cache, attr, IndexType) end + function MOI.set( model::CachingOptimizer, attr::Union{MOI.VariableName,MOI.ConstraintName}, @@ -1045,6 +1049,7 @@ end function MOI.supports(m::CachingOptimizer, attr::MOI.Name) return MOI.supports(m.model_cache, attr) end + function MOI.set(model::CachingOptimizer, attr::MOI.Name, value) MOI.set(model.model_cache, attr, value) return @@ -1205,12 +1210,14 @@ end function map_indices_to_optimizer(m::CachingOptimizer, idx::MOI.Index) return m.model_to_optimizer_map[idx] end + function map_indices_to_optimizer( m::CachingOptimizer, indices::Vector{<:MOI.Index}, ) return getindex.(Ref(m.model_to_optimizer_map), indices) end + function MOI.set( m::CachingOptimizer, attr::AttributeFromOptimizer{T}, @@ -1272,6 +1279,7 @@ function MOI.supports( return caching_opt.optimizer !== nothing && MOI.supports(caching_opt.optimizer, sub)::Bool end + function MOI.submit( caching_opt::CachingOptimizer, sub::MOI.AbstractSubmittable, diff --git a/src/Utilities/mockoptimizer.jl b/src/Utilities/mockoptimizer.jl index 7d40abef50..7da42ca0fa 100644 --- a/src/Utilities/mockoptimizer.jl +++ b/src/Utilities/mockoptimizer.jl @@ -465,6 +465,7 @@ function MOI.get(mock::MockOptimizer, attr::MOI.AbstractOptimizerAttribute) return MOI.get(mock.inner_model, attr) end end + function MOI.get(mock::MockOptimizer, attr::MOI.AbstractModelAttribute) if MOI.is_set_by_optimize(attr) return mock.model_attributes[attr] @@ -680,6 +681,7 @@ function MOI.get( return _safe_get_result(mock.constraint_dual, attr, idx, "dual") end end + function MOI.get( mock::MockOptimizer, ::MockConstraintAttribute, diff --git a/src/Utilities/struct_of_constraints.jl b/src/Utilities/struct_of_constraints.jl index 355d571a3c..515bde35df 100644 --- a/src/Utilities/struct_of_constraints.jl +++ b/src/Utilities/struct_of_constraints.jl @@ -19,12 +19,14 @@ function _add_variable(model::StructOfConstraints) model.num_variables += 1 return broadcastcall(_add_variable, model) end + function _add_variables(model::StructOfConstraints, n) model.num_variables += n return broadcastcall(Base.Fix2(_add_variables, n), model) end function final_touch(::Nothing, index_map) end + function final_touch(model::StructOfConstraints, index_map) broadcastcall(Base.Fix2(final_touch, index_map), model) return diff --git a/src/Utilities/vector_of_constraints.jl b/src/Utilities/vector_of_constraints.jl index 5435abb21b..b12b97bd85 100644 --- a/src/Utilities/vector_of_constraints.jl +++ b/src/Utilities/vector_of_constraints.jl @@ -179,6 +179,7 @@ function MOI.modify( end function _add_variable(::VectorOfConstraints) end + function _add_variables(::VectorOfConstraints, ::Int64) end # Deletion of variables in vector of variables diff --git a/src/constraints.jl b/src/constraints.jl index 979fae8308..28529f0e1c 100644 --- a/src/constraints.jl +++ b/src/constraints.jl @@ -135,12 +135,14 @@ function throw_if_scalar_and_constant_not_zero( end return end + function throw_if_scalar_and_constant_not_zero( ::VariableIndex, ::Type{S}, ) where {S<:AbstractScalarSet} return end + function throw_if_scalar_and_constant_not_zero( ::AbstractVectorFunction, ::Type{S}, @@ -197,6 +199,7 @@ function throw_add_constraint_error_fallback( kwargs..., ) end + function throw_add_constraint_error_fallback( model::ModelLike, func::AbstractVectorFunction, @@ -210,6 +213,7 @@ function throw_add_constraint_error_fallback( kwargs..., ) end + function throw_add_constraint_error_fallback( model::ModelLike, func::AbstractScalarFunction, @@ -220,6 +224,7 @@ function throw_add_constraint_error_fallback( "Cannot add a constraint of the form `ScalarFunction`-in-`VectorSet`", ) end + function throw_add_constraint_error_fallback( model::ModelLike, func::AbstractVectorFunction, diff --git a/src/instantiate.jl b/src/instantiate.jl index aeac3eb7ba..abf179d272 100644 --- a/src/instantiate.jl +++ b/src/instantiate.jl @@ -27,6 +27,7 @@ _to_param(param::Pair{<:AbstractOptimizerAttribute}) = param function _to_param(param::Pair{String}) return RawOptimizerAttribute(param.first) => param.second end + function _to_param(param::Pair) return error( "Expected an optimizer attribute or a string, got `$(param.first)` which is a `$(typeof(param.first))`.", diff --git a/src/modifications.jl b/src/modifications.jl index e0dfd5ed4a..feab10f30a 100644 --- a/src/modifications.jl +++ b/src/modifications.jl @@ -24,6 +24,7 @@ struct ModifyConstraintNotAllowed{ change::C message::String end + function ModifyConstraintNotAllowed( ci::ConstraintIndex{F,S}, change::AbstractFunctionModification, @@ -31,6 +32,7 @@ function ModifyConstraintNotAllowed( ) where {F<:AbstractFunction,S<:AbstractSet} return ModifyConstraintNotAllowed{F,S,typeof(change)}(ci, change, message) end + function throw_modify_not_allowed(ci::ConstraintIndex, args...) return throw(ModifyConstraintNotAllowed(ci, args...)) end diff --git a/test/Bridges/bridge_optimizer.jl b/test/Bridges/bridge_optimizer.jl index 7ee72de240..879a54a4c9 100644 --- a/test/Bridges/bridge_optimizer.jl +++ b/test/Bridges/bridge_optimizer.jl @@ -24,8 +24,11 @@ end include("utilities.jl") struct DummyModelAttribute <: MOI.AbstractModelAttribute end + struct DummyEvaluator <: MOI.AbstractNLPEvaluator end + struct DummyVariableAttribute <: MOI.AbstractVariableAttribute end + struct DummyConstraintAttribute <: MOI.AbstractConstraintAttribute end function test_subsitution_of_variables_constant() diff --git a/test/Bridges/lazy_bridge_optimizer.jl b/test/Bridges/lazy_bridge_optimizer.jl index af5148d039..3558adb6e3 100644 --- a/test/Bridges/lazy_bridge_optimizer.jl +++ b/test/Bridges/lazy_bridge_optimizer.jl @@ -1970,8 +1970,10 @@ function test_wrong_coefficient() end struct OptimizerWithBridgeListOfNonstandardBridges <: MOI.AbstractOptimizer end + struct BridgeListOfNonstandardBridges{T} <: MOI.Bridges.Constraint.AbstractBridge end + function MOI.get( ::OptimizerWithBridgeListOfNonstandardBridges, ::MOI.Bridges.ListOfNonstandardBridges{T}, diff --git a/test/FileFormats/MOF/MOF.jl b/test/FileFormats/MOF/MOF.jl index a9c7c0c3a2..aa0583c9f8 100644 --- a/test/FileFormats/MOF/MOF.jl +++ b/test/FileFormats/MOF/MOF.jl @@ -55,6 +55,7 @@ function _validate(filename::String) end struct UnsupportedSet <: MOI.AbstractSet end + struct UnsupportedFunction <: MOI.AbstractFunction end function _test_model_equality( diff --git a/test/FileFormats/SDPA/SDPA.jl b/test/FileFormats/SDPA/SDPA.jl index 02a769d6f5..afd28e3d9f 100644 --- a/test/FileFormats/SDPA/SDPA.jl +++ b/test/FileFormats/SDPA/SDPA.jl @@ -326,6 +326,7 @@ end function _spacer(char) return [" ", "$char", " $char", "$char ", " $char "] end + function test_dim_reader() for before in _spacer('{') for sep in _spacer(',') diff --git a/test/Utilities/cachingoptimizer.jl b/test/Utilities/cachingoptimizer.jl index fffc051452..02fc93b083 100644 --- a/test/Utilities/cachingoptimizer.jl +++ b/test/Utilities/cachingoptimizer.jl @@ -1001,12 +1001,15 @@ function MOI.Utilities.final_touch(model::FinalTouchDetector, index_map) model.index_map = index_map return end + function MOI.copy_to(::MOI.Utilities.MockOptimizer, ::FinalTouchDetector) return MOI.Utilities.IndexMap() end + function MOI.get(::FinalTouchDetector, ::MOI.ListOfOptimizerAttributesSet) return MOI.AbstractOptimizerAttribute[] end + function MOI.get(::FinalTouchDetector, ::MOI.ListOfModelAttributesSet) return MOI.AbstractModelAttribute[] end diff --git a/test/Utilities/mutable_arithmetics.jl b/test/Utilities/mutable_arithmetics.jl index 152fc7bf5f..33a30d72c5 100644 --- a/test/Utilities/mutable_arithmetics.jl +++ b/test/Utilities/mutable_arithmetics.jl @@ -56,9 +56,11 @@ end function test_promote_operation_allocation_Int() return _test_promote_operation_allocation(Int) end + function test_promote_operation_allocation_Float64() return _test_promote_operation_allocation(Float64) end + function test_promote_operation_allocation_Float32() return _test_promote_operation_allocation(Float32) end diff --git a/test/dummy.jl b/test/dummy.jl index 34199b25fd..6302d8f6b9 100644 --- a/test/dummy.jl +++ b/test/dummy.jl @@ -26,6 +26,7 @@ function MOI.supports( ) return true end + function MOI.supports_constraint( ::AbstractDummyModel, ::Type{MOI.VariableIndex}, @@ -33,6 +34,7 @@ function MOI.supports_constraint( ) return true end + function MOI.supports_constraint( ::AbstractDummyModel, ::Type{MOI.VectorOfVariables},