def test_store_kpis(self): self.assertIn('recording.bag', os.listdir(ROOT_PATH),'recording.bag cannot be found') sim_eval = Evaluation(ROSBAG, RESULTS_DIR) sim_eval.compute_kpis() sim_eval.save_kpis() self.assertIn('computed_kpis.yaml', os.listdir(RESULTS_DIR), 'KPIs were not stored in file computed_kpis.yaml') self.assertIn('kpi_labels.yaml', os.listdir(RESULTS_DIR), 'KPIs labels were not stored in file kpis_labels.yaml')
def test_store_kpis(self): runner = SimulationRunner(PARAMS, TASK, RESULTS_DIR, True) runner.run(PARAMS) self.assertIn('recording.bag', os.listdir(runner.current_sim_results_dir),'recording.bag cannot be found') sim_eval = Evaluation(runner.recording_filename, runner.current_sim_results_dir) sim_eval.compute_kpis() sim_eval.save_kpis() self.assertIn('computed_kpis.yaml', os.listdir(runner.current_sim_results_dir), 'KPIs were not stored in file computed_kpis.yaml') self.assertIn('kpi_labels.yaml', os.listdir(runner.current_sim_results_dir), 'KPIs labels were not stored in file kpis_labels.yaml')
if 'store_all_results' in opt_config: record_all = opt_config['store_all_results'] try: runner = SimulationRunner(params, task, results_dir, record_all) runner.run(params) sim_eval = Evaluation(runner.recording_filename, runner.current_sim_results_dir) output_path = deepcopy(runner.current_sim_results_dir) sim_eval.compute_kpis() if 'store_kpis_only' in opt_config: if opt_config['store_kpis_only']: sim_eval.save_kpis() else: sim_eval.save_evaluation() else: sim_eval.save_kpis() cost = 0.0 for tag in opt_config['cost_fcn']: cost += sim_eval.get_kpi(tag) * opt_config['cost_fcn'][tag] status = 'SUCCESS' output = dict(status=status, cost=float(cost)) with open( os.path.join(runner.current_sim_results_dir, 'smac_result.yaml'), 'w') as smac_file: