Skip to content

Commit

Permalink
box approximation of a Taylor model
Browse files Browse the repository at this point in the history
  • Loading branch information
schillic committed Jan 25, 2024
1 parent ee8366f commit 14b8747
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Approximations/box_approximation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,19 @@ function box_approximation(ms::MinkowskiSum)
H2 = box_approximation(second(ms))
return minkowski_sum(H1, H2)
end

# function to be loaded by Requires
function load_taylormodels_box_approximation()
return quote
using .TaylorModels: TaylorModel1, TaylorModelN, domain, evaluate

box_approximation(vTM::Vector{<:TaylorModel1}) = _box_approximation_vTM(vTM)

box_approximation(vTM::Vector{<:TaylorModelN}) = _box_approximation_vTM(vTM)

function _box_approximation_vTM(vTM)
B = IA.IntervalBox([evaluate(vTM[i], domain(p)) for (i, p) in enumerate(vTM)]...)
return convert(Hyperrectangle, B)
end
end
end # quote / load_taylormodels_box_approximation
1 change: 1 addition & 0 deletions src/Approximations/init_TaylorModels.jl
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
eval(load_taylormodels_box_approximation())
eval(load_taylormodels_overapproximation())
23 changes: 23 additions & 0 deletions test/Approximations/box_approximation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,27 @@ for N in [Float64]
# slightly contradicting bounds are interpreted as a flat set
X = HalfSpace(N[-1], N(0)) HalfSpace(N[1], N(-1e-15))
@test box_approximation(X) == Hyperrectangle(N[-5.0e-16], N[0])

# box approximation of Taylor model
# (currently gives different result for non-Float64:
# https://github.com/JuliaIntervals/TaylorModels.jl/issues/158)
I = interval(N(0), N(0)) # interval remainder
# TaylorModel1
t = TaylorModels.Taylor1(3)
q₁ = 1 + 2 * t + 2 * t^2
D = interval(N(-1), N(1))
x0 = IA.mid(D)
vTM = [TaylorModels.TaylorModel1(q₁, I, x0, D)]
@test box_approximation(vTM) == Hyperrectangle(N[2], N[3])
# TaylorModelN
x₁, x₂, x₃ = set_variables(N, ["x₁", "x₂", "x₃"]; order=5)
p₁ = 1 + x₁ - x₂
p₂ = x₃ - x₁
Dx₁ = interval(N(-1), N(1))
Dx₂ = interval(N(-1), N(1))
Dx₃ = interval(N(-1), N(1))
D = Dx₁ × Dx₂ × Dx₃
x0 = IntervalBox(IA.mid.(D)...)
vTM = [TaylorModels.TaylorModelN(pi, I, x0, D) for pi in [p₁, p₂]]
@test box_approximation(vTM) == Hyperrectangle(N[1, 0], N[2, 2])
end

0 comments on commit 14b8747

Please sign in to comment.