def run(self): """Executes mc failure probability analysis.""" # read in file and parameters damage = self.get_input_dataset("damage").get_csv_reader() damage_result = AnalysisUtil.get_csv_table_rows(damage, ignore_first_row=False) # setting number of cpus to use user_defined_cpu = 1 if not self.get_parameter("num_cpu") is None and self.get_parameter( "num_cpu") > 0: user_defined_cpu = self.get_parameter("num_cpu") num_workers = AnalysisUtil.determine_parallelism_locally( self, len(damage_result), user_defined_cpu) avg_bulk_input_size = int(len(damage_result) / num_workers) inventory_args = [] count = 0 inventory_list = damage_result seed = self.get_parameter("seed") seed_list = [] if seed is not None: while count < len(inventory_list): inventory_args.append(inventory_list[count:count + avg_bulk_input_size]) seed_list.append([ seed + i for i in range(count - 1, count + avg_bulk_input_size - 1) ]) count += avg_bulk_input_size else: while count < len(inventory_list): inventory_args.append(inventory_list[count:count + avg_bulk_input_size]) seed_list.append([ None for i in range(count - 1, count + avg_bulk_input_size - 1) ]) count += avg_bulk_input_size fs_results, fp_results, samples_results = self.monte_carlo_failure_probability_concurrent_future( self.monte_carlo_failure_probability_bulk_input, num_workers, inventory_args, seed_list) self.set_result_csv_data("sample_failure_state", fs_results, name=self.get_parameter("result_name") + "_failure_state") self.set_result_csv_data("failure_probability", fp_results, name=self.get_parameter("result_name") + "_failure_probability") self.set_result_csv_data("sample_damage_states", samples_results, name=self.get_parameter("result_name") + "_sample_damage_states") return True
def run(self): """Executes mean damage calculation.""" # read in file and parameters damage = self.get_input_dataset("damage").get_csv_reader() damage_result = AnalysisUtil.get_csv_table_rows(damage, ignore_first_row=False) dmg_ratio_csv = self.get_input_dataset("dmg_ratios").get_csv_reader() dmg_ratio_tbl = AnalysisUtil.get_csv_table_rows(dmg_ratio_csv) # setting number of cpus to use user_defined_cpu = 1 if not self.get_parameter("num_cpu") is None and self.get_parameter( "num_cpu") > 0: user_defined_cpu = self.get_parameter("num_cpu") num_workers = AnalysisUtil.determine_parallelism_locally( self, len(damage_result), user_defined_cpu) avg_bulk_input_size = int(len(damage_result) / num_workers) inventory_args = [] count = 0 inventory_list = damage_result while count < len(inventory_list): inventory_args.append(inventory_list[count:count + avg_bulk_input_size]) count += avg_bulk_input_size results = self.mean_damage_concurrent_future( self.mean_damage_bulk_input, num_workers, inventory_args, repeat(dmg_ratio_tbl)) self.set_result_csv_data("result", results, name=self.get_parameter("result_name")) return True