|
| 1 | +import numpy as np |
| 2 | +from pybdr.algorithm import ASB2008CDC,ASB2008CDCParallel |
| 3 | +from pybdr.util.functional import performance_counter, performance_counter_start |
| 4 | +from pybdr.dynamic_system import NonLinSys |
| 5 | +from pybdr.geometry import Zonotope, Interval, Geometry |
| 6 | +from pybdr.geometry.operation import boundary |
| 7 | +from pybdr.model import * |
| 8 | +from pybdr.util.visualization import plot |
| 9 | +from save_results import save_result |
| 10 | +from pybdr.geometry.operation.convert import cvt2 |
| 11 | + |
| 12 | +if __name__ == '__main__': |
| 13 | + # settings for the computation |
| 14 | + options = ASB2008CDCParallel.Options() |
| 15 | + options.step = 0.01 |
| 16 | + options.tensor_order = 3 |
| 17 | + options.taylor_terms = 4 |
| 18 | + options.u = Zonotope.zero(1, 1) |
| 19 | + options.u_trans = np.zeros(1) |
| 20 | + Zonotope.REDUCE_METHOD = Zonotope.REDUCE_METHOD.GIRARD |
| 21 | + Zonotope.ORDER = 50 |
| 22 | + |
| 23 | + options.t_end = 5.0 |
| 24 | + # options.t_end = 7.0 |
| 25 | + # options.t_end = 9.0 |
| 26 | + # Z = Interval([1.0, 2.0], [1.8, 2.8]) |
| 27 | + # Z = Interval([0.9, 1.9], [1.9, 2.9]) |
| 28 | + Z = Interval([0.8, 1.8], [2.0, 3.0]) |
| 29 | + |
| 30 | + cell_nums_s = {12: 0.3, 16: 0.25, 20: 0.18} |
| 31 | + cell_nums_m = {8: 0.6, 12: 0.4, 16: 0.3, 20: 0.22, 24: 0.18, 28: 0.16, 32: 0.14, 36: 0.12} |
| 32 | + cell_nums_l = {20: 0.3, 24: 0.2, 28: 0.18, 32: 0.16, 36: 0.15} |
| 33 | + # Reachable sets computed with boundary analysis |
| 34 | + options.r0 = boundary(Z, cell_nums_l[36], Geometry.TYPE.ZONOTOPE) |
| 35 | + # Reachable sets computed without boundary analysis |
| 36 | + # options.r0 = [cvt2(Z, Geometry.TYPE.ZONOTOPE)] |
| 37 | + print("The number of divided sets: ", len(options.r0)) |
| 38 | + |
| 39 | + time_tag = performance_counter_start() |
| 40 | + ri, rp = ASB2008CDCParallel.reach_parallel(vanderpol, [2, 1], options, options.r0) |
| 41 | + performance_counter(time_tag, "ASB2008CDCParallel") |
| 42 | + |
| 43 | + # save the results |
| 44 | + save_result(ri, "vanderpol_" + str(len(options.r0))) |
| 45 | + |
| 46 | + # visualize the results |
| 47 | + plot(ri, [0, 1]) |
0 commit comments