Closed eeshan9815 closed 6 years ago
Thanks! I don't see the benchmarks though.
I manually benchmarked, and shared the results on #intervals in slack
Please include at least the benchmarking script (using BenchmarkTools) in a new directory perf
.
I have included the script and results for n = 1:25 cc @dpsanders
That's the kind of thing I had in mind, thanks. You could instead collect the data using @belapsed
(I think) and output a table using Dataframes or something like that.
Okay, I'll try it out!
So which version of the function should I retain? I don't think MArray
improved the performance a lot.
Try à version using IntervalBox and setindex.
IntervalBox is immutable like an SVector. So modifying it actually requires making a new copy and changing the relevant entry using setindex (without !)
This needs tests.
@dpsanders Travis and AppVeyor both use the latest tagged version and don't have extended_div
, and hence are failing.
I tried to tag a new version but it was causing failures in ValidatedNumerics. I did some upgrades, but I think we should plan carefully how to make patches-versions, so they don't break everything. See this comment.
Actually the matrix version could be pretty efficient when using SMatrix and SVector everywhere. Have you tried that?
Done. I think this version gives the best benchmarks.
So it seems just using normal arrays is fine?
So it seems just using normal arrays is fine?
More or less, yes. Should I remove the other implementations and update the PR?
You should squash down the implementations as I suggested; I think you should leave all of them for now.
Could you please add the example from the Jaulin book in the examples
folder?
Actually you should keep a separate repo, e.g. in your GitHub account or in JuliaIntervals, with a Jupyter notebook with usage examples and explanation.
@dpsanders Is this accurate?
@dpsanders I've added the gaussian elimination with preconditioning and benchmarking against Base.\
ping @dpsanders
This and your other PRs need rebasing on current master, sorry!
Done rebasing and tests pass on the current IntervalArithmetic
master
There is still (or again) a conflict in test/runtests.jl
.
(sorry, wrong button)
Oh that occurred due to the merging of #70. I have rebased again.
@eeshan9815 Tests are still failing. Do you know what is happening?
Tests fail as it uses extended_div
which is not in the latest tagged version of IntervalArithmetic
.
Tests pass locally if the current master is used.
Ah great, thanks
I have redefined \
for Interval
s. Currently, it uses the gauss_elimination_interval
method with precondition=true
.
This is due to the advantages of preconditioning such as reducing dependence mentioned in various books such as Global Optimisation using Interval Analysis by Eldon Hansen.
Since \
is same as gauss_elimination_interval
, for which tests exist already, is there a need to define tests for \
separately?
Also, comparisions exist in the perf/linear_eq_tabular.txt
file.
Right, but the tests are also for future-proofing, eg if we change the implementation of \ again. So you can just add a couple of tests to make sure the output of \ and gaussian elim are the same.
@eeshan9815 Did you actually check that the definition of \
in the package is being called? It doesn't seem to be. You need to import Base: \
.
On the example in the testset "Linear Equations", the new definition seems to be worse than using Base's \
.
I have imported Base.\
in IntervalRootFinding.jl
and it seems to be using gauss_elimination_interval
instead of Base.\
Also, preconditioning widens the solution set by a little bit. It's a trade-off mentioned in the Hansen book as well.
Hmm, I see, sorry. I don't know why it didn't work for me, then.
What's the advantage of preconditioning, then? I thought it was supposed to narrow, not widen, the result.
After checking out your PR, I get
julia> A = [4..5 -1..1 1.5..2.5; -0.5..0.5 -7.. -5 1..2; -1.5.. -0.5 -0.7.. -0.5 2..3]
3×3 Array{IntervalArithmetic.Interval{Float64},2}:
[4, 5] [-1, 1] [1.5, 2.5]
[-0.5, 0.5] [-7, -5] [1, 2]
[-1.5, -0.5] [-0.700001, -0.5] [2, 3]
julia> b = [3..4, 0..2, 3..4]
3-element Array{IntervalArithmetic.Interval{Float64},1}:
[3, 4]
[0, 2]
[3, 4]
julia> A \ b
3-element Array{IntervalArithmetic.Interval{Float64},1}:
[-1.81928, 1.16873]
[-0.41407, 1.72523]
[0.700232, 3.42076]
julia> @which A \ b
\(A::AbstractArray{T,2} where T, B::Union{AbstractArray{T,1}, AbstractArray{T,2}} where T) in Base.LinAlg at linalg/generic.jl:820
which shows that the \
from Base
is being used. Not sure why.
Ignore me, I seem not to have managed to checkout the latest version, apologies.
No, don't ignore me -- you defined \
in test/linear_eq.jl
instead of in the source code!
No problem, thanks!
Running gauss_seidel
seems to modify something it shouldn't? The result of A \ b
shouldn't change in the following session:
julia> IntervalRootFinding.gauss_elimination_interval(A, b)
2-element Array{IntervalArithmetic.Interval{Float64},1}:
[-130.228, 167.728]
[-60.0001, 267.273]
julia> IntervalRootFinding.gauss_elimination_interval(A, b, precondition=false)
2-element Array{IntervalArithmetic.Interval{Float64},1}:
[-120, 90]
[-60, 240]
julia> IntervalRootFinding.gauss_seidel_interval(A, b, precondition=false)
2-element Array{IntervalArithmetic.Interval{Float64},1}:
[-5e+15, 5.00001e+15]
[-1e+16, 1e+16]
julia> A
2×2 Array{IntervalArithmetic.Interval{Float64},2}:
[2, 3] [0, 1]
[1, 2] [1, 3]
julia> b
2-element Array{IntervalArithmetic.Interval{Float64},1}:
[0, 120]
[-60, 240]
julia> A \ b
2-element Array{IntervalArithmetic.Interval{Float64},1}:
[-1e+16, 1e+16]
[-1e+16, 1e+16]
I think this needs more tests. E.g. the gauss_seidel
methods give huge pointless answers for the single test case.
@eeshan9815 There seems to be a real test failure here.
The test failure appears to be in a test for 2D roots, giving error messages similar to the ones faced when the SVector
was initially made a data member of IntervalBox
.
It should work after merging #83
The incorrect modification issue has also been resolved.
julia> IntervalRootFinding.gauss_elimination_interval(A, b)
2-element Array{IntervalArithmetic.Interval{Float64},1}:
[-130.228, 167.728]
[-60.0001, 267.273]
julia> IntervalRootFinding.gauss_elimination_interval(A, b, precondition=false)
2-element Array{IntervalArithmetic.Interval{Float64},1}:
[-120, 90]
[-60, 240]
julia> IntervalRootFinding.gauss_seidel_interval(A, b, precondition=false)
2-element Array{IntervalArithmetic.Interval{Float64},1}:
[-120.001, 90.0001]
[-60.0001, 240.001]
julia> A
2×2 Array{IntervalArithmetic.Interval{Float64},2}:
[2, 3] [0, 1]
[1, 2] [2, 3]
julia> b
2-element Array{IntervalArithmetic.Interval{Float64},1}:
[0, 120]
[60, 240]
julia> A \ b
2-element Array{IntervalArithmetic.Interval{Float64},1}:
[-130.228, 167.728]
[-60.0001, 267.273]
@eeshan9815 Tests are now passing. Is this ready?
Yes, I think so. I added 88 tests (mostly randomly generated) to make sure the methods are working.
Thanks very much!
Codecov Report
4.65% <ø> (+2.61%)
85.13% <85.13%> (ø)
90% <0%> (-0.48%)
0% <0%> (ø)
0% <0%> (ø)
88.13% <0%> (+2.19%)
83.33% <0%> (+8.33%)
Continue to review full report at Codecov.