|
1 | 1 | import numpy as np |
2 | 2 | from pybdr.geometry import Interval, Zonotope, Geometry |
3 | 3 | from pybdr.geometry.operation import cvt2, partition, boundary |
4 | | -from pybdr.algorithm import ASB2008CDC |
| 4 | +from pybdr.algorithm import ASB2008CDCParallel |
5 | 5 | from pybdr.dynamic_system import NonLinSys |
6 | 6 | from pybdr.model import * |
7 | 7 | from pybdr.util.visualization import plot, plot_cmp |
8 | 8 | from pybdr.util.functional import performance_counter, performance_counter_start |
9 | 9 |
|
10 | 10 | if __name__ == '__main__': |
| 11 | + # tuples_list = [(1, 'a', 'x', 'u'), (2, 'b', 'y', 'v'), (3, 'c', 'z', 'w')] |
| 12 | + # |
| 13 | + # lists_list = [list(t) for t in zip(*tuples_list)] |
| 14 | + # |
| 15 | + # print(lists_list) |
| 16 | + # |
| 17 | + # exit(False) |
11 | 18 | time_start = performance_counter_start() |
12 | 19 | # init dynamic system |
13 | | - system = NonLinSys(Model(lotka_volterra_2d, [2, 1])) |
| 20 | + # system = NonLinSys(Model(lotka_volterra_2d, [2, 1])) |
14 | 21 |
|
15 | 22 | # settings for the computation |
16 | | - options = ASB2008CDC.Options() |
| 23 | + options = ASB2008CDCParallel.Options() |
17 | 24 | options.t_end = 2.2 |
18 | 25 | options.step = 0.005 |
19 | 26 | options.tensor_order = 3 |
|
26 | 33 | Zonotope.REDUCE_METHOD = Zonotope.REDUCE_METHOD.GIRARD |
27 | 34 | Zonotope.ORDER = 50 |
28 | 35 |
|
29 | | - z = Interval.identity(2) * 0.5 + 3 |
| 36 | + init_set = Interval.identity(2) * 0.5 + 3 |
30 | 37 |
|
31 | | - options.r0 = [cvt2(z, Geometry.TYPE.ZONOTOPE)] |
32 | | - _, tp_whole, _, _ = ASB2008CDC.reach(system, options) |
| 38 | + _, tp_whole = ASB2008CDCParallel.reach(lotka_volterra_2d, [2, 1], options, |
| 39 | + cvt2(init_set, Geometry.TYPE.ZONOTOPE)) |
33 | 40 |
|
| 41 | + # NAIVE PARTITION |
34 | 42 | # -------------------------------------------------------- |
35 | 43 | # options.r0 = partition(z, 1, Geometry.TYPE.ZONOTOPE) |
| 44 | + # xs = partition(init_set, 1, Geometry.TYPE.ZONOTOPE) |
36 | 45 | # 4 |
37 | | - # ASB2008CDC cost: 43.344963666000005s |
| 46 | + # ASB2008CDCParallel.reach_parallel cost: 20.126129667s |
38 | 47 | # -------------------------------------------------------- |
39 | | - # options.r0 = partition(z, 0.5, Geometry.TYPE.ZONOTOPE) |
| 48 | + # xs = partition(init_set, 0.5, Geometry.TYPE.ZONOTOPE) |
40 | 49 | # 9 |
41 | | - # ASB2008CDC cost: 3868912500001s |
| 50 | + # ASB2008CDCParallel.reach_parallel cost: 23.938516459000002s |
42 | 51 | # -------------------------------------------------------- |
43 | | - options.r0 = partition(z, 0.2, Geometry.TYPE.ZONOTOPE) |
| 52 | + xs = partition(init_set, 0.2, Geometry.TYPE.ZONOTOPE) |
44 | 53 | # 36 |
45 | | - # ASB2008CDC cost: 317.59988937500003s |
| 54 | + # ASB2008CDCParallel.reach_parallel cost: 65.447113125s |
46 | 55 | # -------------------------------------------------------- |
47 | | - # options.r0 = partition(z, 0.1, Geometry.TYPE.ZONOTOPE) |
48 | 56 |
|
49 | | - print(len(options.r0)) |
| 57 | + # BOUNDAYR ANALYSIS |
| 58 | + # -------------------------------------------------------- |
| 59 | + xs = boundary(init_set, 1, Geometry.TYPE.ZONOTOPE) |
| 60 | + # 8 |
| 61 | + # ASB2008CDCParallel.reach_parallel cost: 22.185758250000003s |
| 62 | + |
| 63 | + print(len(xs)) |
| 64 | + |
| 65 | + _, tp_part_00 = ASB2008CDCParallel.reach_parallel(lotka_volterra_2d, [2, 1], options, xs) |
50 | 66 |
|
51 | | - _, tp_part_00, _, _ = ASB2008CDC.reach(system, options) |
52 | | - performance_counter(time_start, "ASB2008CDC") |
| 67 | + performance_counter(time_start, "ASB2008CDCParallel.reach_parallel") |
53 | 68 |
|
54 | 69 | plot_cmp([tp_whole, tp_part_00], [0, 1], cs=["#FF5722", "#303F9F"]) |
0 commit comments