Skip to content

Commit

Permalink
Fix fix fix
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed May 6, 2021
1 parent f56e669 commit 8af0ab9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Utilities/vector_of_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function MOI.get(
v::VectorOfConstraints{F,S},
::MOI.ListOfConstraintTypesPresent,
)::Vector{Tuple{DataType,DataType}} where {F,S}
return (MOI.is_empty(v) || length(_constraints(v)) == 0) ? [] : [(F, S)]
return MOI.is_empty(v) ? [] : [(F, S)]
end

function MOI.get(
Expand Down Expand Up @@ -249,6 +249,9 @@ function _delete_variables(
end
return !del
end
if length(cons) == 0
MOI.empty!(v)
end
return
end

Expand All @@ -261,6 +264,11 @@ function _deleted_constraints(
return
end
_delete_variables(callback, v, [vi])
# We need this second check in case deleting the variables also removes the
# last constraint!
if MOI.is_empty(v)
return
end
_remove_variable(v, vi)
return
end
Expand All @@ -273,8 +281,13 @@ function _deleted_constraints(
if MOI.is_empty(v)
return
end
removed = Set(vis)
_delete_variables(callback, v, vis)
# We need this second check in case deleting the variables also removes the
# last constraint!
if MOI.is_empty(v)
return
end
removed = Set(vis)
_filter_variables(vi -> !(vi in removed), v)
return
end

0 comments on commit 8af0ab9

Please sign in to comment.