Skip to content

Commit d985953

Browse files
committed
F
1 parent 30b859a commit d985953

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/Bridges/bridge_optimizer.jl

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -506,18 +506,30 @@ function _delete_variables_in_vector_of_variables_constraint(
506506
end
507507
end
508508

509+
"""
510+
_delete_variables_in_variables_constraints(
511+
b::AbstractBridgeOptimizer,
512+
vis::Vector{MOI.VariableIndex},
513+
)
514+
515+
!!! warning
516+
There's a lot of subtle logic in this function.
517+
"""
509518
function _delete_variables_in_variables_constraints(
510519
b::AbstractBridgeOptimizer,
511520
vis::Vector{MOI.VariableIndex},
512521
)
513522
c_map = Constraint.bridges(b)::Constraint.Map
514-
# Delete all `MOI.VariableIndex` constraints of these variables.
523+
# First, we need to delete any scalar constraints associated with these
524+
# variables.
525+
#
526+
# x in S_s --> [x] in S_v
515527
for vi in vis
516-
# If a bridged `VariableIndex` constraints creates a second one,
517-
# then we will delete the second one when deleting the first one hence we
518-
# should not delete it again in this loop.
519-
# For this, we reverse the order so that we encounter the first one first
520-
# and we won't delete the second one since `MOI.is_valid(b, ci)` will be `false`.
528+
# If a bridged `VariableIndex` constraints creates a second one, then we
529+
# will delete the second one when deleting the first one hence we should
530+
# not delete it again in this loop. For this, we reverse the order so
531+
# that we encounter the first one first and we won't delete the second
532+
# one since `MOI.is_valid(b, ci)` will be `false`.
521533
for ci in Iterators.reverse(Constraint.variable_constraints(c_map, vi))
522534
if MOI.is_valid(b, ci)
523535
MOI.delete(b, ci)

0 commit comments

Comments
 (0)