Skip to content

Commit f02ab38

Browse files
committed
Add method used by bridges
1 parent a4f3ef1 commit f02ab38

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

docs/src/apireference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,7 @@ The following utilities are available for functions:
962962
Utilities.eval_variables
963963
Utilities.map_indices
964964
Utilities.substitute_variables
965+
Utilities.filter_variables
965966
Utilities.remove_variable
966967
Utilities.all_coefficients
967968
Utilities.unsafe_add

src/Utilities/functions.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,11 @@ Return a new function `f` with the variable vi removed.
663663
function remove_variable(f::MOI.AbstractFunction, vi::MOI.VariableIndex)
664664
return filter_variables(v -> v != vi, f)
665665
end
666+
function remove_variable(f::MOI.AbstractFunction, vis::Vector{MOI.VariableIndex})
667+
# Create a `Set` to test membership in `vis` in O(1).
668+
set = Set(vis)
669+
return filter_variables(vi -> !(vi in set), f)
670+
end
666671

667672
"""
668673
modify_function(f::AbstractFunction, change::AbstractFunctionModification)

0 commit comments

Comments
 (0)