117117
118118``` python
119119import numpy as np
120-
121- from pybdr.algorithm import ASB2008CDC
122- from pybdr.dynamic_system import NonLinSys
120+ from pybdr.algorithm import ASB2008CDC , ASB2008CDC
121+ from pybdr.util.functional import performance_counter, performance_counter_start
123122from pybdr.geometry import Zonotope, Interval, Geometry
124- from pybdr.geometry.operation import boundary
123+ from pybdr.geometry.operation import boundary, cvt2
125124from pybdr.model import *
126125from pybdr.util.visualization import plot
127126
128- # init dynamic system
129- system = NonLinSys(Model(vanderpol, [2 , 1 ]))
130-
131- # settings for the computation
132- options = ASB2008CDC .Options()
133- options.t_end = 6.74
134- options.step = 0.005
135- options.tensor_order = 3
136- options.taylor_terms = 4
137- options.u = Zonotope.zero(1 , 1 )
138- options.u_trans = np.zeros(1 )
139-
140- z = Zonotope([1.4 , 2.4 ], np.diag([0.17 , 0.06 ]))
141-
142- # -----------------------------------------------------
143- # computing reachable sets with boundary analysis
144- options.r0 = boundary(z, 1 , Geometry.TYPE .ZONOTOPE )
145- # -----------------------------------------------------
146- # computing reachable sets without boundary analysis
147- # options.r0 = [z]
148- # -----------------------------------------------------
149-
150- # settings for the using geometry
151- Zonotope.REDUCE_METHOD = Zonotope.REDUCE_METHOD .GIRARD
152- Zonotope.ORDER = 50
153-
154- # reachable sets computation
155- ti, tp, _, _ = ASB2008CDC .reach(system, options)
156-
157- # visualize the results
158- plot(tp, [0 , 1 ])
127+ if __name__ == ' __main__' :
128+ # settings for the computation
129+ options = ASB2008CDC .Options()
130+ options.t_end = 6.74
131+ options.step = 0.005
132+ options.tensor_order = 3
133+ options.taylor_terms = 4
134+ options.u = Zonotope.zero(1 , 1 )
135+ options.u_trans = np.zeros(1 )
136+
137+ # settings for the using geometry
138+ Zonotope.REDUCE_METHOD = Zonotope.REDUCE_METHOD .GIRARD
139+ Zonotope.ORDER = 50
140+
141+ z = Interval([1.23 , 2.34 ], [1.57 , 2.46 ])
142+ x0 = cvt2(z, Geometry.TYPE .ZONOTOPE )
143+ xs = boundary(z, 1 , Geometry.TYPE .ZONOTOPE )
144+
145+ this_time = performance_counter_start()
146+ ri_without_bound, rp_without_bound = ASB2008CDC .reach(vanderpol, [2 , 1 ], options, x0)
147+ this_time = performance_counter(this_time, ' reach_without_bound' )
148+
149+ ri_with_bound, rp_with_bound = ASB2008CDC .reach_parallel(vanderpol, [2 , 1 ], options, xs)
150+ this_time = performance_counter(this_time, ' reach_with_bound' )
151+
152+ # visualize the results
153+ plot(ri_without_bound, [0 , 1 ])
154+ plot(ri_with_bound, [0 , 1 ])
159155```
160156
161157| With Boundary Analysis (BA) | No Boundary Analysis (NBA) |
@@ -164,16 +160,16 @@ plot(tp, [0, 1])
164160
165161For large initial sets,
166162
167- | System | Code | Reachable Sets (Orange-NBA,Blue-BA) |
168- | :-----------------------------------------------------------------------------------------------------------------------:| :------------------------------------------------------------------------------------------------------------------------------------:| :---------------------------------------:|
169- | [ synchronous machine] ( https://github.com/ASAG-ISCAS/PyBDR/blob/master/pyrat/model/synchronous_machine.py ) | [ benchmark_synchronous_machine_cmp.py] ( https://github.com/ASAG-ISCAS/PyBDR/blob/master/example /benchmark_synchronous_machine_cmp.py ) | ![ ] ( doc/imgs/sync_machine_cmp.png ) |
170- | [ Lotka Volterra model of 2 variables] ( https://github.com/ASAG-ISCAS/PyBDR/blob/master/pyrat/model/lotka_volterra_2d.py ) | [ benchmark_lotka_volterra_2d_cmp.py] ( https://github.com/ASAG-ISCAS/PyBDR/blob/master/example /benchmark_lotka_volterra_2d_cmp.py ) | ![ ] ( doc/imgs/lotka_volterra_2d_cmp.png ) |
171- | [ Jet engine] ( https://github.com/ASAG-ISCAS/PyBDR/blob/master/pyrat/model/jet_engine.py ) | [ benchmark_jet_engine_cmp.py] ( https://github.com/ASAG-ISCAS/PyBDR/blob/master/example /benchmark_jet_engine_cmp.py ) | ![ ] ( doc/imgs/jet_engine_cmp.png ) |
163+ | System | Code | Reachable Sets (Orange-NBA,Blue-BA) |
164+ | :-----------------------------------------------------------------------------------------------------------------------:| :--------------------------------------------------------------------------------------------------------------------------------------- :| :---------------------------------------:|
165+ | [ synchronous machine] ( https://github.com/ASAG-ISCAS/PyBDR/blob/master/pyrat/model/synchronous_machine.py ) | [ benchmark_synchronous_machine_cmp.py] ( https://github.com/ASAG-ISCAS/PyBDR/blob/master/benchmarks /benchmark_synchronous_machine_cmp.py ) | ![ ] ( doc/imgs/sync_machine_cmp.png ) |
166+ | [ Lotka Volterra model of 2 variables] ( https://github.com/ASAG-ISCAS/PyBDR/blob/master/pyrat/model/lotka_volterra_2d.py ) | [ benchmark_lotka_volterra_2d_cmp.py] ( https://github.com/ASAG-ISCAS/PyBDR/blob/master/benchmarks /benchmark_lotka_volterra_2d_cmp.py ) | ![ ] ( doc/imgs/lotka_volterra_2d_cmp.png ) |
167+ | [ Jet engine] ( https://github.com/ASAG-ISCAS/PyBDR/blob/master/pyrat/model/jet_engine.py ) | [ benchmark_jet_engine_cmp.py] ( https://github.com/ASAG-ISCAS/PyBDR/blob/master/benchmarks /benchmark_jet_engine_cmp.py ) | ![ ] ( doc/imgs/jet_engine_cmp.png ) |
172168
173169For large time horizons, i.e. consider
174170the system [ Brusselator] ( https://github.com/ASAG-ISCAS/PyBDR/blob/master/pyrat/model/brusselator.py )
175171> For more details about the following example, please refer to
176- > our [ code] ( https://github.com/ASAG-ISCAS/PyBDR/blob/master/example /benchmark_brusselator_cmp.py ) .
172+ > our [ code] ( https://github.com/ASAG-ISCAS/PyBDR/blob/master/benchmarks /benchmark_brusselator_cmp.py ) .
177173
178174| Time instance | With Boundary Analysis | Without Boundary Analysi |
179175| :-------------:| ---------------------------------------| :--------------------------------------:|
238234``` python
239235import numpy as np
240236
241- np.seterr(divide = ' ignore' , invalid = ' ignore' )
242- import sys
243-
244- # sys.path.append("./../../") uncomment this line if you need to add path manually
245237from pybdr.algorithm import ASB2008CDC
246- from pybdr.dynamic_system import NonLinSys
247238from pybdr.geometry import Zonotope, Interval, Geometry
248239from pybdr.model import *
249- from pybdr.util.visualization import plot
250- from pybdr.util.functional.neural_ode_generate import neuralODE
251- from pybdr.geometry.operation import boundary
240+ from pybdr.util.visualization import plot, plot_cmp
241+ from pybdr.geometry.operation import boundary, cvt2
242+ from pybdr.util.functional import performance_counter_start, performance_counter
252243
253- # init neural ODE
254- system = NonLinSys(Model(neuralODE, [2 , 1 ]))
244+ if __name__ == ' __main__' :
245+ # settings for the computation
246+ options = ASB2008CDC .Options()
247+ options.t_end = 1
248+ options.step = 0.01
249+ options.tensor_order = 2
250+ options.taylor_terms = 2
255251
256- # settings for the computation
257- options = ASB2008CDC .Options()
258- options.t_end = 1.5
259- options.step = 0.01
260- options.tensor_order = 2
261- options.taylor_terms = 2
262- Z = Zonotope([0.5 , 0 ], np.diag([1 , 0.5 ]))
252+ options.u = Zonotope([0 ], np.diag([0 ]))
253+ options.u_trans = options.u.c
263254
264- # Reachable sets computed with boundary analysis
265- # options.r0 = boundary(Z,1,Geometry.TYPE.ZONOTOPE)
255+ # settings for the using geometry
256+ Zonotope.REDUCE_METHOD = Zonotope.REDUCE_METHOD .GIRARD
257+ Zonotope.ORDER = 50
266258
267- # Reachable sets computed without boundary analysis
268- options.r0 = [Z]
259+ z = Interval([0 , - 0.5 ], [1 , 0.5 ])
260+ x0 = cvt2(z, Geometry.TYPE .ZONOTOPE )
261+ xs = boundary(z, 2 , Geometry.TYPE .ZONOTOPE )
269262
270- options.u = Zonotope.zero(1 , 1 )
271- options.u_trans = np.zeros(1 )
263+ print (len (xs))
272264
273- # settings for the using geometry
274- Zonotope. REDUCE_METHOD = Zonotope. REDUCE_METHOD . GIRARD
275- Zonotope. ORDER = 50
265+ this_time = performance_counter_start()
266+ ri_without_bound, rp_without_bound = ASB2008CDC .reach(neural_ode_spiral1, [ 2 , 1 ], options, x0)
267+ this_time = performance_counter(this_time, " reach_without_bound " )
276268
277- # reachable sets computation
278- ti, tp, _, _ = ASB2008CDC .reach(system, options )
269+ ri_with_bound, rp_with_bound = ASB2008CDC .reach_parallel(neural_ode_spiral1, [ 2 , 1 ], options, xs)
270+ this_time = performance_counter(this_time, " reach_with_bound " )
279271
280- # visualize the results
281- plot(tp, [0 , 1 ])
272+ # visualize the results
273+ plot_cmp([ri_without_bound, ri_with_bound], [0 , 1 ], cs = [ " #FF5722 " , " #303F9F " ])
282274```
283275
284276In the following table, we show the reachable computed with boundary analysis and without boundary analysis on different
0 commit comments