diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl index 6d4855b..90562e6 100644 --- a/src/MOI_wrapper.jl +++ b/src/MOI_wrapper.jl @@ -1139,7 +1139,10 @@ end struct ParametricObjectiveFunction{T} <: MOI.AbstractModelAttribute end -function MOI.get(model::Optimizer{T}, ::ParametricObjectiveFunction{ParametricQuadraticFunction{T}}) where {T} +function MOI.get( + model::Optimizer{T}, + ::ParametricObjectiveFunction{ParametricQuadraticFunction{T}}, +) where {T} if model.quadratic_objective_cache === nothing error(" There is no parametric quadratic objective function in the model. @@ -1148,7 +1151,10 @@ function MOI.get(model::Optimizer{T}, ::ParametricObjectiveFunction{ParametricQu return model.quadratic_objective_cache end -function MOI.get(model::Optimizer{T}, ::ParametricObjectiveFunction{ParametricAffineFunction{T}}) where {T} +function MOI.get( + model::Optimizer{T}, + ::ParametricObjectiveFunction{ParametricAffineFunction{T}}, +) where {T} if model.affine_objective_cache === nothing error(" There is no parametric affine objective function in the model. @@ -1159,43 +1165,53 @@ end struct ListOfParametricConstraintTypesPresent <: MOI.AbstractModelAttribute end -function MOI.get(model::Optimizer{T}, ::ListOfParametricConstraintTypesPresent) where {T} +function MOI.get( + model::Optimizer{T}, + ::ListOfParametricConstraintTypesPresent, +) where {T} output = Set{Tuple{DataType,DataType,DataType}}() - for (F, S) in MOI.Utilities.DoubleDicts.nonempty_outer_keys(model.affine_constraint_cache) + for (F, S) in MOI.Utilities.DoubleDicts.nonempty_outer_keys( + model.affine_constraint_cache, + ) push!(output, (F, S, ParametricAffineFunction{T})) end - for (F, S) in MOI.Utilities.DoubleDicts.nonempty_outer_keys(model.vector_affine_constraint_cache) + for (F, S) in MOI.Utilities.DoubleDicts.nonempty_outer_keys( + model.vector_affine_constraint_cache, + ) push!(output, (F, S, ParametricVectorAffineFunction{T})) end - for (F, S) in MOI.Utilities.DoubleDicts.nonempty_outer_keys(model.quadratic_constraint_cache) + for (F, S) in MOI.Utilities.DoubleDicts.nonempty_outer_keys( + model.quadratic_constraint_cache, + ) push!(output, (F, S, ParametricQuadraticFunction{T})) end return collect(output) end -struct DictOfParametricConstraintIndicesAndFunctions{F,S,P} <: MOI.AbstractModelAttribute end +struct DictOfParametricConstraintIndicesAndFunctions{F,S,P} <: + MOI.AbstractModelAttribute end function MOI.get( model::Optimizer, ::DictOfParametricConstraintIndicesAndFunctions{F,S,P}, -) where {F,S,P <: ParametricAffineFunction} +) where {F,S,P<:ParametricAffineFunction} return model.affine_constraint_cache[F, S] end function MOI.get( model::Optimizer, ::DictOfParametricConstraintIndicesAndFunctions{F,S,P}, -) where {F,S,P <: ParametricVectorAffineFunction} +) where {F,S,P<:ParametricVectorAffineFunction} return model.vector_affine_constraint_cache[F, S] end function MOI.get( model::Optimizer, ::DictOfParametricConstraintIndicesAndFunctions{F,S,P}, -) where {F,S, P <: ParametricQuadraticFunction} +) where {F,S,P<:ParametricQuadraticFunction} return model.quadratic_constraint_cache[F, S] end - + struct NumberOfPureVariables <: MOI.AbstractModelAttribute end function MOI.get(model::Optimizer, ::NumberOfPureVariables) diff --git a/src/parametric_functions.jl b/src/parametric_functions.jl index ec80d59..ce4e4ce 100644 --- a/src/parametric_functions.jl +++ b/src/parametric_functions.jl @@ -165,7 +165,11 @@ end function _original_function(f::ParametricQuadraticFunction{T}) where {T} return MOI.ScalarQuadraticFunction{T}( - vcat(quadratic_parameter_variable_terms(f), quadratic_parameter_parameter_terms(f), quadratic_variable_variable_terms(f)), + vcat( + quadratic_parameter_variable_terms(f), + quadratic_parameter_parameter_terms(f), + quadratic_variable_variable_terms(f), + ), vcat(affine_parameter_terms(f), affine_variable_terms(f)), f.c, ) @@ -364,11 +368,17 @@ function _count_scalar_affine_terms_types( end function _original_function(f::ParametricAffineFunction{T}) where {T} - return MOI.ScalarAffineFunction{T}(vcat(affine_parameter_terms(f), affine_variable_terms(f)), f.c) + return MOI.ScalarAffineFunction{T}( + vcat(affine_parameter_terms(f), affine_variable_terms(f)), + f.c, + ) end function _current_function(f::ParametricAffineFunction{T}) where {T} - return MOI.ScalarAffineFunction{T}(affine_variable_terms(f), f.current_constant) + return MOI.ScalarAffineFunction{T}( + affine_variable_terms(f), + f.current_constant, + ) end function _parametric_constant(model, f::ParametricAffineFunction{T}) where {T} @@ -472,11 +482,17 @@ function _count_vector_affine_terms_types( end function _original_function(f::ParametricVectorAffineFunction{T}) where {T} - return MOI.VectorAffineFunction{T}(vcat(vector_affine_parameter_terms(f), vector_affine_variable_terms(f)), f.c) + return MOI.VectorAffineFunction{T}( + vcat(vector_affine_parameter_terms(f), vector_affine_variable_terms(f)), + f.c, + ) end function _current_function(f::ParametricVectorAffineFunction{T}) where {T} - return MOI.VectorAffineFunction{T}(vector_affine_variable_terms(f), f.current_constant) + return MOI.VectorAffineFunction{T}( + vector_affine_variable_terms(f), + f.current_constant, + ) end function _parametric_constant(