-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bridges] add IntegerToZeroOneBridge #2205
Conversation
ret = MOI.Utilities.get_bounds(model, T, bridge.x) | ||
if ret === bridge.last_bounds | ||
return nothing # final_touch already called | ||
elseif ret[1] == typemin(T) || ret[2] == typemax(T) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably have a utility for that shared with SplitInterval
and other bridges doing this like is_infinity
. In Interval
we take care of Int
where we never one to consider no bound while we don't do it here. At least it would make sure we are consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the SplitInterval reference. The SplitInterval bridge doesn't rely on a finite domain, it works with one-sided intervals. In comparison, we can't bridge an open set to ZeroOne (unless we pick a big M and do a 20 or 30 bit expansion?).
push!(bridge.y, y) | ||
push!(f.terms, MOI.ScalarAffineTerm(-(T(2)^(i - 1)), y)) | ||
end | ||
bridge.ci = MOI.add_constraint(model, f, MOI.EqualTo{T}(lb)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable bridge spirit would be to substitute x
. Here it seems to be a bad idea because it x
is a big sum.
This is like bridge a constrained variables x in Int
by first adding the variable free and constraining it, then functionizing it and then slack bridge and then variable bridge for the slack. I'm wondering if there could be a nice way to implement this as a variable bridge but defaulting it to be used like that while allowing the user to have x
be substituted as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you just drop a comment that it would more naturally be implemented as a variable bridge but we don't want to substitute every occurence of x
so that's why we do it as a constraint bridge ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if there could be a nice way to implement this as a variable bridge
That would only be necessary for a solver supports only binary variables and not real. We don't really have any current examples, although @ccoffrin might be interested for future quantum annealing formulations. (They have some pretty specific structure restrictions though, which mean doing it naively might be the wrong thing to do.)
fbb830b
to
5fcee87
Compare
Is there anything else to do here? |
Closes #2202
Basic
src/Bridges/XXX/bridges
struct must end in
Bridge
MOI.Bridges.Constraint.SetMapBridge
const
that is aSingleBridgeOptimizer
wrapping thenew bridge. The name of the const must be the name of the bridge, less
the
Bridge
suffixinclude
the file insrc/Bridges/XXX/bridges/XXX.jl
add_all_bridges
at the bottom ofsrc/Bridges/XXX/XXX.jl
Tests
tests/Bridges/XXX
MOI.Bridges.runtests
to test various inputs and outputs of thebridge
covered by the tests, add additional bridge-specific tests to cover the
untested lines.
Documentation
docs/src/submodules/Bridges/list_of_bridges.md
Final touch
If the bridge depends on run-time values of other variables and constraints in
the model:
MOI.Utilities.needs_final_touch(::Bridge)
MOI.Utilities.final_touch(::Bridge, ::MOI.ModelLike)
final_touch
can be called multiple times in a row