Skip to content

Commit d56a837

Browse files
committed
[Utilities] ignore attributes in UniversalFallback if set to nothing
1 parent a905a41 commit d56a837

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/Utilities/universalfallback.jl

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,10 @@ function MOI.get(
464464
listattr::MOI.ListOfOptimizerAttributesSet,
465465
)
466466
list = MOI.get(uf.model, listattr)
467-
for attr in keys(uf.optattr)
468-
push!(list, attr)
467+
for (attr, value) in uf.optattr
468+
if value !== nothing
469+
push!(list, attr)
470+
end
469471
end
470472
return list
471473
end
@@ -475,8 +477,10 @@ function MOI.get(uf::UniversalFallback, listattr::MOI.ListOfModelAttributesSet)
475477
if uf.objective !== nothing
476478
push!(list, MOI.ObjectiveFunction{typeof(uf.objective)}())
477479
end
478-
for attr in keys(uf.modattr)
479-
push!(list, attr)
480+
for (attr, value) in uf.modattr
481+
if value !== nothing
482+
push!(list, attr)
483+
end
480484
end
481485
return list
482486
end
@@ -486,8 +490,10 @@ function MOI.get(
486490
listattr::MOI.ListOfVariableAttributesSet,
487491
)
488492
list = MOI.get(uf.model, listattr)
489-
for attr in keys(uf.varattr)
490-
push!(list, attr)
493+
for (attr, value) in uf.varattr
494+
if value !== nothing
495+
push!(list, attr)
496+
end
491497
end
492498
return list
493499
end
@@ -498,8 +504,11 @@ function MOI.get(
498504
) where {F,S}
499505
list = MOI.get(uf.model, listattr)
500506
for (attr, dict) in uf.conattr
501-
if any(k -> k isa MOI.ConstraintIndex{F,S}, keys(dict))
502-
push!(list, attr)
507+
for (k, v) in dict
508+
if v !== nothing && k isa MOI.ConstraintIndex{F,S}
509+
push!(list, attr)
510+
break
511+
end
503512
end
504513
end
505514
# ConstraintName isn't stored in conattr, but in the .con_to_name dictionary

0 commit comments

Comments
 (0)