Skip to content

Commit 4530db4

Browse files
committed
update doc for better vis
1 parent c25a6af commit 4530db4

File tree

1 file changed

+49
-51
lines changed

1 file changed

+49
-51
lines changed

README.md

Lines changed: 49 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -124,34 +124,33 @@ from pybdr.geometry.operation import boundary, cvt2
124124
from pybdr.model import *
125125
from pybdr.util.visualization import plot
126126

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])
127+
# settings for the computation
128+
options = ASB2008CDC.Options()
129+
options.t_end = 6.74
130+
options.step = 0.005
131+
options.tensor_order = 3
132+
options.taylor_terms = 4
133+
options.u = Zonotope.zero(1, 1)
134+
options.u_trans = np.zeros(1)
135+
136+
# settings for the using geometry
137+
Zonotope.REDUCE_METHOD = Zonotope.REDUCE_METHOD.GIRARD
138+
Zonotope.ORDER = 50
139+
140+
z = Interval([1.23, 2.34], [1.57, 2.46])
141+
x0 = cvt2(z, Geometry.TYPE.ZONOTOPE)
142+
xs = boundary(z, 1, Geometry.TYPE.ZONOTOPE)
143+
144+
this_time = performance_counter_start()
145+
ri_without_bound, rp_without_bound = ASB2008CDC.reach(vanderpol, [2, 1], options, x0)
146+
this_time = performance_counter(this_time, 'reach_without_bound')
147+
148+
ri_with_bound, rp_with_bound = ASB2008CDC.reach_parallel(vanderpol, [2, 1], options, xs)
149+
this_time = performance_counter(this_time, 'reach_with_bound')
150+
151+
# visualize the results
152+
plot(ri_without_bound, [0, 1])
153+
plot(ri_with_bound, [0, 1])
155154
```
156155

157156
| With Boundary Analysis (BA) | No Boundary Analysis (NBA) |
@@ -241,36 +240,35 @@ from pybdr.util.visualization import plot, plot_cmp
241240
from pybdr.geometry.operation import boundary, cvt2
242241
from pybdr.util.functional import performance_counter_start, performance_counter
243242

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
243+
# settings for the computation
244+
options = ASB2008CDC.Options()
245+
options.t_end = 1
246+
options.step = 0.01
247+
options.tensor_order = 2
248+
options.taylor_terms = 2
251249

252-
options.u = Zonotope([0], np.diag([0]))
253-
options.u_trans = options.u.c
250+
options.u = Zonotope([0], np.diag([0]))
251+
options.u_trans = options.u.c
254252

255-
# settings for the using geometry
256-
Zonotope.REDUCE_METHOD = Zonotope.REDUCE_METHOD.GIRARD
257-
Zonotope.ORDER = 50
253+
# settings for the using geometry
254+
Zonotope.REDUCE_METHOD = Zonotope.REDUCE_METHOD.GIRARD
255+
Zonotope.ORDER = 50
258256

259-
z = Interval([0, -0.5], [1, 0.5])
260-
x0 = cvt2(z, Geometry.TYPE.ZONOTOPE)
261-
xs = boundary(z, 2, Geometry.TYPE.ZONOTOPE)
257+
z = Interval([0, -0.5], [1, 0.5])
258+
x0 = cvt2(z, Geometry.TYPE.ZONOTOPE)
259+
xs = boundary(z, 2, Geometry.TYPE.ZONOTOPE)
262260

263-
print(len(xs))
261+
print(len(xs))
264262

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")
263+
this_time = performance_counter_start()
264+
ri_without_bound, rp_without_bound = ASB2008CDC.reach(neural_ode_spiral1, [2, 1], options, x0)
265+
this_time = performance_counter(this_time, "reach_without_bound")
268266

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")
267+
ri_with_bound, rp_with_bound = ASB2008CDC.reach_parallel(neural_ode_spiral1, [2, 1], options, xs)
268+
this_time = performance_counter(this_time, "reach_with_bound")
271269

272-
# visualize the results
273-
plot_cmp([ri_without_bound, ri_with_bound], [0, 1], cs=["#FF5722", "#303F9F"])
270+
# visualize the results
271+
plot_cmp([ri_without_bound, ri_with_bound], [0, 1], cs=["#FF5722", "#303F9F"])
274272
```
275273

276274
In the following table, we show the reachable computed with boundary analysis and without boundary analysis on different

0 commit comments

Comments
 (0)