def test_unaggregation(): 'test an unaggregated discrete transition' ha = HybridAutomaton() # mode one: x' = 1, t' = 1, a' = 0 m1 = ha.new_mode('m1') m1.set_dynamics([[0, 0, 1], [0, 0, 1], [0, 0, 0]]) # mode two: x' = -1, t' = 1, a' = 0 m2 = ha.new_mode('m2') m2.set_dynamics([[0, 0, -1], [0, 0, 1], [0, 0, 0]]) # invariant: t <= 2.5 m1.set_invariant([[0, 1, 0]], [2.5]) # guard: t >= 0.5 trans1 = ha.new_transition(m1, m2, 'trans1') trans1.set_guard([[0, -1, 0]], [-0.5]) # error x >= 4.5 error = ha.new_mode('error') trans2 = ha.new_transition(m2, error, "to_error") trans2.set_guard([[-1, 0, 0]], [-4.5]) # initial set has x0 = [0, 0.2], t = [0, 0.2], a = 1 init_lpi = lputil.from_box([(0, 0.2), (0, 0.2), (1, 1)], m1) init_list = [StateSet(init_lpi, m1)] # settings, step size = 1.0 settings = HylaaSettings(1.0, 10.0) settings.stdout = HylaaSettings.STDOUT_DEBUG settings.plot.store_plot_result = True settings.plot.plot_mode = PlotSettings.PLOT_NONE settings.aggstrat = aggstrat.Unaggregated() result = Core(ha, settings).run(init_list) # expected no exception # m2 should be reachable polys = [obj[0] for obj in result.plot_data.mode_to_obj_list[0]['m2']] assert len(polys) > 15
def make_settings(stepsize, aggregation, axis_limits, filename): 'make the reachability settings object' # see hylaa.settings for a list of reachability settings settings = HylaaSettings(stepsize, 250.0) # step: 0.1, bound: 200.0 settings.plot.filename = filename #settings.approx_model = HylaaSettings.APPROX_LGG if aggregation == 'deagg': settings.stop_on_aggregated_error = False #settings.process_urgent_guards = True settings.aggstrat.deaggregate = True # use deaggregation settings.aggstrat.deagg_preference = Aggregated.DEAGG_LEAVES_FIRST elif aggregation == 'unagg': # dont use aggregation settings.aggstrat = aggstrat.Unaggregated() else: assert aggregation == 'agg', f"unknown aggregation value {aggregation}" settings.stdout = HylaaSettings.STDOUT_NONE #settings.plot.plot_mode = PlotSettings.PLOT_IMAGE #settings.plot.filename = "rendezvous_full_passivity.png" settings.plot.plot_size = (8, 4) settings.plot.video_pause_frames = 2 settings.plot.plot_mode = PlotSettings.PLOT_IMAGE #settings.plot.filename = "rendezvous_full_passivity.mp4" # single plot settings.plot.xdim_dir = [0] * 1 settings.plot.ydim_dir = [1] * 1 settings.plot.grid = False settings.plot.label = [] settings.plot.extra_collections = [] ls = LabelSettings() settings.plot.label.append(ls) ls.big(size=24) ls.title = '' ls.x_label = '$x$' ls.y_label = '$y$' y = 57.735 line = [(-100, y), (-100, -y), (0, 0), (-100, y)] c1 = collections.LineCollection([line], animated=True, colors=('gray'), linewidths=(1), linestyle='dashed') rad = 5.0 line = [(-rad, -rad), (-rad, rad), (rad, rad), (rad, -rad), (-rad, -rad)] c2 = collections.LineCollection([line], animated=True, colors=('red'), linewidths=(2)) settings.plot.extra_collections.append([c1, c2]) settings.plot.label[0].axes_limits = axis_limits return settings
def make_settings(stepsize, aggregation): 'make the reachability settings object' # see hylaa.settings for a list of reachability settings settings = HylaaSettings(stepsize, 250.0) # step: 0.1, bound: 200.0 #settings.approx_model = HylaaSettings.APPROX_LGG if aggregation == 'deagg': settings.stop_on_aggregated_error = False #settings.process_urgent_guards = True settings.aggstrat.deaggregate = True # use deaggregation settings.aggstrat.deagg_preference = Aggregated.DEAGG_LEAVES_FIRST elif aggregation == 'unagg': # dont use aggregation settings.aggstrat = aggstrat.Unaggregated() else: assert aggregation == 'agg', f"unknown aggregation value {aggregation}" settings.stdout = HylaaSettings.STDOUT_VERBOSE #settings.plot.plot_mode = PlotSettings.PLOT_IMAGE settings.plot.plot_size = (8, 9) settings.plot.video_pause_frames = 15 settings.plot.video_fps = 25 video = True if video: settings.plot.plot_mode = PlotSettings.PLOT_VIDEO settings.plot.filename = "rendezvous_full_passivity.mp4" else: settings.plot.plot_mode = PlotSettings.PLOT_IMAGE settings.plot.filename = "rendezvous_full_passivity.png" # multiplot settings.plot.xdim_dir = [0] * 3 settings.plot.ydim_dir = [1] * 3 settings.plot.grid = False settings.plot.label = [] settings.plot.extra_collections = [] for _ in range(3): ls = LabelSettings() settings.plot.label.append(ls) ls.big(size=24) ls.x_label = '$x$' ls.y_label = '$y$' y = 57.735 line = [(-100, y), (-100, -y), (0, 0), (-100, y)] c1 = collections.LineCollection([line], animated=True, colors=('gray'), linewidths=(1), linestyle='dashed') rad = 5 line = [(-rad, -rad), (-rad, rad), (rad, rad), (rad, -rad), (-rad, -rad)] c2 = collections.LineCollection([line], animated=True, colors=('red'), linewidths=(2)) settings.plot.extra_collections.append([c1, c2]) settings.plot.label[0].axes_limits = [-950, 200, -450, 70] #settings.plot.label[1].axes_limits = [-150, 50, -70, 70] settings.plot.label[1].axes_limits = [-150, 100, -80, 80] settings.plot.label[2].axes_limits = [-40, 40, -30, 30] return settings