-
Notifications
You must be signed in to change notification settings - Fork 4
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
Port validated integ from TaylorModels #614
Merged
mforets
merged 18 commits into
JuliaReach:master
from
aa25desh:aadesha/port_validated_integ
Apr 18, 2019
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
805560e
Create reach.jl
aa25desh 0140b17
Update TMJets.jl
aa25desh 5f70ee1
Update post.jl
aa25desh b2776a5
Update post.jl
aa25desh c61f2fe
Update post.jl
aa25desh 8de66ac
Update reach.jl
aa25desh cb1f51a
Update reach.jl
aa25desh 5febd49
Update reach.jl
aa25desh e84a6fd
Delete reach.jl
aa25desh 9926418
Add files via upload
aa25desh a57791b
Update reach.jl
aa25desh e6557d4
Update reach.jl
aa25desh 8426f3c
Update reach.jl
aa25desh a5655d1
Update src/ReachSets/ContinuousPost/TMJets/reach.jl
mforets 7396b6d
Update reach.jl
aa25desh 1e73877
Update reach.jl
aa25desh 6899b09
Update REQUIRE
aa25desh f1d1b6f
Update reach.jl
aa25desh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ Suppressor 0.1.1 | |
IntervalArithmetic | ||
TaylorModels 0.1.0 | ||
TaylorSeries 0.9.1 | ||
TaylorIntegration 0.4.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ TMJets() = TMJets(Options()) | |
include("init.jl") | ||
include("post.jl") | ||
include("project.jl") | ||
include("reach.jl") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#=Copyright (c) 2018-2019: David Sanders and Luis Benet. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE.=# | ||
|
||
using TaylorSeries | ||
using TaylorIntegration:jetcoeffs! | ||
using TaylorModels: validated_step!,TaylorModelN | ||
import IntervalArithmetic | ||
|
||
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} | ||
# Set proper parameters for jet transport | ||
|
||
@assert N == get_numvars() | ||
dof = N | ||
# if get_order() != orderQ | ||
# set_variables("δ", numvars=dof, order=orderQ) | ||
# end | ||
# Some variables | ||
|
||
R = IntervalArithmetic.Interval{T} | ||
q0 = IntervalBox(qq0) | ||
t = t0 + Taylor1(orderT) | ||
tI = t0 + Taylor1(orderT+1) | ||
δq_norm = IntervalBox(IntervalArithmetic.Interval{T}(-1,1),Val(N)) | ||
q0box = q0 + δq_norm | ||
|
||
# Allocation of vectors | ||
# Output | ||
tv = Array{T}(undef, maxsteps+1) | ||
xv = Array{IntervalBox{N,T}}(undef, maxsteps+1) | ||
# xTMNv = Array{TaylorModelN{N,T,T}}(undef, dof, maxsteps+1) | ||
# Internals: jet transport integration | ||
x = Array{Taylor1{TaylorN{T}}}(undef, dof) | ||
dx = Array{Taylor1{TaylorN{T}}}(undef, dof) | ||
xaux = Array{Taylor1{TaylorN{T}}}(undef, dof) | ||
x0 = Array{TaylorN{T}}(undef, dof) | ||
xTMN = Array{TaylorModelN{N,T,T}}(undef, dof) | ||
# Internals: Taylor1{Interval{T}} integration | ||
xI = Array{Taylor1{IntervalArithmetic.Interval{T}}}(undef, dof) | ||
dxI = Array{Taylor1{IntervalArithmetic.Interval{T}}}(undef, dof) | ||
xauxI = Array{Taylor1{IntervalArithmetic.Interval{T}}}(undef, dof) | ||
x0I = Array{IntervalArithmetic.Interval{T}}(undef, dof) | ||
|
||
# Set initial conditions | ||
zI = zero(R) | ||
Δ = zero.(q0) | ||
rem = Array{IntervalArithmetic.Interval{T}}(undef, dof) | ||
@inbounds for i in eachindex(x) | ||
qaux = normalize_taylor(qq0[i] + TaylorN(i, order=orderQ), δq0, true) | ||
x[i] = Taylor1( qaux, orderT) | ||
dx[i] = x[i] | ||
x0[i] = copy(qaux) | ||
xTMN[i] = TaylorModelN(x[i][0], zI, q0, q0box) | ||
# | ||
xI[i] = Taylor1( q0box[i], orderT+1 ) | ||
dxI[i] = xI[i] | ||
x0I[i] = qaux(δq_norm) | ||
rem[i] = zI | ||
end | ||
|
||
# Output vectors | ||
@inbounds tv[1] = t0 | ||
@inbounds xv[1] = IntervalBox( evaluate(xTMN, δq_norm) ) | ||
# @inbounds xTMNv[:, 1] .= xTMN[:] | ||
|
||
# Determine if specialized jetcoeffs! method exists (built by @taylorize) | ||
parse_eqs = parse_eqs && (length(methods(jetcoeffs!)) > 2) | ||
if parse_eqs | ||
try | ||
jetcoeffs!(Val(f!), t, x, dx) | ||
catch | ||
parse_eqs = false | ||
end | ||
end | ||
|
||
# Integration | ||
nsteps = 1 | ||
while t0 < tmax | ||
|
||
# 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) | ||
|
||
# New initial conditions and time | ||
nsteps += 1 | ||
t0 += δt | ||
@inbounds t[0] = t0 | ||
@inbounds tI[0] = t0 | ||
@inbounds tv[nsteps] = t0 | ||
@inbounds for i in eachindex(x) | ||
aux = x[i](δt) | ||
x[i] = Taylor1( aux, orderT ) | ||
dx[i] = Taylor1( zero(aux), orderT ) | ||
end | ||
# @show(IntervalBox(rem)) | ||
# @inbounds xTMNv[:, nsteps] .= xTMN[:] | ||
|
||
# println(nsteps, "\t", t0, "\t", remainder.(xTMN[:]), "\t", diam(Δ)) | ||
if nsteps > maxsteps | ||
@info(""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is better to do |
||
Maximum number of integration steps reached; exiting. | ||
""") | ||
break | ||
end | ||
|
||
end | ||
|
||
return view(tv,1:nsteps), view(xv,1:nsteps)#, view(xTMNv, 1:nsteps, :) | ||
end | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove the commented code in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I'd like to make that and in general use our guidelines https://github.com/JuliaReach/JuliaReachDevDocs/