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

Fails to optimize expressions containing a sup/inf on an interval valued function. #67

Open
freemin7 opened this issue Nov 30, 2021 · 4 comments

Comments

@freemin7
Copy link

freemin7 commented Nov 30, 2021

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
@freemin7
Copy link
Author

freemin7 commented Nov 30, 2021

@Suavesito-Olimpiada could you see if that issue vanishes on your fix for #62 ?

@Suavesito-Olimpiada
Copy link
Contributor

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))

@freemin7
Copy link
Author

freemin7 commented Nov 30, 2021

@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).

@Suavesito-Olimpiada
Copy link
Contributor

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.

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

No branches or pull requests

2 participants