-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
521 additions
and
634 deletions.
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
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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
const A = 1.0 | ||
const B = 1.5 | ||
const B1 = B + 1 | ||
|
||
@taylorize function brusselator!(du, u, p, t) | ||
local A = 1.0 | ||
local B = 1.5 | ||
local B1 = B + 1 | ||
|
||
x, y = u | ||
x² = x * x | ||
aux = x² * y | ||
du[1] = A + aux - B1 * x | ||
du[2] = B * x - aux | ||
|
||
x²y = x^2 * y | ||
du[1] = A + x²y - B1 * x | ||
du[2] = B * x - x²y | ||
return du | ||
end | ||
|
||
U0(r) = Singleton([1.0, 1.0]) ⊕ BallInf(zeros(2), r) | ||
U0(r) = BallInf([1.0, 1.0], r); | ||
|
||
bruss(r) = @ivp(u' = brusselator!(u), u(0) ∈ U0(r), dim:2) | ||
bruss(r) = @ivp(u' = brusselator!(u), u(0) ∈ U0(r), dim:2); |
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 |
---|---|---|
@@ -1,112 +1,93 @@ | ||
using ReachabilityAnalysis, SparseArrays, JLD2 | ||
using ReachabilityAnalysis, JLD2, ReachabilityBase.CurrentPath | ||
using ReachabilityBase.Arrays: SingleEntryVector | ||
|
||
LazySets.set_ztol(Float64, 1e-14) | ||
const x25 = SingleEntryVector(25, 48, 1.0) | ||
const x25e = SingleEntryVector(25, 49, 1.0) | ||
|
||
const x25 = [zeros(24); 1.0; zeros(23)] | ||
const x25e = vcat(x25, 0.0) | ||
path = @current_path("Building", "building.jld2") | ||
|
||
examples_dir = normpath(@__DIR__, "..", "..", "..", "examples") | ||
building_path = joinpath(examples_dir, "Building", "building.jld2") | ||
function building_common() | ||
@load path A B | ||
|
||
c = [fill(0.000225, 10); fill(0.0, 38)] | ||
r = [fill(0.000025, 10); fill(0.0, 14); 0.0001; fill(0.0, 23)] | ||
X0 = Hyperrectangle(c, r) | ||
|
||
function building_BLDF01() | ||
@load building_path A B | ||
n = size(A, 1) | ||
U = Interval(0.8, 1.0) | ||
S = @system(x' = Ax + Bu, u ∈ U, x ∈ Universe(n)) | ||
|
||
# initial states | ||
center_X0 = [fill(0.000225, 10); fill(0.0, 38)] | ||
radius_X0 = [fill(0.000025, 10); fill(0.0, 14); 0.0001; fill(0.0, 23)] | ||
X0 = Hyperrectangle(center_X0, radius_X0) | ||
return A, B, X0, U | ||
end | ||
|
||
return prob_BLDF01 = InitialValueProblem(S, X0) | ||
function building_BLDF01() | ||
A, B, X0, U = building_common() | ||
n = size(A, 1) | ||
S = @system(x' = A * x + B * u, u ∈ U, x ∈ Universe(n)) | ||
prob_BLDF01 = InitialValueProblem(S, X0) | ||
return prob_BLDF01 | ||
end | ||
|
||
using ReachabilityAnalysis: add_dimension | ||
|
||
function building_BLDC01() | ||
@load building_path A B | ||
A, B, X0, U = building_common() | ||
n = size(A, 1) | ||
U = Interval(0.8, 1.0) | ||
|
||
# initial states | ||
center_X0 = [fill(0.000225, 10); fill(0.0, 38)] | ||
radius_X0 = [fill(0.000025, 10); fill(0.0, 14); 0.0001; fill(0.0, 23)] | ||
X0 = Hyperrectangle(center_X0, radius_X0) | ||
|
||
Ae = add_dimension(A) | ||
Ae[1:n, end] = B | ||
return prob_BLDC01 = @ivp(x' = Ae * x, x(0) ∈ X0 × U) | ||
end | ||
|
||
using Plots | ||
prob_BLDC01 = @ivp(x' = Ae * x, x(0) ∈ X0 × U) | ||
return prob_BLDC01 | ||
end; | ||
|
||
prob_BLDF01 = building_BLDF01() | ||
prob_BLDF01 = building_BLDF01(); | ||
|
||
sol_BLDF01_dense = solve(prob_BLDF01; T=20.0, alg=LGG09(; δ=0.004, vars=(25), n=48)); | ||
sol_BLDF01_dense = solve(prob_BLDF01; T=20.0, | ||
alg=LGG09(; δ=0.004, vars=(25), n=48)) | ||
|
||
fig = plot(sol_BLDF01_dense; vars=(0, 25), linecolor=:blue, color=:blue, alpha=0.8, lw=1.0, | ||
xlab="t", ylab="x25") | ||
fig = plot(sol_BLDF01_dense; vars=(0, 25), linecolor=:blue, color=:blue, | ||
alpha=0.8, lw=1.0, xlab="t", ylab="x25") | ||
|
||
@assert ρ(x25, sol_BLDF01_dense) <= 5.1e-3 "the property should be proven" # BLDF01 - BDS01 | ||
@assert !(ρ(x25, sol_BLDF01_dense) <= 4e-3) "the property should not be proven" # BLDF01 - BDU01 | ||
ρ(x25, sol_BLDF01_dense) | ||
|
||
ρ(x25, sol_BLDF01_dense) <= 5.1e-3 # BLDF01 - BDS01 | ||
|
||
ρ(x25, sol_BLDF01_dense) <= 4e-3 # BLDF01 - BDU01 | ||
|
||
@assert !(ρ(x25, sol_BLDF01_dense(20.0)) <= -0.78e-3) "the property should not be proven" # BLDF01 - BDU02 | ||
ρ(x25, sol_BLDF01_dense(20.0)) | ||
|
||
ρ(x25, sol_BLDF01_dense(20.0)) <= -0.78e-3 # BLDF01 - BDU02 | ||
|
||
sol_BLDF01_discrete = solve(prob_BLDF01; T=20.0, | ||
alg=LGG09(; δ=0.01, vars=(25), n=48, approx_model=NoBloating())); | ||
|
||
fig = plot(sol_BLDF01_discrete; vars=(0, 25), linecolor=:blue, color=:blue, alpha=0.8, lw=1.0, | ||
xlab="t", ylab="x25") | ||
fig = plot(sol_BLDF01_discrete; vars=(0, 25), linecolor=:blue, color=:blue, | ||
alpha=0.8, lw=1.0, xlab="t", ylab="x25") | ||
|
||
@assert ρ(x25, sol_BLDF01_discrete) <= 5.1e-3 "the property should be proven" # BLDF01 - BDS01 | ||
@assert !(ρ(x25, sol_BLDF01_discrete) <= 4e-3) "the property should not be proven" # BLDF01 - BDU01 | ||
ρ(x25, sol_BLDF01_discrete) | ||
|
||
ρ(x25, sol_BLDF01_discrete) <= 5.1e-3 # BLDF01 - BDS01 | ||
|
||
ρ(x25, sol_BLDF01_discrete) | ||
|
||
ρ(x25, sol_BLDF01_discrete) <= 4e-3 # BLDF01 - BDU01 | ||
|
||
@assert !(ρ(x25, sol_BLDF01_discrete(20.0)) <= -0.78e-3) "the property should not be proven" # BLDF01 - BDU02 | ||
ρ(x25, sol_BLDF01_discrete(20.0)) | ||
|
||
ρ(x25, sol_BLDF01_discrete(20.0)) <= -0.78e-3 # BLDF01 - BDU02 | ||
|
||
prob_BLDC01 = building_BLDC01() | ||
prob_BLDC01 = building_BLDC01(); | ||
|
||
sol_BLDC01_dense = solve(prob_BLDC01; T=20.0, alg=LGG09(; δ=0.005, vars=(25), n=49)) | ||
|
||
fig = plot(sol_BLDC01_dense; vars=(0, 25), linecolor=:blue, color=:blue, alpha=0.8, lw=1.0, | ||
xlab="t", ylab="x25") | ||
fig = plot(sol_BLDC01_dense; vars=(0, 25), linecolor=:blue, color=:blue, | ||
alpha=0.8, lw=1.0, xlab="t", ylab="x25") | ||
|
||
@assert ρ(x25e, sol_BLDC01_dense) <= 5.1e-3 "the property should be proven" # BLDC01 - BDS01 | ||
@assert !(ρ(x25e, sol_BLDC01_dense) <= 4e-3) "the property should not be proven" # BLDC01 - BDU01 | ||
ρ(x25e, sol_BLDC01_dense) | ||
|
||
ρ(x25e, sol_BLDC01_dense) <= 5.1e-3 # BLDC01 - BDS01 | ||
|
||
ρ(x25e, sol_BLDC01_dense) <= 4e-3 # BLDC01 - BDU01 | ||
|
||
@assert !(ρ(x25e, sol_BLDC01_dense(20.0)) <= -0.78e-3) "the property should not be proven" # BLDC01 - BDU02 | ||
ρ(x25, sol_BLDF01_discrete(20.0)) | ||
|
||
ρ(x25e, sol_BLDC01_dense(20.0)) <= -0.78e-3 # BLDC01 - BDU02 | ||
|
||
sol_BLDC01_discrete = solve(prob_BLDC01; T=20.0, | ||
alg=LGG09(; δ=0.01, vars=(25), n=49, approx_model=NoBloating())) | ||
|
||
fig = plot(sol_BLDC01_discrete; vars=(0, 25), linecolor=:blue, color=:blue, alpha=0.8, lw=1.0, | ||
xlab="t", ylab="x25") | ||
|
||
ρ(x25e, sol_BLDC01_discrete) | ||
|
||
ρ(x25e, sol_BLDC01_discrete) <= 5.1e-3 # BLDC01 - BDS01 | ||
fig = plot(sol_BLDC01_discrete; vars=(0, 25), linecolor=:blue, color=:blue, | ||
alpha=0.8, lw=1.0, xlab="t", ylab="x25") | ||
|
||
@assert ρ(x25e, sol_BLDC01_discrete) <= 5.1e-3 "the property should be proven" # BLDC01 - BDS01 | ||
@assert !(ρ(x25e, sol_BLDC01_discrete) <= 4e-3) "the property should not be proven" # BLDC01 - BDU01 | ||
ρ(x25e, sol_BLDC01_discrete) | ||
|
||
ρ(x25e, sol_BLDC01_discrete) <= 4e-3 # BLDC01 - BDU01 | ||
|
||
@assert !(ρ(x25e, sol_BLDC01_discrete(20.0)) <= -0.78e-3) "the property should not be proven" # BLDC01 - BDU02 | ||
ρ(x25e, sol_BLDC01_discrete(20.0)) | ||
|
||
ρ(x25e, sol_BLDC01_discrete(20.0)) <= -0.78e-3 # BLDC01 - BDU02 |
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
Oops, something went wrong.