-
Notifications
You must be signed in to change notification settings - Fork 94
Update tests with add_constrained_variable(s) #803
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
Conversation
This is an issue, because people reading the tests and writing the tests won't know which one to use. Could we test |
It's kind of similar with |
Codecov Report
@@ Coverage Diff @@
## master #803 +/- ##
==========================================
+ Coverage 94.09% 94.21% +0.11%
==========================================
Files 59 59
Lines 6795 6892 +97
==========================================
+ Hits 6394 6493 +99
+ Misses 401 399 -2
Continue to review full report at Codecov.
|
Adding these tests would be good, but this doesn't address the issue of MOI.add_constrained_variables(model, MOI.RotatedSecondOrderCone(4)) Are there any solvers for which a bridge would apply to: MOI.add_constrained_variable(model, MOI.LessThan(0.0)) ? |
Yes, SDP need variable bridges for any variable that's not added with add_constrained_variables with Nonnegatives or PSD. |
What does this mean for variables with both lower and upper bounds? |
One of the bounds will be transformed to an affine constraint via the Constraint.FunctionizeBridge and then the SlackBridge will create another variable. For interval and free variables. You need to create to variables in SDP solvers |
What I don't understand is the asymmetry. If you want to impose How will SDP solvers be able to handle the following: x = add_variable(model)
add_constraint(model, x, LessThan(10.0))
add_constraint(model, x, GreaterThan(1.0)) ? |
With: x = add_variable(model)
add_constraint(model, x, LessThan(10.0))
add_constraint(model, x, GreaterThan(10.0)) you first create a free variables which is bridged into one nonnegative + one nonpositive using the FreeBridge and then the Nonpositive is bridged to Nonnegative using the FlipSignBridge. If you write x = add_constrained_variable(model, LessThan(10.0))
add_constraint(model, x, GreaterThan(10.0)) you only create 2: the nonnegative variables |
Minor: this seems wasteful since I'm not aware of solvers that that don't support free variables but do support nonnegative variables. Could you bridge them into a difference of two nonpositive variables and save an extra transformation? Ok, I see why |
Transforming into an nonnegatives and a nonpositives seems cleaner as it does not favor any cone. As it's for SDP solver, saving a variable bridge shouldn't be critical for performance.
There is no need as they support free variables. There is no strict reason to use it or not use it. Just like with VectorAffine vs ScalarAffine, we should do a bit of both to have good coverage.
(SDPT3 will probably do but the wrapper is not done yet, I was waiting for variable bridges.) However, even if you use a bridged followed by a caching optimizer, since LazyBridgeOptimizer decides whether it bridges or not only depending on |
This should be done systematically. It should be clear to a reader what each tests is designed to cover. Sprinkling |
I agree but this is how The current rule could be: use |
It's natural to favor nonnegatives because there are zero solvers that support nonpositives and do not support nonnegatives.
What if we make it easier to run the tests with cache then bridges then cache? This is the default configuration for JuMP, so we'd be testing out the same pathway that JuMP uses. Then there's no need to use
Yes, but adding on top of a mess only makes it worse. I'm looking for better alternatives. If we really can't find any, then I would be satisfied with additional comments and a new issue opened. |
Ok let's change that in the bl/variable_bridges PR.
Ok so say that the tests try to mirror what JuMP would call, and would also show what's recommended. So given a
If a solver need caches to passes the tests, he's responsible to add them. It may need cache+bridge+cache as with JuMP. |
Hmm. How can we support dropping integrality or removing bounds as we do currently if JuMP created variables with
Solver authors really shouldn't need to understand cache+bridge+cache in order to test their solver. We should provide a few modes of testing, that you can choose easily from, like direct mode, bridge+cache, and cache+bridge+cache. |
I feel like we need some sort of I'd even like a function function how_to_support_constrained_variable(model, sets...)
normal_constraint = [] # Sets that should be supported using add_constraint
constrained_variable = [] # Sets that should be supported using add_constrained_varaible
# ...
return normal_constraint, constrained_variable
end |
Yes, it's just doing two operations (
In general, you should use |
What happens when you use I think there's a conceptual mismatch here that accounts for some of the confusion. We think of If you think of It might help to have an offline discussion. |
dbc1068
to
9c0faa4
Compare
Just changed the PR. It only modifies |
9c0faa4
to
a733d97
Compare
Use
add_constrained_variable
andadd_constrained_variables
instead ofadd_variable
/add_variables
in a few tests.Also create a new rotated SOC test.
There is no rule on whether one should use
add_variable
oradd_constrained_variable
in the tests except in some places where usingadd_constrained_variable
would not work as the test use modification not supported by the bridge.The tests are run with an SDPA model in
test/Bridges/lazy_bridge_optimizer.jl
to make sure tests don't do the wrong choice in #759Extracted from #759