def analyze_results(self, i_iteration, data_fn=None, config_fn=None, kde_fn=None, analysis_fn=None): """ analyze the results of the simulation this method analyzes the results of the simulation, and does post simulation tasks, such as filtering by qoi performance, pareto optimization, etc. Args: data_fn(str): the path of the data file. By default this is set to none where the the file will be determine by i_iteration and internal attributes config_fn(str): the path of the data file. By default this is set to none where the the file will be determine by i_iteration and internal attributes kde_fn(str): the path of the data file. By default this is set to none where the the file will be determine by i_iteration and internal attributes """ if data_fn is None: data_fn = os.path.join(\ self.root_directory, self.data_directory, 'pyposmat.results.{}.out'.format(i_iteration)) if config_fn is None: config_fn = os.path.join(\ self.root_directory, self.configuration_filename) if kde_fn is None: kde_fn = os.path.join(\ self.root_directory, self.data_directory, 'pyposmat.kde.{}.out'.format(i_iteration+1)) if analysis_fn is None: analysis_fn = os.path.join(self.root_directory, self.data_directory, 'pyposmat.analysis.out') data_analyzer = PyposmatDataAnalyzer() data_analyzer.initialize_configuration(config_fn=config_fn) data_analyzer.analyze_results_data(i_iteration, filename=data_fn) assert isinstance(data_analyzer.results_statistics, OrderedDict) if os.path.isfile(analysis_fn): data_analyzer.read_analysis_file(filename=analysis_fn) self.log( data_analyzer.str__results_descriptive_statistics( statistics=data_analyzer.results_statistics)) self.log(data_analyzer.str__qoi_filtering_summary()) data_analyzer.write_kde_file(filename=kde_fn) data_analyzer.analyze_kde_data(i_iteration, filename=kde_fn) assert isinstance(data_analyzer.kde_statistics, OrderedDict) self.log( data_analyzer.str__kde_descriptive_statistics( statistics=data_analyzer.kde_statistics)) data_analyzer.update_analysis(i_iteration) data_analyzer.write_analysis_file(filename=analysis_fn)
analysis_results = OrderedDict() for i in range(n_iterations): if i not in analysis_results: print('i_iteration:{}'.format(i)) analysis_results[i] = OrderedDict() analysis_results[i]['results_statistics'] = None analysis_results[i]['kde_statistics'] = None analysis_results[i]['filter_info'] = None filter_info = o.analyze_results_data( i_iteration=i, filename=os.path.join(data_directory, 'pyposmat.results.{}.out'.format(i))) o.analyze_kde_data(i_iteration=i, filename=os.path.join( data_directory, 'pyposmat.kde.{}.out'.format(i + 1))) analysis_results[i]['results_statistics'] = o.results_statistics analysis_results[i]['kde_statistics'] = o.kde_statistics analysis_results[i]['filter_info'] = filter_info print(analysis_results[i]['results_statistics']) print(analysis_results[i]['filter_info']) print(analysis_results[i]['kde_statistics']) else: pass # write analysis results to filesystem with open(analysis_fn, 'w') as f: yaml.dump(analysis_results, f, default_flow_style=False)