Skip to content

[Bridges] fix support for nested final_touch bridges#3027

Open
odow wants to merge 2 commits into
masterfrom
od/final-touch
Open

[Bridges] fix support for nested final_touch bridges#3027
odow wants to merge 2 commits into
masterfrom
od/final-touch

Conversation

@odow

@odow odow commented Jul 24, 2026

Copy link
Copy Markdown
Member

Now that I understand the fix in #3025, this is a hopefully simpler fix.

Closes #1980!
Closes #3025

Comment thread src/Bridges/bridge_optimizer.jl Outdated
# vector, and then we insert the bridge into the vector. This is an O(N)
# operation in the number of new bridges, but it's a pretty rare edge-case,
# and the number of new bridges should be small. (And in most common bridges
# that need final touch, like the ToMILP bridges, N=0.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's a Vector{Any, can't we just do push!(map.needs_final_touch, nothing) here and then replace it ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we might not need to

n_final_touch = length(map.needs_final_touch)
bridge = Constraint.bridge_constraint(BridgeType, recursive_model(b), f, s)
if MOI.Bridges.needs_final_touch(bridge)
insert!(map.needs_final_touch, n_final_touch + 1, bridge)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer doing these things in Constraint/map.jl, bridge_optimizer.jl

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to make a PR with some changes. This seemed simplest place to put it for me but I might be missing something.

Comment thread src/Bridges/bridge_optimizer.jl Outdated
# vector, and then we insert the bridge into the vector. This is an O(N)
# operation in the number of new bridges, but it's a pretty rare edge-case,
# and the number of new bridges should be small. (And in most common bridges
# that need final touch, like the ToMILP bridges, N=0.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is N=0 for MILP bridge ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They don’t add any bridges that themselves need final touch

Clarify comments regarding bridge insertion and final touch requirements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Adding a bridge that needs final_touch bridges in the final_touch of another bridge

2 participants