Skip to content

Commit c1eb838

Browse files
committed
update examples
1 parent d6635f8 commit c1eb838

3 files changed

Lines changed: 74 additions & 2 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import numpy as np
2+
from pybdr.geometry import Interval, Zonotope, Geometry
3+
from pybdr.geometry.operation import cvt2, partition, boundary
4+
from pybdr.algorithm import ASB2008CDC
5+
from pybdr.dynamic_system import NonLinSys
6+
from pybdr.model import *
7+
from pybdr.util.visualization import plot, plot_cmp
8+
from pybdr.util.functional import performance_counter, performance_counter_start
9+
10+
if __name__ == '__main__':
11+
time_start = performance_counter_start()
12+
# init dynamic system
13+
system = NonLinSys(Model(lotka_volterra_2d, [2, 1]))
14+
15+
# settings for the computation
16+
options = ASB2008CDC.Options()
17+
options.t_end = 2.2
18+
options.step = 0.005
19+
options.tensor_order = 3
20+
options.taylor_terms = 4
21+
22+
options.u = Zonotope([0], np.diag([0]))
23+
options.u_trans = options.u.c
24+
25+
# settings for the using geometry
26+
Zonotope.REDUCE_METHOD = Zonotope.REDUCE_METHOD.GIRARD
27+
Zonotope.ORDER = 50
28+
29+
z = Interval.identity(2) * 0.5 + 3
30+
31+
options.r0 = [cvt2(z, Geometry.TYPE.ZONOTOPE)]
32+
_, tp_whole, _, _ = ASB2008CDC.reach(system, options)
33+
34+
# --------------------------------------------------------
35+
# options.r0 = partition(z, 1, Geometry.TYPE.ZONOTOPE)
36+
# 4
37+
# ASB2008CDC cost: 43.344963666000005s
38+
# --------------------------------------------------------
39+
# options.r0 = partition(z, 0.5, Geometry.TYPE.ZONOTOPE)
40+
# 9
41+
# ASB2008CDC cost: 3868912500001s
42+
# --------------------------------------------------------
43+
options.r0 = partition(z, 0.2, Geometry.TYPE.ZONOTOPE)
44+
# 36
45+
# ASB2008CDC cost: 317.59988937500003s
46+
# --------------------------------------------------------
47+
# options.r0 = partition(z, 0.1, Geometry.TYPE.ZONOTOPE)
48+
49+
print(len(options.r0))
50+
51+
_, tp_part_00, _, _ = ASB2008CDC.reach(system, options)
52+
performance_counter(time_start, "ASB2008CDC")
53+
54+
plot_cmp([tp_whole, tp_part_00], [0, 1], cs=["#FF5722", "#303F9F"])

example/benchmark_brusselator_cmp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
Zonotope.REDUCE_METHOD = Zonotope.REDUCE_METHOD.GIRARD
2929
Zonotope.ORDER = 50
3030

31-
z = Interval.identity(2) * 0.1 + 0.2;
31+
z = Interval.identity(2) * 0.1 + 0.2
3232

3333
no_boundary_analysis = False
3434

example/benchmark_lotka_volterra_2d_cmp.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
from pybdr.geometry.operation import boundary, cvt2
99
from pybdr.model import *
1010
from pybdr.util.visualization import plot, plot_cmp
11+
from pybdr.util.functional import performance_counter_start, performance_counter
1112

1213
if __name__ == '__main__':
14+
time_start = performance_counter_start()
1315
# init dynamic system
1416
system = NonLinSys(Model(lotka_volterra_2d, [2, 1]))
1517

@@ -34,8 +36,24 @@
3436
ti_whole, tp_whole, _, _ = ASB2008CDC.reach(system, options)
3537

3638
# reachable sets computation with boundary analysis
39+
# --------------------------------------------------------
40+
# options.r0 = boundary(z, 2, Geometry.TYPE.ZONOTOPE)
41+
# 4
42+
# ASB2008CDC cost: 43.888805708s
43+
# --------------------------------------------------------
3744
options.r0 = boundary(z, 1, Geometry.TYPE.ZONOTOPE)
45+
# 8
46+
# ASB2008CDC cost: 77.14907875s
47+
# --------------------------------------------------------
3848
ti_bound, tp_bound, _, _ = ASB2008CDC.reach(system, options)
49+
performance_counter(time_start, 'ASB2008CDC')
3950

4051
# visualize the results
41-
plot_cmp([tp_whole, tp_bound], [0, 1], cs=["#FF5722", "#303F9F"])
52+
# plot_cmp([tp_whole, tp_bound], [0, 1], cs=["#FF5722", "#303F9F"])
53+
# plot_cmp([tp_whole, tp_bound], [0, 1], cs=["#FF5722", "#D6D6D6"])
54+
# plot_cmp([tp_whole, tp_bound], [0, 1], cs=["#FF5722", "#808000"])
55+
plot_cmp([tp_whole, tp_bound], [0, 1], cs=["#FF5722", "#228B22"])
56+
# plot_cmp([tp_whole, tp_bound], [0, 1], cs=["#FF5722", "#663399"])
57+
# plot_cmp([tp_whole, tp_bound], [0, 1], cs=["#FF5722", "#008080"])
58+
# plot_cmp([tp_whole, tp_bound], [0, 1], cs=["#FF5722", "#FFD700"])
59+
# plot_cmp([tp_whole, tp_bound], [0, 1], cs=["#FF5722", "#2E8B57"])

0 commit comments

Comments
 (0)