Skip to content

Instantly share code, notes, and snippets.

@mforets
Last active March 25, 2019 04:46
Show Gist options
  • Select an option

  • Save mforets/8bbb915c14d235e2e4097de29ce20d46 to your computer and use it in GitHub Desktop.

Select an option

Save mforets/8bbb915c14d235e2e4097de29ce20d46 to your computer and use it in GitHub Desktop.
compute with an invariant in validated integ
$ git diff
diff --git a/REQUIRE b/REQUIRE
index ba1d010..87bc2e0 100644
--- a/REQUIRE
+++ b/REQUIRE
@@ -4,3 +4,4 @@ TaylorSeries v0.8.1
IntervalArithmetic v0.15.1
TaylorIntegration v0.4.0
RecipesBase
+LazySets
diff --git a/src/validatedODEs.jl b/src/validatedODEs.jl
index 6e1f278..2743bcb 100644
--- a/src/validatedODEs.jl
+++ b/src/validatedODEs.jl
@@ -1,4 +1,6 @@
# Some methods for validated integration of ODEs
+using LazySets
+using TaylorModels: Interval
"""
remainder_taylorstep!(f!, t, x, dx, xI, dxI, δI, δt)
@@ -163,7 +165,7 @@ function validated_step!(f!, t::Taylor1{T},
rem::Vector{Interval{T}}, δq_norm::IntervalBox{N,T},
q0::IntervalBox{N,T}, q0box::IntervalBox{N,T}, nsteps::Int,
orderT::Int, abstol::T, parse_eqs::Bool,
- check_property::Function=(t, x)->true) where {N,T}
+ check_property::Function=(t, x)->true, invariant::LazySet=Universe(length(δq_norm))) where {N,T}
#
# One step integration (non-validated)
δt = TaylorIntegration.taylorstep!(f!, t, x, dx, xaux,
@@ -199,6 +201,10 @@ function validated_step!(f!, t::Taylor1{T},
end
xv[nsteps] = evaluate(xTMN, δq_norm) # IntervalBox
+ if is_intersection_empty(convert(Hyperrectangle, xv[nsteps]), invariant)
+ break
+ end
+
if !check_property(t0+δt, xv[nsteps])
δt = δt/2
continue
@@ -220,11 +226,10 @@ function validated_step!(f!, t::Taylor1{T},
return δt
end
-
function validated_integ(f!, qq0::AbstractArray{T,1}, δq0::IntervalBox{N,T},
t0::T, tmax::T, orderQ::Int, orderT::Int, abstol::T;
maxsteps::Int=500, parse_eqs::Bool=true,
- check_property::Function=(t, x)->true) where {N, T<:Real}
+ check_property::Function=(t, x)->true, invariant::LazySet=Universe(length(qq0))) where {N, T<:Real}
# Set proper parameters for jet transport
@assert N == get_numvars()
@@ -297,7 +302,7 @@ function validated_integ(f!, qq0::AbstractArray{T,1}, δq0::IntervalBox{N,T},
# Validated step of the integration
δt = validated_step!(f!, t, x, dx, xaux, tI, xI, dxI, xauxI,
t0, tmax, x0, x0I, xTMN, xv, rem, δq_norm,
- q0, q0box, nsteps, orderT, abstol, parse_eqs, check_property)
+ q0, q0box, nsteps, orderT, abstol, parse_eqs, check_property, invariant)
# New initial conditions and time
nsteps += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment