IntervalOptimisation.jl
IntervalOptimisation.jl copied to clipboard
Fails to optimize expressions containing a sup/inf on an interval valued function.
y = Interval(-0.1,0.1)
k(x) = ( ((x+y)- 2)^6 + 0.2 ) * (log(1+(x+y)^2))
global_min, minimisers = minimise(x -> sup(k(x)), -0.2..3)
results in:
ERROR: MethodError: no method matching sup(::Float64)
Closest candidates are:
sup(::Interval) at C:\Users\freemint\.julia\packages\IntervalArithmetic\UR6Qe\src\intervals\arithmetic.jl:306
sup(::DecoratedInterval{T}) where T at C:\Users\freemint\.julia\packages\IntervalArithmetic\UR6Qe\src\decorations\functions.jl:54
Stacktrace:
[1] minimise(f::var"#1#2", X::Interval{Float64}; structure::Type{HeapedVector}, tol::Float64)
@ IntervalOptimisation C:\Users\freemint\.julia\packages\IntervalOptimisation\deTUP\src\optimise.jl:40
[2] minimise(f::Function, X::Interval{Float64})
@ IntervalOptimisation C:\Users\freemint\.julia\packages\IntervalOptimisation\deTUP\src\optimise.jl:22
[3] top-level scope
@ REPL[5]:1
However:
julia> sup(x::Real) = x
sup (generic function with 3 methods)
julia> inf(x::Real) = x
inf (generic function with 3 methods)
does not fix it and raises a new issue which suggests that there might be something else going on.
ERROR: ArgumentError: reducing over an empty collection is not allowed
Stacktrace:
[1] _empty_reduce_error()
@ Base .\reduce.jl:299
[2] reduce_empty(op::Function, #unused#::Type{Real})
@ Base .\reduce.jl:309
[3] mapreduce_empty(#unused#::typeof(identity), op::Function, T::Type)
@ Base .\reduce.jl:343
[4] reduce_empty(op::Base.MappingRF{typeof(identity), typeof(min)}, #unused#::Type{Real})
@ Base .\reduce.jl:329
[5] reduce_empty_iter
@ .\reduce.jl:355 [inlined]
[6] mapreduce_empty_iter(f::Function, op::Function, itr::Vector{Real}, ItrEltype::Base.HasEltype)
@ Base .\reduce.jl:351
[7] _mapreduce(f::typeof(identity), op::typeof(min), #unused#::IndexLinear, A::Vector{Real})
@ Base .\reduce.jl:400
[8] _mapreduce_dim
@ .\reducedim.jl:318 [inlined]
[9] #mapreduce#672
@ .\reducedim.jl:310 [inlined]
[10] mapreduce
@ .\reducedim.jl:310 [inlined]
[11] #_minimum#694
@ .\reducedim.jl:878 [inlined]
[12] _minimum
@ .\reducedim.jl:878 [inlined]
[13] #_minimum#693
@ .\reducedim.jl:877 [inlined]
[14] _minimum
@ .\reducedim.jl:877 [inlined]
[15] #minimum#691
@ .\reducedim.jl:873 [inlined]
[16] minimum(a::Vector{Real})
@ Base .\reducedim.jl:873
[17] minimise(f::var"#3#4", X::Interval{Float64}; structure::Type{HeapedVector}, tol::Float64)
@ IntervalOptimisation C:\Users\freemint\.julia\packages\IntervalOptimisation\deTUP\src\optimise.jl:60
[18] minimise(f::Function, X::Interval{Float64})
@ IntervalOptimisation C:\Users\freemint\.julia\packages\IntervalOptimisation\deTUP\src\optimise.jl:22
[19] top-level scope
@ REPL[11]:1
@Suavesito-Olimpiada could you see if that issue vanishes on your fix for #62 ?
No, it does not work. But... if you change your algorithm to this t works
k(x, y) = (((x+y) - 2)^6 + 0.2) * log(1 + (x+y)^2)
global_min, minimisers = minimise(x -> k(x[1], x[2]), (-0.2..3) × (-0.1..0.1))
@Suavesito-Olimpiada Thanks for trying it out.
You are solving an entirely different problem in your suggestions. I want something along the lines of min_x max_y f(x,y) not min_{x,y} f(x,y).
Ok, now I see what you're trying to do. I don't know is this kind of algorithms are really suited for finding minmax
of functions. Maybe this is a theoretical difficulty.