|
5 | 5 | from pybdr.algorithm import ASB2008CDC |
6 | 6 | from pybdr.dynamic_system import NonLinSys |
7 | 7 | from pybdr.geometry import Zonotope, Interval, Geometry |
8 | | -from pybdr.geometry.operation import boundary |
| 8 | +from pybdr.geometry.operation import boundary, cvt2 |
9 | 9 | from pybdr.model import * |
10 | 10 | from pybdr.util.visualization import plot, plot_cmp |
11 | 11 |
|
12 | | -# init dynamic system |
13 | | -system = NonLinSys(Model(brusselator, [2, 1])) |
| 12 | +if __name__ == '__main__': |
14 | 13 |
|
15 | | -# settings for the computation |
16 | | -options = ASB2008CDC.Options() |
17 | | -options.t_end = 6.0 |
18 | | -options.step = 0.02 |
19 | | -options.tensor_order = 2 |
20 | | -options.taylor_terms = 4 |
| 14 | + # init dynamic system |
| 15 | + system = NonLinSys(Model(brusselator, [2, 1])) |
21 | 16 |
|
22 | | -options.u = Zonotope([0], np.diag([0])) |
23 | | -options.u_trans = options.u.c |
| 17 | + # settings for the computation |
| 18 | + options = ASB2008CDC.Options() |
| 19 | + options.t_end = 6.0 |
| 20 | + options.step = 0.02 |
| 21 | + options.tensor_order = 2 |
| 22 | + options.taylor_terms = 4 |
24 | 23 |
|
25 | | -# settings for the using geometry |
26 | | -Zonotope.REDUCE_METHOD = Zonotope.REDUCE_METHOD.GIRARD |
27 | | -Zonotope.ORDER = 50 |
| 24 | + options.u = Zonotope([0], np.diag([0])) |
| 25 | + options.u_trans = options.u.c |
28 | 26 |
|
29 | | -z = Zonotope([0.2, 0.2], np.diag([0.1, 0.1])) |
| 27 | + # settings for the using geometry |
| 28 | + Zonotope.REDUCE_METHOD = Zonotope.REDUCE_METHOD.GIRARD |
| 29 | + Zonotope.ORDER = 50 |
30 | 30 |
|
31 | | -no_boundary_analysis = True |
| 31 | + z = Interval.identity(2) * 0.1 + 0.2; |
32 | 32 |
|
33 | | -tp_whole, tp_bound = None, None |
34 | | -xlim, ylim = [0, 2], [0, 2.4] |
| 33 | + no_boundary_analysis = False |
35 | 34 |
|
36 | | -if no_boundary_analysis: |
37 | | - # reachable sets computation without boundary analysis |
38 | | - options.r0 = [z] |
39 | | - ti_whole, tp_whole, _, _ = ASB2008CDC.reach(system, options) |
40 | | -else: |
41 | | - # reachable sets computation with boundary analysis |
42 | | - options.r0 = boundary(z, 1, Geometry.TYPE.ZONOTOPE) |
43 | | - ti_bound, tp_bound, _, _ = ASB2008CDC.reach(system, options) |
| 35 | + tp_whole, tp_bound = None, None |
| 36 | + xlim, ylim = [0, 2], [0, 2.4] |
44 | 37 |
|
45 | | -# visualize the results |
46 | | -if no_boundary_analysis: |
47 | | - plot(tp_whole, [0, 1], xlim=xlim, ylim=ylim) |
48 | | -else: |
49 | | - plot(tp_bound, [0, 1], xlim=xlim, ylim=ylim) |
| 38 | + if no_boundary_analysis: |
| 39 | + # reachable sets computation without boundary analysis |
| 40 | + options.r0 = [cvt2(z, Geometry.TYPE.ZONOTOPE)] |
| 41 | + ti_whole, tp_whole, _, _ = ASB2008CDC.reach(system, options) |
| 42 | + else: |
| 43 | + # reachable sets computation with boundary analysis |
| 44 | + options.r0 = boundary(z, 0.3, Geometry.TYPE.ZONOTOPE) |
| 45 | + ti_bound, tp_bound, _, _ = ASB2008CDC.reach(system, options) |
| 46 | + |
| 47 | + # visualize the results |
| 48 | + if no_boundary_analysis: |
| 49 | + plot(tp_whole, [0, 1], xlim=xlim, ylim=ylim) |
| 50 | + else: |
| 51 | + plot(tp_bound, [0, 1], xlim=xlim, ylim=ylim) |
0 commit comments