def _plot_comm(self, data, parallel_key, figure, color='teal', offset=0.0, label='', marker='o'): if parallel_key not in data: return xs, ys, lowers, uppers = [], [], [], [] for cores, v_ in data[parallel_key].items(): xs.append(int(cores) + offset) sums = list(map(lambda wt: np.sum(np.array(wt[1:])), v_['comm'])) mean = np.mean(sums) ys.append(mean) lower, upper = conf_95_mean(sums) lowers.append(mean - lower) uppers.append(upper - mean) ys = [y for _, y in sorted(zip(xs, ys))] lowers = [l for _, l in sorted(zip(xs, lowers))] uppers = [u for _, u in sorted(zip(xs, uppers))] xs = sorted(xs) figure.errorbar(xs, ys, yerr=[lowers, uppers], fmt=marker, markerfacecolor='none', color=color, label=label, mew=MEW, ms=MS) figure.plot(xs, ys, '-', alpha=0.5, linewidth=0.5, color=color)
def _plot_speedup(self, data, parallel_key, figure, color='teal', marker='o', offset=0.0, plotline=True, legend=''): if parallel_key not in data: return xs, ys, lowers, uppers = [], [], [], [] if 'seq' in data: sequential = np.array(data['seq']['time']).flatten() for cores, v_ in data[parallel_key].items(): xs.append(int(cores)) parallel = [] for times in v_['time']: parallel.append(np.mean(times)) speedup = sequential / parallel mean_speedup = np.mean(speedup) ys.append(mean_speedup) lower, upper = conf_95_mean(speedup) lowers.append(mean_speedup - lower) uppers.append(upper - mean_speedup) ys = [y for _, y in sorted(zip(xs, ys))] xs = sorted(xs) xs = list(map(lambda x: float(x) + offset, xs)) if legend == '': figure.errorbar(xs, ys, yerr=[lowers, uppers], fmt=marker, markerfacecolor='none', color=color, mew=MEW, ms=MS) else: figure.errorbar(xs, ys, yerr=[lowers, uppers], fmt=marker, markerfacecolor='none', color=color, label=legend, mew=MEW, ms=MS) plt.plot(xs, ys, '-', alpha=0.5, linewidth=0.5, color=color) if plotline: plt.plot([0, max(xs)], [0, max(xs)], '-', color='black', label='Linear Speedup') else: print('could not solve {} sequentially within ' 'timeout...'.format(legend))
def _plot_runtime(self, data, parallel_key, figure, color='teal', offset=0.0, marker='o', legend=''): if parallel_key not in data: return xs, ys, lowers, uppers = [], [], [], [] if 'seq' in data: xs.append(1 + offset) mean = np.mean(np.array(data['seq']['time']).flatten()) ys.append(mean) lower, upper = conf_95_mean( np.array(data['seq']['time']).flatten()) lowers.append(mean - lower) uppers.append(upper - mean) print('{} sequential runtime: {} +{} -{}'.format( legend, mean, upper - mean, mean - lower)) for cores, v_ in data[parallel_key].items(): xs.append(int(cores)) mean = np.mean(np.array(v_['time']).flatten()) ys.append(mean) lower, upper = conf_95_mean(np.array(v_['time']).flatten()) lowers.append(mean - lower) uppers.append(upper - mean) ys = [y for _, y in sorted(zip(xs, ys))] xs = sorted(xs) figure.errorbar(xs, ys, yerr=[lowers, uppers], fmt=marker, markerfacecolor='none', color=color, label=legend, mew=MEW, ms=MS) plt.plot(xs, ys, '-', alpha=0.5, linewidth=0.5, color=color)
def _plot_scatter(self): markers ={'DPLL': 'o', 'CDCL': 'D'} color = {'DPLL': 'firebrick', 'CDCL': 'teal'} offsets = {'DPLL': 0.1, 'CDCL': -0.1} x_ticks = [] plt.figure(figsize=(6, 3.4)) xs = [] for s in ['DPLL', 'CDCL']: xs = [] ys = [] lower_error = [] upper_error = [] i = 0 for k, v in self.data[s].iteritems(): if 'ais8.cnf' in k: continue data = [] for t in v['time']: data.append(np.array(t)/1000) xs.append(i + offsets[s]) mean = np.mean(data) ys.append(mean) lower, upper = conf_95_mean(data) lower = mean - lower upper = upper - mean if s == 'CDCL': print('formula {} CDCL time: {} - {} + {}'.format(k, mean, lower, upper)) lower_error.append(lower) upper_error.append(upper) if s == 'DPLL': x_ticks.append(k.split('/')[-1].replace('.cnf', '')) i = i+1 plt.errorbar(xs, ys, yerr=[lower_error, upper_error], label=s, fmt=markers[s], color=color[s], markerfacecolor='none', mew=MEW, ms=MS) plt.xticks(xs, x_ticks, rotation=45, ha='right') plt.title('DPLL vs CDCL') plt.ylabel('Avg. runtime [s]\nwith 95% conf. intervals') plt.legend(loc=2) self._default_plt_postprocessing() f = '../../report/figures/dpll_vs_cdcl.pdf' plt.savefig(f, format='pdf') f = '../../report/figures/dpll_vs_cdcl.png' plt.savefig(f, format='png') plt.show()
def plot(self): markers = ['o', 'D'] color = ['firebrick', 'teal'] i = 0 x_offsets = {} for s in EXECUTABLES: x_offsets = {} xs = [] ys = [] lower_error = [] upper_error = [] for k, v in self.data[s].iteritems(): info = Info(**v['info']) data = [] for t in v['time']: data.append(t) if info.variables not in x_offsets: x_offsets[info.variables] = -2.5 x_offsets[info.variables] = x_offsets[info.variables] + 0.5 xs.append(info.variables + x_offsets[info.variables]) data1 = [] for d in data: data1.append(np.mean(d)) mean = np.mean(data1) ys.append(mean) lower, upper = conf_95_mean(data1) lower_error.append(mean - lower) upper_error.append(upper - mean) plt.errorbar(xs, ys, yerr=[lower_error, upper_error], label=s, fmt=markers[i], color=color[i], markerfacecolor='none') i = i + 1 plt.xticks(x_offsets.keys(), x_offsets.keys()) plt.title( 'Stealing vs Master-Worker, mean runtime with 95% confidence interval' ) plt.xlabel( 'Approximate formula difficulty [formula size: number of variables]' ) plt.ylabel('Runtime [ms]') plt.legend(loc=2) plt.show()
def find_best_runtime(self, files): for f in range(len(files)): data = self.data[files[f]] best_config = 'none' m = 1000000000 for p in ['parallel', 'stealing']: if p in data: for n, d in data[p].items(): times = d['time'] means = list(map(lambda t: np.mean(t), times)) mean = np.mean(means) lower, upper = conf_95_mean(means) lower = mean - lower upper = upper - mean if mean < m: m = mean best_config = '{} on {} nodes, time: {} -{} +{}'.format( p, n, mean, lower, upper) print('formula {} best: {}'.format(files[f], best_config))
colors['parallel'] = ['teal', 'teal'] offset = {} offset['parallel'] = -0.6 offset['stealing'] = 0 for type in ['parallel', 'stealing']: lower_error = [] upper_error = [] ys = [] xs = [] for data in case[type]['x']: xs.append(data + offset[type]) for data in case[type]['y']: mean = np.mean(data) ys.append(mean) lower, upper = conf_95_mean(data) lower_error.append(mean-lower) upper_error.append(upper-mean) plt.errorbar(xs, ys, yerr=[lower_error, upper_error], #label='{} version'.format(type), fmt='D', color=colors[type][1], linewidth=1, markerfacecolor='none') plt.plot(xs, ys, '--', color=colors[type][1], label='{} version'.format(type), linewidth=1) plt.title(title) plt.xlabel('# cores') plt.ylabel(ylabel);