JuliaIntervals / IntervalRootFinding.jl

Library for finding the roots of a function using interval arithmetic
https://juliaintervals.github.io/IntervalRootFinding.jl/
Other
126 stars 26 forks source link

Make a RootProblem type #109

Open dpsanders opened 5 years ago

dpsanders commented 5 years ago

It may be useful to have a RootProblem type that encodes the function, the IntervalBox, the dimension, etc.

dpsanders commented 5 years ago

Here's a possible definition for a type to wrap a function:

"""
Type representing a function to be used in a branch and bound algorithm
"""

struct BranchAndBoundFunction{F,N,T}
    f::F
    X::IntervalBox{N,T}
    input_dim::Int
    output_dim::Int

    function BranchAndBoundFunction(f::F, X::IntervalBox{N,T}) where {F<:Function,N,T}
        new{F,N,T}(f, X, N, length(f(X)))
    end
end

(f::BranchAndBoundFunction{F,N,T})(X::IntervalBox{N,T}) where {F,N,T} = f.f(X)