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

Complete rewrite using generic branch and prune with contractors #24

Merged
merged 38 commits into from
Mar 3, 2018

Conversation

dpsanders
Copy link
Member

No description provided.

This was referenced Jun 30, 2017
Copy link
Member

@lbenet lbenet left a comment

Choose a reason for hiding this comment

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

LGTM, and we should merge it, urgently :-)

The question is what to do with the tests. I am aware this is related to other issues (https://github.com/JuliaIntervals/IntervalArithmetic.jl/pull/97/files)




h(x) = SVector(2*x - y - exp(-x), -x + 2*y - exp(-y))
Copy link
Member

Choose a reason for hiding this comment

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

Running this example throws an error here. I guess you need something like:
h(xv) = ( (x, y) = xv; SVector(2*x - y - exp(-x), -x + 2*y - exp(-y)))

h(x) = SVector(2*x - y - exp(-x), -x + 2*y - exp(-y))

rts = roots(h, X × X, Bisection)
rts = roots(rts, g, Newton)
Copy link
Member

Choose a reason for hiding this comment

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

Another error is thrown here. My guess is that this should read as rts = roots(h, rts, Newton)



# Dennis-Schnabel:
h(x) = SVector(x^2 + y^2 - 2, exp(x - 1) + y^3 - 2)
Copy link
Member

Choose a reason for hiding this comment

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

I guess you need to correct this function similarly as above.


# Dennis-Schnabel:
h(x) = SVector(x^2 + y^2 - 2, exp(x - 1) + y^3 - 2)

Copy link
Member

Choose a reason for hiding this comment

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

The following two lines should read as:

rts = roots(h, X × X, Bisection)
rts = roots(h, rts, Newton)


## MINPACK benchmarks: https://github.com/JuliaNLSolvers/NLsolve.jl/blob/master/test/minpack.jl

using IntervalArithmetic, IntervalRootFinding, StaticArrays
Copy link
Member

Choose a reason for hiding this comment

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

This is not needed.

@@ -0,0 +1,205 @@
using IntervalRootFinding
using IntervalRootFinding: Root
Copy link
Member

Choose a reason for hiding this comment

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

I think these first two using clauses are not needed.

Inputs:
- `f`: function whose roots will be found
- `X`: `Interval` or `IntervalBox`
- `contractor`: function that, when applied to the function `f`, determines the status of a given box `X`. It returns the new box and a symbol indicating the status.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe an example of the contractor is helpful in the docstrings.

Copy link
Member

Choose a reason for hiding this comment

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

After reading the code, maybe you should specify the possible contractor types.



contains_zero{T}(X::Interval{T}) = zero(T) ∈ X
contains_zero(X::SVector) = all(contains_zero(X[i]) for i in 1:length(X))
Copy link
Member

Choose a reason for hiding this comment

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

Use here (and below) broadcasting: contains_zero(X::SVector) = all(contains_zero.(X))

end


roots{C<:Contractor}(f, X, contractor::Type{C}, tol::Float64=1e-3) = branch_and_prune(f, X, contractor, tol)
Copy link
Member

Choose a reason for hiding this comment

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

Add docstrings for roots

@lbenet
Copy link
Member

lbenet commented Mar 2, 2018

I have done some work here for tests to pass. Essentially some functions are currently unexported, among other minor things. Shall I commit directly to this branch, or shall I do it in an alternative one?

@dpsanders
Copy link
Member Author

Just add it to this huge branch I think. Thanks!

@lbenet
Copy link
Member

lbenet commented Mar 2, 2018

Just pushed a PR which allows to pass tests locally.

If you can take a look on the changes it would be worth doing it, because I think your plan was to deprecate/erase some of the previous functions (e.g., use roots instead of newton or krawczyk).

@codecov-io
Copy link

codecov-io commented Mar 2, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@39e0514). Click here to learn what that means.
The diff coverage is 74.07%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #24   +/-   ##
=========================================
  Coverage          ?   78.22%           
=========================================
  Files             ?        7           
  Lines             ?      271           
  Branches          ?        0           
=========================================
  Hits              ?      212           
  Misses            ?       59           
  Partials          ?        0
Impacted Files Coverage Δ
src/IntervalRootFinding.jl 88.67% <ø> (ø)
src/bisection.jl 0% <0%> (ø)
src/newton.jl 68.49% <59.25%> (ø)
src/complex.jl 60% <60%> (ø)
src/branch_and_prune.jl 84.61% <84.61%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 39e0514...2cefebd. Read the comment docs.

@lbenet
Copy link
Member

lbenet commented Mar 2, 2018

Done; tests are passing...

@dpsanders
Copy link
Member Author

Thanks for the tests! I have added a basic docstring for roots.

I think we should merge this and refine later!

@dpsanders
Copy link
Member Author

I converted some of examples.jl into new tests, which pass.
Merging this for now!

@dpsanders dpsanders merged commit 5dd515b into master Mar 3, 2018
@lbenet lbenet deleted the contractors branch June 25, 2018 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants