Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquimg committed Dec 27, 2024
1 parent b47c533 commit 55ca155
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 16 deletions.
38 changes: 27 additions & 11 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(

Check warning on line 1142 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1142

Added line #L1142 was not covered by tests
model::Optimizer{T},
::ParametricObjectiveFunction{ParametricQuadraticFunction{T}},
) where {T}
if model.quadratic_objective_cache === nothing
error("

Check warning on line 1147 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1146-L1147

Added lines #L1146 - L1147 were not covered by tests
There is no parametric quadratic objective function in the model.
Expand All @@ -1148,7 +1151,10 @@ function MOI.get(model::Optimizer{T}, ::ParametricObjectiveFunction{ParametricQu
return model.quadratic_objective_cache

Check warning on line 1151 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1151

Added line #L1151 was not covered by tests
end

function MOI.get(model::Optimizer{T}, ::ParametricObjectiveFunction{ParametricAffineFunction{T}}) where {T}
function MOI.get(

Check warning on line 1154 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1154

Added line #L1154 was not covered by tests
model::Optimizer{T},
::ParametricObjectiveFunction{ParametricAffineFunction{T}},
) where {T}
if model.affine_objective_cache === nothing
error("

Check warning on line 1159 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1158-L1159

Added lines #L1158 - L1159 were not covered by tests
There is no parametric affine objective function in the model.
Expand All @@ -1159,43 +1165,53 @@ end

struct ListOfParametricConstraintTypesPresent <: MOI.AbstractModelAttribute end

function MOI.get(model::Optimizer{T}, ::ListOfParametricConstraintTypesPresent) where {T}
function MOI.get(

Check warning on line 1168 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1168

Added line #L1168 was not covered by tests
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(

Check warning on line 1173 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1172-L1173

Added lines #L1172 - L1173 were not covered by tests
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(

Check warning on line 1178 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1176-L1178

Added lines #L1176 - L1178 were not covered by tests
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(

Check warning on line 1183 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1181-L1183

Added lines #L1181 - L1183 were not covered by tests
model.quadratic_constraint_cache,
)
push!(output, (F, S, ParametricQuadraticFunction{T}))
end
return collect(output)

Check warning on line 1188 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1186-L1188

Added lines #L1186 - L1188 were not covered by tests
end

struct DictOfParametricConstraintIndicesAndFunctions{F,S,P} <: MOI.AbstractModelAttribute end
struct DictOfParametricConstraintIndicesAndFunctions{F,S,P} <:
MOI.AbstractModelAttribute end

function MOI.get(

Check warning on line 1194 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1194

Added line #L1194 was not covered by tests
model::Optimizer,
::DictOfParametricConstraintIndicesAndFunctions{F,S,P},
) where {F,S,P <: ParametricAffineFunction}
) where {F,S,P<:ParametricAffineFunction}
return model.affine_constraint_cache[F, S]

Check warning on line 1198 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1198

Added line #L1198 was not covered by tests
end

function MOI.get(

Check warning on line 1201 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1201

Added line #L1201 was not covered by tests
model::Optimizer,
::DictOfParametricConstraintIndicesAndFunctions{F,S,P},
) where {F,S,P <: ParametricVectorAffineFunction}
) where {F,S,P<:ParametricVectorAffineFunction}
return model.vector_affine_constraint_cache[F, S]

Check warning on line 1205 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1205

Added line #L1205 was not covered by tests
end

function MOI.get(

Check warning on line 1208 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1208

Added line #L1208 was not covered by tests
model::Optimizer,
::DictOfParametricConstraintIndicesAndFunctions{F,S,P},
) where {F,S, P <: ParametricQuadraticFunction}
) where {F,S,P<:ParametricQuadraticFunction}
return model.quadratic_constraint_cache[F, S]

Check warning on line 1212 in src/MOI_wrapper.jl

View check run for this annotation

Codecov / codecov/patch

src/MOI_wrapper.jl#L1212

Added line #L1212 was not covered by tests
end

struct NumberOfPureVariables <: MOI.AbstractModelAttribute end

function MOI.get(model::Optimizer, ::NumberOfPureVariables)
Expand Down
26 changes: 21 additions & 5 deletions src/parametric_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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}(

Check warning on line 485 in src/parametric_functions.jl

View check run for this annotation

Codecov / codecov/patch

src/parametric_functions.jl#L485

Added line #L485 was not covered by tests
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(
Expand Down

0 comments on commit 55ca155

Please sign in to comment.