Latest recommendations for global optimization

Thanks for the figure. I had defined the interval version wrong.
Here’s take 2:

"Evaluate interval function with piecewise region--function pairs"
function piecewise(pieces::Vector{<:Pair}, X)
    return reduce(∪, f(X ∩ region) for (region, f) in pieces)
end

X = 2..5
f2 = X -> piecewise([0..3 => x->x+1,
            3..6 => x->x,
            6..∞ => x->x+2], X)

f(x) = sum(f2 ∘ abs, x)

B = IntervalBox(-10..10, 10)

julia> @time minimum, minimisers = minimise(f, B, tol=1e-6);
  0.011364 seconds (198.56 k allocations: 7.963 MiB)

julia> minimum
[10, 10]

julia> minimisers
1-element Array{IntervalBox{10,Float64},1}:
 [-5.98024e-08, 5.12973e-07] × [-5.98024e-08, 5.12973e-07] × [-5.98024e-08, 5.12973e-07] × [-5.98024e-08, 5.12973e-07] × [-5.98024e-08, 5.12973e-07] × [-5.98024e-08, 5.12973e-07] × [-5.98024e-08, 5.12973e-07] × [-5.98024e-08, 5.12973e-07] × [-5.98024e-08, 5.12973e-07] × [-5.98024e-08, 5.12973e-07]

It wouldn’t (I think) be too difficult to extend this to piecewise functions where the range was not given explicitly as here, but rather by a condition like x^2 + y^2 \le 1.

The conversion of ifs to piecewise functions like this is trickier…

EDIT: Julia + intervals makes defining piecewise functions so beautiful!

3 Likes