Skip to content

Commit a2df7e6

Browse files
committed
Fix deletion of no variable
1 parent f02ab38 commit a2df7e6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Utilities/model.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ function MOI.delete(model::AbstractModel, vi::MOI.VariableIndex)
222222
model.objective = remove_variable(model.objective, vi)
223223
end
224224
function MOI.delete(model::AbstractModel, vis::Vector{MOI.VariableIndex})
225+
if isempty(vis)
226+
# In `keep`, we assume that `model.variable_indices !== nothing` so
227+
# at least one variable need to be deleted.
228+
return
229+
end
225230
# Delete `VectorOfVariables(vis)` constraints as otherwise, it will error
226231
# when removing variables one by one.
227232
vov_to_remove = broadcastvcat(constrs -> _vector_of_variables_with(constrs, vis), model)

0 commit comments

Comments
 (0)