def run(self, init_state_list): ''' Run the computation (main entry point) init_star is the initial state fixed_dim_list, if used, is a list of dimensions with fixed initial values ''' Timers.reset() Timers.tic("total") self.setup(init_state_list) if self.settings.plot.plot_mode == PlotSettings.PLOT_INTERACTIVE: # make sure to store plot result for on_click listener to report on self.print_verbose( f"Setting store_plot_result to true since PLOT_INTERACTIVE has click listener" ) self.settings.plot.store_plot_result = True if self.settings.plot.store_plot_result: self.result.plot_data = PlotData(self.plotman.num_subplots) if self.settings.plot.plot_mode == PlotSettings.PLOT_NONE: self.run_to_completion() else: self.plotman.compute_and_animate() Timers.toc("total") if self.settings.stdout >= HylaaSettings.STDOUT_VERBOSE: Timers.print_stats() if self.result.has_concrete_error: self.print_normal( "Result: Error modes are reachable (found counter-example).\n") elif self.result.has_aggregated_error: self.print_normal("Result: System is safe, although error modes were reachable when aggregation " + \ "(overapproximation) was used.\n") else: self.print_normal( "Result: System is safe. Error modes are NOT reachable.\n") self.print_normal("Total Runtime: {:.2f} sec".format( Timers.top_level_timer.total_secs)) # assign results self.result.top_level_timer = Timers.top_level_timer Timers.reset() return self.result
def run_to_completion(self): 'run the computation until it finishes (without plotting)' Timers.tic("total") while not self.is_finished(): self.do_step() Timers.toc("total") if self.settings.print_output: LpInstance.print_stats() Timers.print_stats() self.result.time = Timers.timers["total"].total_secs
def anim_iterator(): 'generator for the computation iterator' Timers.tic("total") # do the computation until its done while not is_finished_func(): yield False # redraw one more (will clear cur_state) # yield False Timers.toc("total") LpInstance.print_stats() Timers.print_stats()
pv_object = run_hylaa(settings, init_r, usafe_r) # pv_object.compute_longest_ce() # depth_direction = np.identity(len(init_r.dims)) # pv_object.compute_deepest_ce(depth_direction[1]) robust_pt = pv_object.compute_robust_ce() # pv_object.compute_counter_examples_using_z3(4) # pv_object.compute_z3_counterexample() ce_smt_object = CeSmt(pv_object) ce_smt_object.compute_ce_wo_regex() # ce_smt_object.compute_z3_ces_for_regex() # pv_object.compute_milp_counterexample_py('Oscillator', "11111001111111111111111110") ce_mip_object = CeMilp(pv_object) ce_mip_object.compute_counterexample('Oscillator') # z3_ce = np.array([-5.1324054061, 0.8009245168]) # milp_ce = np.array([-5.28179, 0.76464]) # compute_simulation_mt(milp_ce, z3_ce) # simulations = [] # for ce in z3_counter_examples: # simulation = compute_simulation(z3_counter_example, a_matrix, c_vector, 0.2, 20/0.2) # x, y = np.array(simulation).T # plt.plot(x, y, 'r*') # verts = usafe_star.verts() # print(verts) # x, y = np.array(verts).T # plt.plot(x, y, 'r-', robust_pt[0], robust_pt[1], 'r.') # plt.show() Timers.print_stats()