Skip to content

Commit

Permalink
[Utilities] ignore attributes in UniversalFallback if set to nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Nov 1, 2024
1 parent 278fba5 commit 56b12ae
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/Utilities/universalfallback.jl
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,10 @@ function MOI.get(
listattr::MOI.ListOfOptimizerAttributesSet,
)
list = MOI.get(uf.model, listattr)
for attr in keys(uf.optattr)
push!(list, attr)
for (attr, value) in uf.optattr
if value !== nothing
push!(list, attr)
end
end
return list
end
Expand All @@ -475,8 +477,10 @@ function MOI.get(uf::UniversalFallback, listattr::MOI.ListOfModelAttributesSet)
if uf.objective !== nothing
push!(list, MOI.ObjectiveFunction{typeof(uf.objective)}())
end
for attr in keys(uf.modattr)
push!(list, attr)
for (attr, value) in uf.modattr
if value !== nothing
push!(list, attr)
end
end
return list
end
Expand All @@ -486,8 +490,10 @@ function MOI.get(
listattr::MOI.ListOfVariableAttributesSet,
)
list = MOI.get(uf.model, listattr)
for attr in keys(uf.varattr)
push!(list, attr)
for (attr, value) in uf.varattr
if value !== nothing
push!(list, attr)
end
end
return list
end
Expand All @@ -498,8 +504,11 @@ function MOI.get(
) where {F,S}
list = MOI.get(uf.model, listattr)
for (attr, dict) in uf.conattr
if any(k -> k isa MOI.ConstraintIndex{F,S}, keys(dict))
push!(list, attr)
for (k, v) in dict
if v !== nothing && k isa MOI.ConstraintIndex{F,S}
push!(list, attr)
break
end
end
end
# ConstraintName isn't stored in conattr, but in the .con_to_name dictionary
Expand Down

0 comments on commit 56b12ae

Please sign in to comment.