def _get_table(self, attribute, domain=None): #get original table table = AbsoluteReport._get_table(self, attribute, domain) #if table is coverage, and in problem resolution, take also initial-h-value and add a column of the ratio if attribute == 'coverage' : h_attr = Attribute('initial_h_value', min_wins=False, absolute=True) h_table = AbsoluteReport._get_table(self, h_attr, domain) hstar_attr = Attribute('cost', min_wins=False, absolute=True) hstar_table = AbsoluteReport._get_table(self, hstar_attr, domain) ratio_attr = Attribute('hstar_to_h', min_wins=False, absolute=True) ratio_table = AbsoluteReport._get_table(self, ratio_attr, domain) ratio_col = {} h_col = {} hstar_col = {} # Filter those rows which have no significant changes for row in table.row_names: hstar = hstar_table.get_row(row) h = h_table.get_row(row) ratio = ratio_table.get(row) print ratio ratio_col[row] = ratio['WORK-lmcut'] h_col[row] = h[0] hstar_col[row] = hstar[0] table.set_column_order(table.col_names + ['h*']) table.add_col('h*/h(s)', ratio_col) table.add_col('h(s)', h_col) table.add_col('h*', hstar_col) table.min_wins = None table.colored = False return table
def _get_statistics_table(self, attribute, domain=None): #get original table table = AbsoluteReport._get_table(self, attribute, domain) #if attribute is statistics, take also initial-h-value and add a column of the ratio if attribute == 'statistics' : h_attr = Attribute('initial_h_value', min_wins=False, absolute=True) h_table = AbsoluteReport._get_table(self, h_attr, domain) hstar_attr = Attribute('cost', min_wins=False, absolute=True) hstar_table = AbsoluteReport._get_table(self, hstar_attr, domain) ratio_attr = Attribute('hstar_to_h', min_wins=False, absolute=True) ratio_table = AbsoluteReport._get_table(self, ratio_attr, domain) ff_h_value_attr = Attribute('initial_ff_h_value', min_wins=False, absolute=True) ff_h_value_table = AbsoluteReport._get_table(self, ff_h_value_attr, domain) ratio_col = {} h_col = {} hstar_col = {} ff_h_value_col = {} h_ff_to_h = [] for row in table.row_names: hstar = hstar_table.get_row(row) h = h_table.get_row(row) ff_h_val = ff_h_value_table.get_row(row) ratio = ratio_table.get(row) ratio_col[row] = ratio[self.nick] h_col[row] = h[0] ff_h_value_col[row] = ff_h_val[0] hstar_col[row] = hstar[0] # build h-ff/h: if(ff_h_val[0] != None and hstar[0] != None): if hstar[0] != 0: h_ff_to_h.append(ff_h_val[0]/hstar[0]) table.set_column_order(table.col_names + ['h*']) table.add_col('h*/h(s)', ratio_col) table.add_col('h(s)', h_col) table.add_col('ff_h(s)', ff_h_value_col) table.add_col('h*', hstar_col) table.min_wins = None table.colored = False # domain_dir = self.outFile + '/' + domain # tools.makedirs(domain_dir) # domain_file = domain_dir + '/' + 'PAC_Statistics.csv' # with open(domain_file, 'w') as csvfile: # writer = csv.writer(csvfile) # [writer.writerow(r) for r in table] self.save_stat_table_to_file(domain,table) self.create_commulative_h_ff_to_h_table(domain, h_ff_to_h) return table
def _get_statistics_table(self, attribute, domain=None): #get original table table = AbsoluteReport._get_table(self, attribute, domain) #if attribute is statistics, take also initial-h-value and add a column of the ratio if attribute == 'statistics': h_attr = Attribute('initial_h_value', min_wins=False, absolute=True) h_table = AbsoluteReport._get_table(self, h_attr, domain) hstar_attr = Attribute('cost', min_wins=False, absolute=True) hstar_table = AbsoluteReport._get_table(self, hstar_attr, domain) ratio_attr = Attribute('hstar_to_h', min_wins=False, absolute=True) ratio_table = AbsoluteReport._get_table(self, ratio_attr, domain) ff_h_value_attr = Attribute('initial_ff_h_value', min_wins=False, absolute=True) ff_h_value_table = AbsoluteReport._get_table( self, ff_h_value_attr, domain) ratio_col = {} h_col = {} hstar_col = {} ff_h_value_col = {} h_ff_to_h = [] for row in table.row_names: hstar = hstar_table.get_row(row) h = h_table.get_row(row) ratio = ratio_table.get(row) ratio_col[row] = ratio[self.nick] h_col[row] = h[0] hstar_col[row] = hstar[0] ff_h_val = ff_h_value_table.get_row(row) ff_h_value_col[row] = ff_h_val[0] # build h-ff/h: if (ff_h_val[0] != None and hstar[0] != None): if hstar[0] != 0: h_ff_to_h.append(hstar[0] / ff_h_val[0]) table.set_column_order(table.col_names + ['h*']) table.add_col('h*/h(s)', ratio_col) table.add_col('h(s)', h_col) table.add_col('h*', hstar_col) table.add_col('ff_h(s)', ff_h_value_col) table.min_wins = None table.colored = False self.save_stat_table_to_file(domain, table) self.create_commulative_h_ff_to_h_table(domain, h_ff_to_h) return table
def get_points(self, domain): """ By default plot the configs on the x-axis and the attribute values on the y-axis. All values are in the same category. """ h_attr = Attribute('initial_h_value', min_wins=False, absolute=True) h_table = AbsoluteReport._get_table(self, h_attr, domain) hstar_attr = Attribute('cost', min_wins=False, absolute=True) hstar_table = AbsoluteReport._get_table(self, hstar_attr, domain) coverage_attr = Attribute('coverage', min_wins=False, absolute=True) coverage_table = AbsoluteReport._get_table(self, coverage_attr, domain) hstar_to_h = {} total_solved = 0 counter = 0 for row in h_table.row_names: hstar = hstar_table.get_row(row) h = h_table.get_row(row) hstar_val = hstar[0] h_val = h[0] coverage = coverage_table.get_row(row) coverage_val = coverage[0] if hstar_val is not None and h_val is not None and h_val > 0: hstar_to_h[counter] = hstar_val / h_val else: hstar_to_h[counter] = 0 counter = counter + 1 if coverage_val > 0: total_solved = total_solved + 1 ratios = { 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.05, 1.1, 1.15, 1.2, 1.25, 1.3, 1.35, 1.4, 1.45, 1.5, 1.55, 1.6, 1.65, 1.7, 1.75, 1.8, 1.85, 1.9, 1.95, 2, 2.05, 2.1, 2.15, 2.2, 2.25, 2.3, 2.35, 2.4, 2.45, 2.5, 2.55, 2.6, 2.65, 2.7, 2.75, 2.8, 2.85, 2.9, 2.95, 3.0, 3.05, 3.1, 3.15, 3.2, 3.25, 3.3, 3.35, 3.4, 3.45, 3.5, 3.55, 3.6, 3.65, 3.7 } percentages = Set() for ratio in ratios: _sum = 0 for key in hstar_to_h: if hstar_to_h[key] <= ratio and hstar_to_h[key] > 0: _sum = _sum + 1 if total_solved == 0: _sum_percent = 0 else: _sum_percent = _sum * 100 / total_solved percentages.add((ratio, _sum_percent)) return list(percentages)
def get_points(self, domain): """ By default plot the configs on the x-axis and the attribute values on the y-axis. All values are in the same category. """ h_attr = Attribute('initial_h_value', min_wins=False, absolute=True) h_table = AbsoluteReport._get_table(self, h_attr, domain) hstar_attr = Attribute('cost', min_wins=False, absolute=True) hstar_table = AbsoluteReport._get_table(self, hstar_attr, domain) coverage_attr = Attribute('coverage', min_wins=False, absolute=True) coverage_table = AbsoluteReport._get_table(self, coverage_attr, domain) hstar_to_h = {} total_solved = 0 counter = 0 for row in h_table.row_names: hstar = hstar_table.get_row(row) h = h_table.get_row(row) hstar_val = hstar[0] h_val = h[0] coverage = coverage_table.get_row(row) coverage_val = coverage[0] if hstar_val is not None and h_val is not None and h_val > 0: hstar_to_h[counter] = hstar_val / h_val else: hstar_to_h[counter] = 0 counter = counter + 1 if coverage_val > 0: total_solved = total_solved + 1 ratios = {0.75,0.8,0.85,0.9,0.95,1,1.05,1.1,1.15,1.2,1.25,1.3,1.35,1.4,1.45,1.5,1.55,1.6,1.65,1.7,1.75,1.8,1.85,1.9,1.95,2,2.05,2.1,2.15,2.2,2.25,2.3,2.35,2.4,2.45,2.5,2.55,2.6,2.65,2.7,2.75,2.8,2.85,2.9,2.95,3.0,3.05,3.1,3.15,3.2,3.25,3.3,3.35,3.4,3.45,3.5,3.55,3.6,3.65,3.7} percentages = Set() for ratio in ratios: _sum = 0 for key in hstar_to_h: if hstar_to_h[key] <= ratio and hstar_to_h[key] > 0: _sum = _sum + 1 if total_solved == 0: _sum_percent = 0 else: _sum_percent = _sum*100 / total_solved percentages.add((ratio,_sum_percent)) return list(percentages)
def _get_table(self, attribute, domain=None): #get original table table = AbsoluteReport._get_table(self, attribute, domain) #if table is coverage, and in problem resolution, take also initial-h-value and add a column of the ratio if attribute == 'coverage': h_attr = Attribute('initial_h_value', min_wins=False, absolute=True) h_table = AbsoluteReport._get_table(self, h_attr, domain) hstar_attr = Attribute('cost', min_wins=False, absolute=True) hstar_table = AbsoluteReport._get_table(self, hstar_attr, domain) ratio_attr = Attribute('hstar_to_h', min_wins=False, absolute=True) ratio_table = AbsoluteReport._get_table(self, ratio_attr, domain) ratio_col = {} h_col = {} hstar_col = {} # Filter those rows which have no significant changes for row in table.row_names: hstar = hstar_table.get_row(row) h = h_table.get_row(row) ratio = ratio_table.get(row) print ratio ratio_col[row] = ratio['WORK-lmcut'] h_col[row] = h[0] hstar_col[row] = hstar[0] table.set_column_order(table.col_names + ['h*']) table.add_col('h*/h(s)', ratio_col) table.add_col('h(s)', h_col) table.add_col('h*', hstar_col) table.min_wins = None table.colored = False return table
def _get_table(self, attribute, domain=None): table = AbsoluteReport._get_table(self, attribute, domain) quotient_col = {} percent_col = {} # Filter those rows which have no significant changes for row in table.row_names: val1, val2 = table.get_row(row) if not val1 and not val2: # Delete row if both values are missing (None) or 0. del table[row] continue elif val1 is None or val2 is None: # Don't add quotient if exactly one value is None. quotient_col[row] = NOT_AVAILABLE continue abs_change = abs(val1 - val2) if val1 == 0 or val2 == 0: # If one value is 0, only add row if the change is big enough. if abs_change >= self.abs_change: quotient_col[row] = NOT_AVAILABLE else: del table[row] continue quotient = val2 / val1 percent_change = abs(quotient - 1.0) if (percent_change >= self.rel_change and abs_change >= self.abs_change): quotient_col[row] = quotient percent_col[row] = percent_change else: del table[row] # Add table also if there were missing cells if len(quotient_col) == 0: return 'No changes.' table.set_column_order(table.col_names + ['Factor']) table.add_col('Factor', quotient_col) table.add_col('%-Change', percent_col) table.min_wins = None table.colored = False return table
def _get_table(self, attribute, domain=None): table = AbsoluteReport._get_table(self, attribute, domain) quotient_col = {} percent_col = {} # Filter those rows which have no significant changes for row in table.row_names: val1, val2 = table.get_row(row) if not val1 and not val2: # Delete row if both values are missing (None) or 0. del table[row] continue elif val1 is None or val2 is None: # Don't add quotient if exactly one value is None. quotient_col[row] = NOT_AVAILABLE continue abs_change = abs(val1 - val2) if val1 == 0 or val2 == 0: # If one value is 0, only add row if the change is big enough. if abs_change >= self.abs_change: quotient_col[row] = NOT_AVAILABLE else: del table[row] continue quotient = val2 / val1 percent_change = abs(quotient - 1.0) if percent_change >= self.rel_change and abs_change >= self.abs_change: quotient_col[row] = quotient percent_col[row] = percent_change else: del table[row] # Add table also if there were missing cells if len(quotient_col) == 0: return "No changes." table.set_column_order(table.col_names + ["Factor"]) table.add_col("Factor", quotient_col) table.add_col("%-Change", percent_col) table.min_wins = None table.colored = False return table
def create_commulative_h_star_table(self, domain): #get relevant value from original table cost_attr = Attribute('cost', min_wins=False, absolute=True) cost_table = AbsoluteReport._get_table(self, cost_attr, domain) #define list of costs: cost_list = [] #calculate number of solved problems total_solved = 0 for row in cost_table.row_names: curr_val = cost_table.get(row) val = curr_val[self.nick] if val > 0: total_solved = total_solved + 1 cost_list.append(val) cost_set = list(set(cost_list)) # remove duplicate element cost_dict = {} for value in sorted(cost_set): smaller_than_value_counter = 0; for compared_value in cost_list: if compared_value <= value: smaller_than_value_counter += 1 cost_dict[value] = smaller_than_value_counter*100 / total_solved #write results into .cvs file: domain_dir = self.outFile + '/' + domain tools.makedirs(domain_dir) domain_file = domain_dir + '/' + 'PAC_Commulative_hstar.csv' file = open(domain_file, "w") sorted_cost_dict_keys = sorted(cost_dict.keys()) for hstar in sorted_cost_dict_keys: toWrite = str(hstar) + ',' + str(cost_dict[hstar]) + '\n' file.write(toWrite) file.close()
def create_commulative_h_star_table(self, domain): #get relevant value from original table cost_attr = Attribute('cost', min_wins=False, absolute=True) cost_table = AbsoluteReport._get_table(self, cost_attr, domain) #define list of costs: cost_list = [] #calculate number of solved problems total_solved = 0 for row in cost_table.row_names: curr_val = cost_table.get(row) val = curr_val[self.nick] if val > 0: total_solved = total_solved + 1 cost_list.append(val) cost_set = list(set(cost_list)) # remove duplicate element cost_dict = {} for value in sorted(cost_set): smaller_than_value_counter = 0 for compared_value in cost_list: if compared_value <= value: smaller_than_value_counter += 1 cost_dict[value] = smaller_than_value_counter * 100 / total_solved #write results into .cvs file: domain_dir = self.outFile + '/' + domain tools.makedirs(domain_dir) domain_file = domain_dir + '/' + 'PAC_Commulative_hstar.csv' file = open(domain_file, "w") sorted_cost_dict_keys = sorted(cost_dict.keys()) for hstar in sorted_cost_dict_keys: toWrite = str(hstar) + ',' + str(cost_dict[hstar]) + '\n' file.write(toWrite) file.close()
def _get_commulative_table(self, domain): #init new table title = 'Commulative' columns = {'Percentage', 'h*/h(s)'} min_wins = False colored = True table = reports.Table(title=title, min_wins=min_wins, colored=colored) table.set_column_order(columns) link = '#%s' % title formatter = reports.CellFormatter(link=link) table.cell_formatters[table.header_row][ table.header_column] = formatter domain_dir = self.outFile + '/' + domain tools.makedirs(domain_dir) domain_file = domain_dir + '/' + 'PAC_Commulative_ratio.csv' file = open(domain_file, "w") #get relevant value from original table ratio_attr = Attribute('hstar_to_h', min_wins=False, absolute=True) ratio_table = AbsoluteReport._get_table(self, ratio_attr, domain) #define arrays to work ratios = [ 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.05, 1.1, 1.15, 1.2, 1.25, 1.3, 1.35, 1.4, 1.45, 1.5, 1.55, 1.6, 1.65, 1.7, 1.75, 1.8, 1.85, 1.9, 1.95, 2, 2.05, 2.1, 2.15, 2.2, 2.25, 2.3, 2.35, 2.4, 2.45, 2.5, 2.55, 2.6, 2.65, 2.7, 2.75, 2.8, 2.85, 2.9, 2.95, 3.0, 3.05, 3.1, 3.15, 3.2, 3.25, 3.3, 3.35, 3.4, 3.45, 3.5, 3.55, 3.6, 3.65, 3.7, 3.75, 3.80, 3.85, 3.9, 3.95, 4.0, 4.05, 4.1, 4.15, 4.2, 2.25, 4.3, 4.35, 4.4, 4.45, 4.5 ] names = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'za', 'zb', 'zc', 'zd', 'ze', 'zf', 'zg', 'zh', 'zi', 'zj', 'zk', 'zl', 'zm', 'zn', 'zo', 'aa', 'ab', 'ac', 'ad', 'ae', 'af', 'ag', 'ah', 'ai', 'aj', 'ak', 'al', 'am', 'an', 'ao', 'ap', 'aq', 'ar', 'as', 'at', 'au', 'av', 'aw', 'ax', 'ay', 'az', 'ba', 'bb', 'bc', 'bd', 'be', 'bf', 'bg', 'bh', 'bi' ] counter = 0 #calculate number of solved problems total_solved = 0 for row in ratio_table.row_names: curr_val = ratio_table.get(row) val = curr_val[self.nick] if val > 0: total_solved = total_solved + 1 #for each ratio (1,1.05...), find the number of problems with this ratio, calc percentage and add row for ratio in ratios: _sum = 0 for row in ratio_table.row_names: curr_val = ratio_table.get(row) val = curr_val[self.nick] if val <= ratio and val > 0: _sum = _sum + 1 if total_solved == 0: _sum_percent = 0 else: _sum_percent = _sum * 100 / total_solved #add new row row_to_add = {} row_to_add['Percentage'] = _sum_percent row_to_add['h*/h(s)'] = ratio table.add_row(names[counter], row_to_add) counter = counter + 1 #TODO - save only one ratio per percentage toWrite = str(ratio) + ',' + str(_sum_percent) + '\n' file.write(toWrite) file.close() self.create_commulative_h_star_table(domain) return table
def _get_commulative_table(self, domain): #init new table title = 'Commulative' columns = {'Percentage','h*/h(s)'} min_wins = False colored = True table = reports.Table(title=title, min_wins=min_wins, colored=colored) table.set_column_order(columns) link = '#%s' % title formatter = reports.CellFormatter(link=link) table.cell_formatters[table.header_row][table.header_column] = formatter domain_dir = self.outFile + '/' + domain tools.makedirs(domain_dir) domain_file = domain_dir + '/' + 'PAC_Commulative_ratio.csv' file = open(domain_file, "w") #get relevant value from original table ratio_attr = Attribute('hstar_to_h', min_wins=False, absolute=True) ratio_table = AbsoluteReport._get_table(self, ratio_attr, domain) #define arrays to work ratios = [0.75,0.8,0.85,0.9,0.95,1,1.05,1.1,1.15,1.2,1.25,1.3,1.35,1.4,1.45,1.5,1.55,1.6,1.65,1.7,1.75,1.8,1.85,1.9,1.95,2,2.05,2.1,2.15,2.2,2.25,2.3,2.35,2.4,2.45,2.5,2.55,2.6,2.65,2.7,2.75,2.8,2.85,2.9,2.95,3.0,3.05,3.1,3.15,3.2,3.25,3.3,3.35,3.4,3.45,3.5,3.55,3.6,3.65,3.7,3.75,3.80,3.85,3.9,3.95,4.0,4.05,4.1,4.15,4.2,2.25,4.3,4.35,4.4,4.45,4.5] names = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','za','zb','zc','zd','ze','zf','zg','zh','zi','zj','zk','zl','zm','zn','zo','aa','ab','ac','ad','ae','af','ag','ah','ai','aj','ak','al','am','an','ao','ap','aq','ar','as','at', 'au','av','aw','ax','ay','az','ba','bb','bc','bd','be','bf','bg','bh','bi'] counter = 0 #calculate number of solved problems total_solved = 0 for row in ratio_table.row_names: curr_val = ratio_table.get(row) val = curr_val[self.nick] if val > 0: total_solved = total_solved + 1 #for each ratio (1,1.05...), find the number of problems with this ratio, calc percentage and add row for ratio in ratios: _sum = 0 for row in ratio_table.row_names: curr_val = ratio_table.get(row) val = curr_val[self.nick] if val <= ratio and val > 0: _sum = _sum + 1 if total_solved == 0: _sum_percent = 0 else: _sum_percent = _sum*100 / total_solved #add new row row_to_add = {} row_to_add['Percentage'] = _sum_percent row_to_add['h*/h(s)'] = ratio table.add_row(names[counter],row_to_add) counter = counter + 1 #TODO - save only one ratio per percentage toWrite = str(ratio)+','+str(_sum_percent)+'\n' file.write(toWrite) file.close() self.create_commulative_h_star_table(domain) return table