@@ -717,26 +717,25 @@ function _get_all_including_bridged(
717717 b:: AbstractBridgeOptimizer ,
718718 attr:: MOI.ListOfVariableIndices ,
719719)
720- list = MOI. get (b. model, attr)
721- # This is about to get confusing. `list` contains the variables in `.model`
722- # ordered by when they were added to the model. We need to return a list of
723- # the original user-space variables in the order that they were added. To do
724- # so, we need to undo any Variable.bridges transformations.
725- #
726720 # `inner_to_outer` is going to map variable indices in `b.model` to their
727721 # bridged variable indices. If the bridge adds multiple variables, we need
728722 # only to map the first variable, and we can skip the rest. To mark this
729723 # distinction, the tail variables are set to `nothing`.
724+ map = Variable. bridges (b)
730725 inner_to_outer = Dict {MOI.VariableIndex,Union{Nothing,MOI.VariableIndex}} ()
731- for (user_variable, bridge) in Variable . bridges (b)
726+ for (user_variable, bridge) in map
732727 variables = MOI. get (bridge, MOI. ListOfVariableIndices ())
733728 for bridged_variable in variables
734729 inner_to_outer[bridged_variable] = nothing
735730 end
736731 inner_to_outer[first (variables)] = user_variable
737732 end
733+ # We're about to loop over the variables in `.model`, ordered by when they
734+ # were added to the model. We need to return a list of the original
735+ # user-space variables in the order that they were added. To do so, we need
736+ # to undo any Variable.bridges transformations.
738737 ret = MOI. VariableIndex[]
739- for inner_variable in list
738+ for inner_variable in MOI . get (b . model, attr)
740739 outer_variable = get (inner_to_outer, inner_variable, missing )
741740 if ismissing (outer_variable)
742741 # inner_variable does not exist in inner_to_outer, which means that
@@ -750,6 +749,12 @@ function _get_all_including_bridged(
750749 # inner_variable exists in inner_to_outer. It must be the first
751750 # variable in the bridge. Report it back to the user.
752751 push! (ret, outer_variable)
752+ # `outer_variable` might represent the start of a VectorOfVariables
753+ # if multiple user-variables were bridged. Add them all.
754+ n = Variable. length_of_vector_of_variables (map, outer_variable)
755+ for i in 1 : n- 1
756+ push! (ret, MOI. VariableIndex (outer_variable. value - i))
757+ end
753758 end
754759 end
755760 return ret
0 commit comments