Skip to content

Commit

Permalink
Rename _function_type_to_set to _function_type_to_func and test (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Nov 24, 2024
1 parent e1ebd0c commit 6e2188c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
_kFunctionTypeScalarQuadratic,
)

function _function_type_to_set(::Type{T}, k::_FunctionType) where {T}
function _function_type_to_func(::Type{T}, k::_FunctionType) where {T}
if k == _kFunctionTypeVariableIndex
return MOI.VariableIndex
elseif k == _kFunctionTypeScalarAffine
Expand Down Expand Up @@ -299,7 +299,7 @@ function MOI.set(
end

function MOI.get(block::QPBlockData{T}, ::MOI.ObjectiveFunctionType) where {T}
return _function_type_to_set(T, block.objective_function_type)
return _function_type_to_func(T, block.objective_function_type)
end

function MOI.get(block::QPBlockData{T}, ::MOI.ObjectiveFunction{F}) where {T,F}
Expand All @@ -312,7 +312,7 @@ function MOI.get(
) where {T}
constraints = Set{Tuple{Type,Type}}()
for i in 1:length(block)
F = _function_type_to_set(T, block.function_type[i])
F = _function_type_to_func(T, block.function_type[i])
S = _bound_type_to_set(T, block.bound_type[i])
push!(constraints, (F, S))
end
Expand Down Expand Up @@ -342,7 +342,7 @@ function MOI.get(
for i in 1:length(block)
if _bound_type_to_set(T, block.bound_type[i]) != S
continue
elseif _function_type_to_set(T, block.function_type[i]) != F
elseif _function_type_to_func(T, block.function_type[i]) != F
continue
end
push!(ret, MOI.ConstraintIndex{F,S}(i))
Expand Down
9 changes: 9 additions & 0 deletions test/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,15 @@ function test_RawOptimizerAttribute()
return
end

function test_function_type_to_func()
model = Ipopt.Optimizer()
x = MOI.add_variable(model)
MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
MOI.set(model, MOI.ObjectiveFunction{MOI.VariableIndex}(), x)
@test MOI.get(model, MOI.ObjectiveFunctionType()) == MOI.VariableIndex
return
end

end # module TestMOIWrapper

TestMOIWrapper.runtests()

0 comments on commit 6e2188c

Please sign in to comment.