Skip to content
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] fix supports for VariableIndex: Take II #1992

Merged
merged 8 commits into from
Sep 11, 2022
Merged

Conversation

odow
Copy link
Member

@odow odow commented Sep 7, 2022

A fix for the fix in #1991.

This is actually a super subtle part of the bridging system, and we don't have good test coverage. I think I understand the space of possible outcomes, and I've tested with Ipopt, SCS, and SDPA etc.

So before merging:

  • Add better tests

@odow odow added Type: Bug Submodule: Bridges About the Bridges submodule labels Sep 7, 2022
@blegat blegat self-requested a review September 7, 2022 08:50
@blegat
Copy link
Member

blegat commented Sep 7, 2022

I'll take a look

# 2. It is added as a free variable, followed by a constraint bridge
# 3. It is added by a variable bridge
# To distinguish between {1.} and {2., 3.}, we call `is_bridged`:
if is_bridged(b, S)
Copy link
Member

Choose a reason for hiding this comment

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

Suppose you have a solver that supports

  • Adding variables constrained on creation in S or T
  • Adding a constraint VAF-in-T

You add variables on creation to S
Then you add a constraint on this vector of variables in T. This is bridged into VAF-in-T.
Here, is_bridged(b, T) is false with a LazyBridgeOptimizer.

There are cases in which both might be possible, it depends whether it was constrained on creation or not. In that case, supports should return true if one of the two cases is true because there is a chance that it is supported.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm going around in circles. Is there a way to tell if a VectorOfVariables was added by add_constrained_variables? Not really just from the type, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

So I think we actually have a much bigger issue that means we can't get this right.

The SingleBridgeOptimizer tests are failing for things like flip_sign.jl, because if you add a VectorOfVariables-in-Nonnegatives constraint, the solver supports the constraint and the attribute. But if you add constrained variables in Nonnegatives, the solver force bridges (even though the model supports it) and the bridge doesn't support the attribute.

But, we can't distinguish whether to return true or false, because given a constraint index we don't know whether it was added as a constraint or a constrained variable.

Copy link
Member

@blegat blegat Sep 8, 2022

Choose a reason for hiding this comment

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

Exactly, given just the type, you cannot know how all constraint of that type will be dealt with.You need to consider all possible cases and return true if at least one case supports it

given a constraint index we don't know whether it was added as a constraint or a constrained variable.

Given a constraint index you can know that but not given just the types

@blegat
Copy link
Member

blegat commented Sep 8, 2022

Note that, as shown by the reduce_bridged function that was removed in #1937, there are 3 places depending on the same logic so if there was something wrong with this one, we should also update the other 2 places accordingly

@odow
Copy link
Member Author

odow commented Sep 10, 2022

So I took a look at this, introducing the || instead of && following your comment #1937 (comment). And it breaks more tests than it fixes. We either give a false negative, or a false positive. I think for now, let's keep this behavior, since it fixes a bug in Ipopt and all current tests remain passing.

@blegat
Copy link
Member

blegat commented Sep 10, 2022

Let's a least keep either an open issue or open PR then

@odow
Copy link
Member Author

odow commented Sep 11, 2022

Okay. I'll merge and open an issue

@odow odow merged commit d9c998a into master Sep 11, 2022
@odow odow deleted the od/bridge-tests branch September 11, 2022 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Submodule: Bridges About the Bridges submodule Type: Bug
Development

Successfully merging this pull request may close these issues.

2 participants