-
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
Update MOI.Test to support any coefficient that is a subtype of Real #841
Comments
@JiazhengZhu and I would be interested in this too! Could someone point us to how to go about generalizing the tests? |
Sure! The basic steps are:
|
It might also be a type parameter of |
In #855 some decisions were made about the details of doing this, and I think the following was more-or-less settled on for how to update a set of tests:
This can be mostly done via find-and-replace. Slightly less obvious tricks:
Tests to update:
And unit tests. Maybe those will need a different treatment though? I'm not really sure. After the tests are updated, the tests of the tests will need to be updated. These will (hopefully) not pass until the internal use of (Hope I got that all right, regarding the emergent plan). |
This sounds fantastic. Small incremental steps. |
As an aside that may be relevant to those interested in this issue: I've been setting up a framework similar to MOI's tests in Convex.jl, to allow solvers to test against Convex.jl's tests (what I've been calling the Convex.jl Problem Depot). The Convex.jl MOI branch uses this for its own tests, and I've generalized* them to arbitrary numeric type, which we are using to test the solvers in SDPAFamily.jl (né SDPA_GMP.jl). *: They aren't fully generalized yet; so far I've just updated them so they use an I see this testing framework as complementary to MOI's; it allows end-to-end testing of problems, with a different set of problems than MOI uses. An early version of this (just with Float64s) revealed #838 (the first correctness bug of MOI, at least as far as I could see looking at the |
Is someone actively working on this? If not I may start to. |
That would be great! I’m not actively working on it now, and I don’t think @JiazhengZhu is either, but I can’t speak for anyone else. |
I have been making progress. After #1681, only the 7000 lines of conic tests remain... |
That was a pretty grinding few days, but it was faster than I thought it would be. We now run a standard MathOptInterface.jl/test/Test/Test.jl Lines 52 to 69 in bc0bf1b
This runs. all the tests automatically, so it should catch us re-introducing Float64 -specific tests.
Closing because I think this is now done. The next release of MOI should be of interest to:
|
Nice work @odow |
I can't promise I got every case, only that it works for BigFloat. For example, I think you'll run into a lot of issues if you use rational arithmetic, but that's probably to be expected because a lot of the tests don't have a rational solution. We could potentially come up with a clever rational check if its a problem. julia> T = Rational{Int}
Rational{Int64}
julia> sqrt(T(2)) isa T
false
julia> T = BigFloat
BigFloat
julia> sqrt(T(2)) isa T
true |
Hypatia doesn't really work with rationals anymore so we won't need that, not sure about Tulip or COSMO |
Same, I dropped Rational a while ago, in part because of the type-instability, in part because of numerical issues (the required precision would quickly explode) |
^ Hashtag relatable |
CDDLib needs |
Looking for an easy way to help contribute to MOI?
Help us by updating the tests so that we can run them with a generic coefficient type, instead of just
Float64
.Problem
I am trying to test a solver that works on a
Model{T}
for anyT <: Real
, but I can only run the vast majority of tests whenT = Float64
.Solution
Things have changed quite a lot since the discussion below. Here's the latest (August 2021):
Step 1: pick a file from https://github.com/jump-dev/MathOptInterface.jl/tree/master/src/Test
Step 2: pick a test which contains explicit
Float64
s. Here's oneMathOptInterface.jl/src/Test/test_variable.jl
Lines 180 to 201 in f08c78c
Step 3: rewrite it to use a type parameter
T
insteadThe text was updated successfully, but these errors were encountered: