Skip to content

Commit 0a7a432

Browse files
committed
Add Van der Pol
1 parent 54418e3 commit 0a7a432

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

examples/systems/building_automation_system.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function building_automation_system_decoupled(; state_split=(10, 10, 10, 10, 10,
3434
state_abs = StateUniformGridSplit(X, state_split)
3535

3636
U = Hyperrectangle(; low=[15.0], high=[30.0])
37-
input_abs = Input(U, input_split)
37+
input_abs = InputLinRange(U, input_split)
3838

3939
target_model = DecoupledIMDP()
4040

examples/systems/van_der_pol.jl

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using LinearAlgebra, LazySets
2+
using IntervalMDP, IntervalSySCoRe
3+
4+
5+
function building_automation_system(; sampling_time=0.1)
6+
# TODO: Control?
7+
f(x, u) = [x[1] + x[2] * sampling_time, x[2] + (-x[1] + (1 - x[1])^2 * x[2]) * sampling_time + u[1]]
8+
9+
w_variance = [0.2, 0.2]
10+
w_stddev = sqrt.(w_variance)
11+
12+
dyn = LinearAdditiveNoiseDynamics(f, 2, 0, AdditiveDiagonalGaussianNoise(w_stddev))
13+
14+
initial_region = EmptySet(2)
15+
reach_region = Hyperrectangle(; low=[-1.4, -2.9], high=[-0.7, -2.0])
16+
avoid_region = EmptySet(2)
17+
18+
sys = System(dyn, initial_region, reach_region, avoid_region)
19+
20+
return sys
21+
end
22+
23+
function building_automation_system_decoupled(; state_split=(50, 50), input_split=10)
24+
sys = c()
25+
26+
X = Hyperrectangle(; low=[-3.0, -3.0], high=[3.0, 3.0])
27+
state_abs = StateUniformGridSplit(X, state_split)
28+
29+
U = Hyperrectangle(; low=[-1.0], high=[1.0])
30+
input_abs = InputLinRange(U, input_split)
31+
32+
target_model = DecoupledIMDP()
33+
34+
mdp, reach, avoid = abstraction(sys, state_abs, input_abs, target_model)
35+
36+
return mdp, reach, avoid
37+
end
38+
39+
function main()
40+
mdp, reach, avoid = van_der_pol_decoupled(; state_split=(50, 50), input_split=10)
41+
42+
prop = FiniteTimeReachAvoid(reach, avoid, 6)
43+
spec = Specification(prop, Optimistic, Minimize)
44+
prob = Problem(mdp, spec)
45+
46+
V_unsafety, k, res = value_iteration(prob)
47+
V_safety = 1.0 .- V_unsafety
48+
end

src/dynamics/NonlinearAdditiveNoiseDynamics.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ I.e. `x_{k+1} = A x_k + B u_k + w_k`, where `w_k ~ N(0, diag(w_stddev))`.
1818
1919
# Stochastic Van der Pol Oscillator with additive uniform noise, but no inputs.
2020
τ = 0.1
21-
f(x, u) = [x[1] + x[2] * τ; x[2] + (-x[1] + (1 - x[1])^2 * x[2]) * τ]
21+
f(x, u) = [x[1] + x[2] * τ, x[2] + (-x[1] + (1 - x[1])^2 * x[2]) * τ]
2222
2323
w_stddev = [0.1, 0.1]
2424
w = AdditiveDiagonalUniformNoise(w_stddev)

0 commit comments

Comments
 (0)