Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/Utilities/universalfallback.jl
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ function _get(
end

function _get(
uf,
uf::UniversalFallback,
attr::MOI.CanonicalConstraintFunction,
ci::MOI.ConstraintIndex,
)
Expand Down Expand Up @@ -445,8 +445,19 @@ function MOI.get(
listattr::MOI.ListOfConstraintAttributesSet{F,S},
) where {F,S}
list = MOI.get(uf.model, listattr)
for attr in keys(uf.conattr)
push!(list, attr)
for (attr, dict) in uf.conattr
if any(k -> k isa MOI.ConstraintIndex{F,S}, keys(dict))
push!(list, attr)
end
end
# ConstraintName isn't stored in conattr, but in the .con_to_name dictionary
# instead. Only add it to `list` if it isn't already, and if a constraint
# of the right type has a name set. This avoids, for example, returning
# ConstraintName for SingleVariable constraints.
if !(MOI.ConstraintName() in list)
if any(k -> k isa MOI.ConstraintIndex{F,S}, keys(uf.con_to_name))
push!(list, MOI.ConstraintName())
end
end
return list
end
Expand Down Expand Up @@ -648,7 +659,7 @@ function _set(uf::UniversalFallback, attr::MOI.AbstractModelAttribute, value)
end

function _set(
uf,
uf::UniversalFallback,
attr::MOI.AbstractVariableAttribute,
vi::MOI.VariableIndex,
value,
Expand All @@ -661,7 +672,7 @@ function _set(
end

function _set(
uf,
uf::UniversalFallback,
attr::MOI.AbstractConstraintAttribute,
ci::MOI.ConstraintIndex,
value,
Expand Down Expand Up @@ -755,11 +766,8 @@ end

function constraints(
uf::UniversalFallback,
ci::MOI.ConstraintIndex{F,S},
::MOI.ConstraintIndex{F,S},
) where {F,S}
if !MOI.supports_constraint(uf, F, S)
throw(MOI.InvalidIndex(ci))
end
return constraints(uf, F, S)
end

Expand Down
Loading