def main(dirn, fname): 
  (xs, ysPerSolver, ydevsPerSolver) = CommonViz.parseData(dirn, fname)
     
  CommonConf.setupMPPDefaults()
  fmts = CommonConf.getLineFormats()
  mrkrs = CommonConf.getLineMarkers()
  fig = pp.figure()
  ax = fig.add_subplot(111)
  # ax.set_xscale("log", basex=2)

  index = 0
  for (solver, ys), (solver, ydevs) in zip(ysPerSolver.iteritems(),ydevsPerSolver.iteritems()) : 
    ax.errorbar(xs, ys, yerr=ydevs, label=solver, marker=mrkrs[index], linestyle=fmts[index])
    index = index + 1

  ax.set_xlabel(X_LABEL);
  ax.set_ylabel(Y_LABEL);
  ax.legend(loc='best', fancybox=True)

  ax.get_yaxis().set_major_formatter(
    matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x/1000000), ',')))

  ax.get_xaxis().set_major_formatter(
    matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x * 100), ',')))
  
  pp.savefig(dirn+"/"+fname+".pdf")
  pp.show()
def main(dirn, fname):
    (xs, ysPerSolver, ydevsPerSolver) = CommonViz.parseData(dirn, fname)

    CommonConf.setupMPPDefaults()
    fmts = CommonConf.getLineFormats()
    mrkrs = CommonConf.getLineMarkers()
    fig = pp.figure()
    ax = fig.add_subplot(111)
    ax.set_xscale("log", basex=2)
    #ax.set_yscale("symlog" )

    index = 0
    for (solver, ys), (solver, ydevs) in zip(ysPerSolver.iteritems(),
                                             ydevsPerSolver.iteritems()):
        ax.errorbar(xs,
                    ys,
                    yerr=ydevs,
                    label=solver,
                    marker=mrkrs[index],
                    linestyle=fmts[index])
        index = index + 1

    ax.set_xlabel(X_LABEL)
    ax.set_ylabel(Y_LABEL)
    ax.legend(loc='best', fancybox=True)

    pp.savefig(dirn + "/" + fname + ".pdf")
    pp.show()
Beispiel #3
0
def main(dirn, fname):
    (xs, ysPerSolver, ydevsPerSolver) = CommonViz.parseData(dirn, fname)

    CommonConf.setupMPPDefaults()
    fmts = CommonConf.getLineFormats()
    mrkrs = CommonConf.getLineMarkers()
    fig = pp.figure()
    ax = fig.add_subplot(111)
    # ax.set_xscale("log", basex=2)

    index = 0
    for (solver, ys), (solver, ydevs) in zip(ysPerSolver.iteritems(),
                                             ydevsPerSolver.iteritems()):
        ax.errorbar(xs,
                    ys,
                    yerr=ydevs,
                    label=solver,
                    marker=mrkrs[index],
                    linestyle=fmts[index])
        index = index + 1

    ax.set_xlabel(X_LABEL)
    ax.set_ylabel(Y_LABEL)
    ax.legend(loc='best', fancybox=True)

    # ax.get_yaxis().set_major_formatter(
    #   matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x/1000000), ',')))

    ax.get_xaxis().set_major_formatter(
        matplotlib.ticker.FuncFormatter(
            lambda x, p: format(int(x * 100), ',')))

    pp.savefig(dirn + "/" + fname + ".pdf")
    pp.show()
Beispiel #4
0
def plot_resilience(paths_dir, out_file):
    fig = pp.figure(figsize=(12,8))
    ax = fig.add_subplot(111)
    paths_file = dict()
    resilience = dict()
    rects = dict()
    width = 0.9/len(algs)
    CommonConf.setupMPPDefaults()
    colors = CommonConf.getLineColorsDict()
    bar_width = 0.7
    for alg in algs:
        paths_file[alg] = paths_dir + '/' + alg + '_0'
    for alg in algs:
        mhs_vals = []
        paths = parse_path_file(paths_file[alg])
        for sd,sdpaths in paths.iteritems():
            mhs = find_min_hitting_set([set(p) for p in sdpaths.keys()])
            #print len(sdpaths), len(mhs)
            mhs_vals.append(len(mhs)-1)
        resilience[alg] = freq(mhs_vals)

    t = [max(resilience[alg].keys()) for alg in algs]
    xs = np.arange(max(t)+1)
    i = 0
    for alg in algs:
        ys = []
        for x in xs:
            ys.append(np.sum([resilience[alg].get(X,0) for X in xs if X >= x]))
        print alg, ys
        rects[alg] = ax.bar(xs-0.5+i*width, ys, width, color=colors[alg],
                            edgecolor=None, alpha=0.8, zorder=1/np.mean(ys))
        i = i+1

    ax.spines['top'].set_visible(False)
    ax.spines['right'].set_visible(False)
    ax.xaxis.set_ticks_position('bottom')
    ax.yaxis.set_ticks_position('left')
    pp.xticks(range(len(algs)), [' ' for x in algs])
    ax.locator_params(axis='y', nbins=6)
    ax.set_ylabel('Number of f-resilient node pairs')
    ax.set_xticklabels(xs)
    ax.legend([rects[x] for x  in algs],
              [CommonConf.gen_label(x) for x in algs],
              loc='best', borderaxespad=1., fancybox=True)
    pp.xlim(0.5,2.5)
    pp.tight_layout()
    pp.savefig("resilience.pdf")
def main(dirn, fname):
    blockSizes = []
    localitiesPerApproach = OrderedDict()

    with open(dirn + "/" + fname + ".dat") as fin:
        lines = fin.readlines()

        for line in lines:
            if line.startswith("#"):
                continue
            (blockSize, approach, locality, nline) = re.split("[\t]", line)
            blockSize = float(blockSize)
            locality = float(locality)
            if approach in localitiesPerApproach:
                localitiesPerApproach[approach].append(locality)
            else:
                localitiesPerApproach[approach] = [locality]
            if len(blockSizes) == 0 or blockSize > blockSizes[-1]:
                blockSizes.append(blockSize)

    CommonConf.setupMPPDefaults()
    fmts = CommonConf.getLineFormats()
    mrkrs = CommonConf.getLineMarkers()
    fig = pp.figure()
    ax = fig.add_subplot(111)
    #ax.set_xscale("log", basex=2)

    index = 0
    for approach, localities in localitiesPerApproach.iteritems():
        ax.plot(blockSizes,
                localities,
                label=approach,
                marker=mrkrs[index],
                linestyle=fmts[index])
        index = index + 1

    ax.set_xlabel('block size (bytes)')
    ax.set_ylabel('locality')
    # ax.set_xlim(0, 2100)
    ax.legend(loc='best', fancybox=True)

    pp.savefig(dirn + "/" + fname + ".pdf")
    pp.show()
Beispiel #6
0
def plot_pdf(pdfs, budget, out_file):
    CommonConf.setupMPPDefaults()
    fig, axes = pp.subplots(2, len(solvers)/2, sharex=True, sharey=True,
                          figsize=(12,6))
    colors=CommonConf.getLineColorsDict()
    fmts = CommonConf.getLineFormatsDict()
    linewidth = CommonConf.getLineMarkersLWDict()
    mrkrs = CommonConf.getLineMarkersDict()
    mrkrsize = CommonConf.getLineMarkersSizeDict()

    xs = np.asarray([float(i+1)/budget for i in range(budget)])
    width = 1.
    print xs
    axeslist = []
    print axes
    for ax in axes:
        print ax
        axeslist = axeslist + list(ax)
    for ax,solver in zip(axeslist, sorted(solvers)):
        zorder = 1
        pdf = pdfs[solver]
        print solver, pdf
        ys = []
        for x in xs:
            y = sum([pdf[k] for k in pdf.keys() if k <= (x+0.001) and k >=
                     (x-0.24)]) #(k > (x-min_x)
            ys.append(y)
        print sum(ys)
        print ys
        ax.bar(np.arange(len(xs))-0.5, ys, width,
               alpha=1.0,
               color=[colors[solver]]*len(xs),
               edgecolor='white',#[colors[solver]]*len(xs),
               label=CommonConf.gen_label(solver),
               linewidth=0,#linewidth[solver],
               linestyle='solid',
               #marker=mrkrs[solver],
               #markersize=mrkrsize[solver],
               zorder=1/np.mean(ys))
        ax.spines['right'].set_visible(False)
        ax.spines['top'].set_visible(False)
        ax.yaxis.set_ticks_position('left')
        ax.xaxis.set_ticks_position('bottom')
        ax.locator_params(axis='x', nbins=4)
        ax.locator_params(axis='y', nbins=4)
        ax.set_xlabel("Risk");
        ax.set_ylabel("Probability");
        ax.legend(loc='best', borderaxespad=0., fancybox=True, ncol=3)
    pp.locator_params(axis='x', nbins=6)
    pp.xticks(np.arange(len(xs)), xs)
    pp.xlim(-0.5,3.5)
    pp.tight_layout(pad=0)
    pp.savefig("tmp.pdf")
def main(dirn, fname, solvers):
  (xs, ysPerSolver, ydevsPerSolver) = CommonViz.parseData(dirn, fname, solvers)

  CommonConf.setupMPPDefaults()
  fmts = CommonConf.getLineFormats()
  mrkrs = CommonConf.getLineMarkers()
  fig = pp.figure()
  ax = fig.add_subplot(111)
  # ax.set_xscale("log", basex=2)

  index = 0
  for (solver, ys), (solver, ydevs) in zip(ysPerSolver.iteritems(),ydevsPerSolver.iteritems()) :
    ax.errorbar(xs, ys, yerr=ydevs, label=solver, marker=mrkrs[index], linestyle=fmts[index])
    index = index + 1

  ax.set_xlabel(X_LABEL);
  ax.set_ylabel(Y_LABEL);
  ax.legend(loc='best', fancybox=True)

  pp.savefig(dirn+"/"+fname+"-".join(solvers)+".svg")
def main(dirn, fname):
  blockSizes = []
  localitiesPerApproach = OrderedDict()

  with open(dirn+"/"+fname+".dat") as fin:
    lines = fin.readlines()

    for line in lines:
      if line.startswith("#"):
        continue
      (blockSize, approach, locality, nline) = re.split("[\t]", line)
      blockSize = float(blockSize)
      locality = float(locality)
      if approach in localitiesPerApproach:
        localitiesPerApproach[approach].append(locality)
      else:
        localitiesPerApproach[approach] = [locality]
      if len(blockSizes) == 0 or blockSize > blockSizes[-1]:
        blockSizes.append(blockSize)

  CommonConf.setupMPPDefaults()
  fmts = CommonConf.getLineFormats()
  mrkrs = CommonConf.getLineMarkers()
  fig = pp.figure()
  ax = fig.add_subplot(111)
  #ax.set_xscale("log", basex=2)
    
  index = 0
  for approach, localities in localitiesPerApproach.iteritems():
    ax.plot(blockSizes, localities, label=approach, 
            marker=mrkrs[index], linestyle=fmts[index])
    index = index + 1

  ax.set_xlabel('block size (bytes)');
  ax.set_ylabel('locality');
  # ax.set_xlim(0, 2100)
  ax.legend(loc='best', fancybox=True)

  pp.savefig(dirn+"/"+fname+".pdf")
  pp.show()
Beispiel #9
0
def main(dirn, fname, solvers):
    (xs, ysPerSolver,
     ydevsPerSolver) = CommonViz.parseData(dirn, fname, solvers)

    CommonConf.setupMPPDefaults()
    colors = CommonConf.getLineColorsDict()
    fmts = CommonConf.getLineFormatsDict()
    linewidth = CommonConf.getLineMarkersLWDict()
    mrkrs = CommonConf.getLineMarkersDict()
    mrkrsize = CommonConf.getLineMarkersSizeDict()

    fig = pp.figure(figsize=(8, 6))
    ax = fig.add_subplot(111)
    # ax.set_xscale("log", basex=2)

    #xs.append(max(xs)+2)
    for (solver, ys), (solver, ydevs) in zip(ysPerSolver.iteritems(),
                                             ydevsPerSolver.iteritems()):
        if solver not in CommonConf.solver_list:
            continue
        xs_arr = np.asarray(xs)
        xs_arr = xs_arr + random.random() / 2
        xs_arr[-1] += random.random() * 2
        avg_y, std_y = np.mean(np.asarray(ys)), np.std(np.asarray(ys))
        #ys.append(avg_y)
        #ydevs.append(std_y)

        ax.errorbar(xs_arr[1:NUMTM],
                    ys[1:NUMTM],
                    yerr=ydevs[1:NUMTM],
                    alpha=0.8,
                    color=colors[solver],
                    label=CommonConf.gen_label(solver),
                    linewidth=linewidth[solver],
                    linestyle=fmts[solver],
                    marker=mrkrs[solver],
                    markersize=mrkrsize[solver])

    ax.spines['top'].set_visible(False)
    ax.spines['right'].set_visible(False)
    ax.xaxis.set_ticks_position('none')
    ax.yaxis.set_ticks_position('none')
    ax.set_xlabel(X_LABEL)
    ax.set_ylabel(Y_LABEL)
    #ax.set_yscale("log", nonposy='clip')
    ax.legend(loc='best', borderaxespad=0., fancybox=True, ncol=3)
    pp.subplots_adjust(left=0.12, right=0.95, top=0.9, bottom=0.12)
    pp.xlim(0, NUMTM)
    pp.savefig(dirn + "/" + fname + "-".join(solvers) + ".pdf")
def main(dirn, fname, solvers):
    (xs, ysPerSolver,
     ydevsPerSolver) = CommonViz.parseData(dirn, fname, solvers)

    CommonConf.setupMPPDefaults()
    colors = CommonConf.getLineColorsDict()
    fmts = CommonConf.getLineFormatsDict()
    linewidth = CommonConf.getLineMarkersLWDict()
    mrkrs = CommonConf.getLineMarkersDict()
    mrkrsize = CommonConf.getLineMarkersSizeDict()

    fig = pp.figure(figsize=(12, 6))
    ax = fig.add_subplot(111)
    # ax.set_xscale("log", basex=2)

    index = 0
    #xs.append(max(xs)+2)
    for (solver, ys), (solver, ydevs) in zip(ysPerSolver.iteritems(),
                                             ydevsPerSolver.iteritems()):
        xs_arr = np.asarray(xs)
        xs_arr = xs_arr + random.random() / 10
        ax.errorbar(xs_arr,
                    ys,
                    yerr=ydevs,
                    alpha=0.8,
                    color=colors[solver],
                    label=CommonConf.gen_label(solver),
                    linewidth=linewidth[solver],
                    linestyle=fmts[solver],
                    marker=mrkrs[solver],
                    markersize=mrkrsize[solver])

    ax.set_xlabel(X_LABEL)
    ax.set_ylabel(Y_LABEL)
    ax.legend(loc=0, borderaxespad=1., fancybox=True)
    ymin, ymax = pp.ylim()
    pp.ylim(0.5, 1.05)

    xa = ax.get_xaxis()
    xa.set_major_locator(pylab.MaxNLocator(integer=True))
    #ax.annotate('link (s2-s12) fails', xy=(1.8, 0.54), xytext=(0.95, 0.6),
    #          arrowprops=dict(facecolor='black', shrink=0.05), fontsize=14
    #          )
    #pp.axvline(1.8, linestyle='dashed' )
    pp.subplots_adjust(left=0.1, right=0.8, top=0.9, bottom=0.1)

    #pp.savefig(dirn+"/"+fname+"-".join(solvers)+".pdf")
    pp.savefig(dirn + "/" + fname + "-".join(solvers) + ".svg")
Beispiel #11
0
def display(all_congestions, directory):
    sort_cong = OrderedDict()
    for scheme in sorted(all_congestions.keys()):
        sort_cong[scheme] = get_scheme_congestions(all_congestions, scheme)

    CommonConf.setupMPPDefaults()
    colors = CommonConf.getLineColorsDict()
    fmts = CommonConf.getLineFormatsDict()
    linewidth = CommonConf.getLineMarkersLWDict()
    mrkrs = CommonConf.getLineMarkersDict()
    mrkrsize = CommonConf.getLineMarkersSizeDict()

    fig = pp.figure(figsize=(12, 6))
    ax = fig.add_subplot(111)
    mxl = 0
    num_sample = 20
    for solver, cong_dist in sort_cong.iteritems():
        ys = [x / len(cong_dist) for x in range(0, len(cong_dist))]
        gap = int(len(ys) / num_sample) + 1
        xx = []
        yy = []
        for i in range(0, len(ys)):
            if (i % gap == 0):
                xx.append(cong_dist[i])
                yy.append(ys[i])
        if (len(ys) - 1) % gap != 0:
            xx.append(cong_dist[-1])
            yy.append(ys[-1])

        ydevs = [0] * len(yy)
        ax.errorbar(xx,
                    yy,
                    yerr=ydevs,
                    alpha=0.8,
                    color=colors[solver],
                    label=CommonConf.gen_label(solver),
                    linewidth=linewidth[solver],
                    linestyle=fmts[solver],
                    marker=mrkrs[solver],
                    markersize=mrkrsize[solver])

    ax.set_xlabel(X_LABEL)
    ax.set_ylabel(Y_LABEL)
    ax.legend(bbox_to_anchor=(1., 1.), loc=2, borderaxespad=1., fancybox=True)
    pp.subplots_adjust(left=0.1, right=0.8, top=0.9, bottom=0.1)
    pp.ylim(0.2, 1.01)
    pp.savefig(directory + "/CongestionCDF.svg")
Beispiel #12
0
def display (all_congestions, directory):
  sort_cong = OrderedDict()
  for scheme in sorted(all_congestions.keys()):
    sort_cong[scheme] = get_scheme_congestions(all_congestions, scheme)

  CommonConf.setupMPPDefaults()
  colors = CommonConf.getLineColorsDict()
  fmts = CommonConf.getLineFormatsDict()
  linewidth = CommonConf.getLineMarkersLWDict()
  mrkrs = CommonConf.getLineMarkersDict()
  mrkrsize = CommonConf.getLineMarkersSizeDict()

  fig = pp.figure(figsize=(12,6))
  ax = fig.add_subplot(111)
  mxl = 0
  num_sample=20
  for solver, cong_dist in sort_cong.iteritems():
    ys = [x/len(cong_dist) for x in range(0, len(cong_dist))]
    gap=int(len(ys)/num_sample)+1
    xx=[]
    yy=[]
    for i in range(0,len(ys)):
      if (i%gap==0):
        xx.append(cong_dist[i])
        yy.append(ys[i])
    if (len(ys)-1)%gap!=0:
      xx.append(cong_dist[-1])
      yy.append(ys[-1])

    ydevs = [0] * len(yy)
    ax.errorbar(xx, yy, yerr=ydevs,
            alpha=0.8,
            color=colors[solver],
            label=CommonConf.gen_label(solver),
            linewidth=linewidth[solver],
            linestyle=fmts[solver],
            marker=mrkrs[solver],
            markersize=mrkrsize[solver])

  ax.set_xlabel(X_LABEL)
  ax.set_ylabel(Y_LABEL)
  ax.legend(bbox_to_anchor=(1., 1.), loc=2, borderaxespad=1., fancybox=True)
  pp.subplots_adjust(left=0.1, right=0.8, top=0.9, bottom=0.1)
  pp.ylim(0.2,1.01)
  pp.savefig(directory+"/CongestionCDF.svg")
def main(dirn, fname, solvers):
  (xs, ysPerSolver, ydevsPerSolver) = CommonViz.parseData(dirn, fname, solvers)

  CommonConf.setupMPPDefaults()
  colors = CommonConf.getLineColorsDict()
  fmts = CommonConf.getLineFormatsDict()
  linewidth = CommonConf.getLineMarkersLWDict()
  mrkrs = CommonConf.getLineMarkersDict()
  mrkrsize = CommonConf.getLineMarkersSizeDict()

  fig = pp.figure(figsize=(12,6))
  ax = fig.add_subplot(111)
  # ax.set_xscale("log", basex=2)

  index = 0
  #xs.append(max(xs)+2)
  for (solver, ys), (solver, ydevs) in zip(ysPerSolver.iteritems(),ydevsPerSolver.iteritems()) :
    xs_arr = np.asarray(xs)
    xs_arr = xs_arr + random.random()/10
    ax.errorbar(xs_arr, ys, yerr=ydevs,
            alpha=0.8,
            color=colors[solver],
            label=CommonConf.gen_label(solver),
            linewidth=linewidth[solver],
            linestyle=fmts[solver],
            marker=mrkrs[solver],
            markersize=mrkrsize[solver])

  ax.set_xlabel(X_LABEL);
  ax.set_ylabel(Y_LABEL);
  ax.legend(loc=0, borderaxespad=1., fancybox=True)
  ymin, ymax = pp.ylim()
  pp.ylim(0.5,1.05)

  xa = ax.get_xaxis()
  xa.set_major_locator(pylab.MaxNLocator(integer=True))
  #ax.annotate('link (s2-s12) fails', xy=(1.8, 0.54), xytext=(0.95, 0.6),
  #          arrowprops=dict(facecolor='black', shrink=0.05), fontsize=14
  #          )
  #pp.axvline(1.8, linestyle='dashed' )
  pp.subplots_adjust(left=0.1, right=0.8, top=0.9, bottom=0.1)

  #pp.savefig(dirn+"/"+fname+"-".join(solvers)+".pdf")
  pp.savefig(dirn+"/"+fname+"-".join(solvers)+".svg")
Beispiel #14
0
def main(dirn, fname, solvers):
    (xs, ysPerSolver, ydevsPerSolver) = CommonViz.parseData(dirn, fname, solvers)

    CommonConf.setupMPPDefaults()
    colors = CommonConf.getLineColorsDict()
    fmts = CommonConf.getLineFormatsDict()
    linewidth = CommonConf.getLineMarkersLWDict()
    mrkrs = CommonConf.getLineMarkersDict()
    mrkrsize = CommonConf.getLineMarkersSizeDict()

    fig = pp.figure(figsize=(12, 6))
    ax = fig.add_subplot(111)
    # ax.set_xscale("log", basex=2)

    xs.append(max(xs) + 2)
    for (solver, ys), (solver, ydevs) in zip(ysPerSolver.iteritems(), ydevsPerSolver.iteritems()):
        xs_arr = np.asarray(xs)
        xs_arr = xs_arr + random.random() / 2
        xs_arr[-1] += random.random() * 2
        avg_y, std_y = np.mean(np.asarray(ys)), np.std(np.asarray(ys))
        ys.append(avg_y)
        ydevs.append(std_y)

        ax.errorbar(
            xs_arr,
            ys,
            yerr=ydevs,
            alpha=0.8,
            color=colors[solver],
            label=CommonConf.gen_label(solver),
            linewidth=linewidth[solver],
            linestyle=fmts[solver],
            marker=mrkrs[solver],
            markersize=mrkrsize[solver],
        )

    ax.set_xlabel(X_LABEL)
    ax.set_ylabel(Y_LABEL)
    ax.legend(bbox_to_anchor=(1.0, 1.0), loc=2, borderaxespad=1.0, fancybox=True)
    pp.subplots_adjust(left=0.1, right=0.8, top=0.9, bottom=0.1)

    pp.savefig(dirn + "/" + fname + "-".join(solvers) + ".svg")
Beispiel #15
0
def main(dirn, fname, solvers):
    (xs, ysPerSolver,
     ydevsPerSolver) = CommonViz.parseData(dirn, fname, solvers)

    CommonConf.setupMPPDefaults()
    colors = CommonConf.getLineColorsDict()
    fmts = CommonConf.getLineFormatsDict()
    linewidth = CommonConf.getLineMarkersLWDict()
    mrkrs = CommonConf.getLineMarkersDict()
    mrkrsize = CommonConf.getLineMarkersSizeDict()

    fig = pp.figure(figsize=(12, 6))
    ax = fig.add_subplot(111)
    # ax.set_xscale("log", basex=2)

    xs.append(max(xs) + 2)
    for (solver, ys), (solver, ydevs) in zip(ysPerSolver.iteritems(),
                                             ydevsPerSolver.iteritems()):
        xs_arr = np.asarray(xs)
        xs_arr = xs_arr + random.random() / 2
        xs_arr[-1] += random.random() * 2
        avg_y, std_y = np.mean(np.asarray(ys)), np.std(np.asarray(ys))
        ys.append(avg_y)
        ydevs.append(std_y)

        ax.errorbar(xs_arr,
                    ys,
                    yerr=ydevs,
                    alpha=0.8,
                    color=colors[solver],
                    label=CommonConf.gen_label(solver),
                    linestyle=fmts[solver],
                    linewidth=linewidth[solver],
                    marker=mrkrs[solver],
                    markersize=mrkrsize[solver])

    ax.set_xlabel(X_LABEL)
    ax.set_ylabel(Y_LABEL)
    ax.legend(bbox_to_anchor=(1., 1.), loc=2, borderaxespad=1., fancybox=True)
    pp.subplots_adjust(left=0.1, right=0.8, top=0.9, bottom=0.1)

    pp.savefig(dirn + "/" + fname + "-".join(solvers) + ".svg")
Beispiel #16
0
def display (all_latencies, directory): # all_latencies : solver -> #tm(0-23) -> path_len -> frac_traffic
    scheme_latency_dist = OrderedDict()  # solver -> path_length -> (frac_tput_mean, frac_tput_std)
    for solver in all_latencies.keys():
        lat_percentile = get_latency_percentile(all_latencies, solver)
        scheme_latency_dist[solver] = lat_percentile
    CommonConf.setupMPPDefaults()
    fmts = CommonConf.getLineFormatsDict()
    mrkrs = CommonConf.getLineMarkersDict()
    mrkrsize = CommonConf.getLineMarkersSizeDict()
    mrkrlw = CommonConf.getLineMarkersLWDict()
    colors = CommonConf.getLineColorsDict()
    fig = pp.figure(figsize=(6,5))
    ax = fig.add_subplot(111)
    max_lat = 0
    for solver, latencies in scheme_latency_dist.iteritems():
        max_lat = max(max_lat, max(latencies.keys()))

    gap=1
    for solver, latencies in scheme_latency_dist.iteritems():
        xs = []
        xsall = sorted(latencies.keys())
        for i in range(0,len(xsall)):
          if (i%gap==0):
            xs.append(xsall[i])
        if (len(xsall)-1)%gap!=0:
          xs.append(xsall[-1])

        ys = [latencies[lat][0] for lat in xs]
        ydevs = [latencies[lat][1] for lat in xs]
        ax.plot((xs[-1], max_lat), (ys[-1], ys[-1]), linestyle=':',
                marker=mrkrs[solver],
                color=colors[solver],
                markersize=mrkrsize[solver],
                markerfacecolor='none',
                markeredgecolor=colors[solver],
                markeredgewidth=mrkrsize[solver]/4,
                linewidth=mrkrlw[solver])

        new_xs = np.linspace(min(xs), max(xs), (max(xs)-min(xs))*3+1)
        print new_xs
        yinterp = pchip(xs, ys)
        ydevsinterp = pchip(xs, ydevs)
        new_ys = yinterp(new_xs)
        new_ydevs = ydevsinterp(new_xs)
        ax.errorbar(new_xs, new_ys, yerr=new_ydevs,
                label=CommonConf.gen_label(solver), marker=mrkrs[solver],
                linestyle=fmts[solver],
                color=colors[solver],
                markersize=mrkrsize[solver],
                markerfacecolor='none',
                markeredgecolor=colors[solver],
                markeredgewidth=mrkrsize[solver]/4,
                markevery=len(new_xs)/4,
                errorevery=len(new_xs)/4,
                linewidth=mrkrlw[solver])
    ax.set_xlabel(X_LABEL)
    ax.set_ylabel(Y_LABEL)
    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)
    ax.yaxis.set_ticks_position('left')
    ax.xaxis.set_ticks_position('bottom')
    ax.legend(loc='best', borderaxespad=1., fancybox=True)
    pp.subplots_adjust(left=0.1, right=0.8, top=0.9, bottom=0.1)
    pp.ylim(0.0,1.05)
    xmin,xmax = ax.get_xlim()
    xmax = (xmax + (xmax%2))
    pp.xlim(3, xmax)
    pp.tight_layout()
    pp.savefig(directory+"/LatencyCDF.svg")
def plotfigure(metric_name,dotfile):
    curf="expData";
    todofolder=[f for f in listdir(curf) if op.isdir(op.join(curf, f)) & ("prediction_"+dotfile in f) ]
    mydict={}
    curname=0;
    totiter=0
    xx=[]
    for folder in todofolder:
        xx.append(100*float(folder[len("prediction_"+dotfile):]))
        curname += 1
        picked_file=[f for f in listdir(op.join(curf,folder)) if op.isfile(op.join(curf,folder, f)) & (metric_name+'.dat' in f) & (not 'swp' in f)]
        if (len(picked_file)>1):
            assert(False)
        picked_file=picked_file[0]
        f=open(op.join(curf,folder,picked_file))
        for line in f.readlines():
            if "solver" in line:
                continue
            words=line.split("\t")
            if (len(words)<4):
                continue
            if (not words[0] in mydict):
                mydict[words[0]]=[[] for i in range(len(todofolder))]
            if (int(words[1])>totiter):
                totiter=int(words[1])
            mydict[words[0]][curname-1].append(float(words[2]))
    mean_list={}
    var_list={}
    for alg in mydict:
        mean_list[alg]=OrderedDict()
        var_list[alg]=OrderedDict()
        i=0
        for all_num in mydict[alg]:
            mean_list[alg][xx[i]]=numpy.mean(numpy.array(all_num), axis=0)
            var_list [alg][xx[i]]=numpy.std(numpy.array(all_num), axis=0)
            i+=1

    totiter+= 1
    fig=pp.figure(figsize=(18,9))
    dotted=0
    m=CommonConf.getLineMarkers()
    linest=CommonConf.getLineFormats()
    colors=CommonConf.getLineColors()


    for alg in sorted(mydict):
        print(alg,':')
        for key in sorted(mean_list[alg]):
            print(key,mean_list[alg][key])
        ml=[]
        kl=[]
        vl=[]
        for key in sorted(mean_list[alg]):
            kl.append(key)
            ml.append(mean_list[alg][key])
            vl.append(var_list[alg][key])
        xs=np.asarray(kl)+random.random()*5
        pp.errorbar(xs,ml,vl,label=alg, linestyle=linest[dotted], marker=m[dotted],color=colors[dotted])
        dotted+=1
    x1,x2,y1,y2 = pp.axis()
    pp.axis((x1,x2+0.1,y1,y2+0.05))
    pp.legend(loc='best',prop={'size':14},bbox_to_anchor=(1.02, 1))
    pp.tight_layout(pad=20)
    pp.xlabel('Random perturbation %')
    pp.ylabel(metric_name)
    pp.savefig("expData/prediction_"+dotfile+"_"+metric_name+".svg")
    #pp.show()
    pp.close(fig)
Beispiel #18
0
def plot_latency(rtt_file, paths_dir, out_file, rtt_hop):
    paths_file = dict()
    for alg in algs:
        paths_file[alg] = paths_dir + '/' + alg + '_0'
    rtts = parse_rtt_file(rtt_file)
    alg_sd_wtrtt = defaultdict(dict)  # alg -> sd -> weighted_rtt
    for alg in algs:
        paths = parse_path_file(paths_file[alg])
        for sd, sdpaths in paths.iteritems():
            weighted_rtts = 0
            for path, weight in sdpaths.iteritems():
                path_rtt = 0
                if rtt_hop == 'rtt':
                    for link in path:
                        path_rtt += rtts.get(link, 0)
                else:
                    path_rtt = len(path) - 2
                weighted_rtts += weight * path_rtt
            alg_sd_wtrtt[alg][sd] = weighted_rtts
    # sort hosts by ecmp weighted RTT
    sorted_sd = sorted(alg_sd_wtrtt['ecmp'].items(),
                       key=operator.itemgetter(1))
    sorted_sd = [x[0] for x in sorted_sd]
    alg_sorted_lats = dict(
    )  # alg -> list of latencies sorted by ecmp distance
    for alg in algs:
        if alg == BASE:
            alg_sorted_lats[alg] = [alg_sd_wtrtt[BASE][sd] for sd in sorted_sd]
        else:
            alg_sorted_lats[alg] = [
                (alg_sd_wtrtt[alg][sd] - 0 * alg_sd_wtrtt[BASE][sd])
                for sd in sorted_sd
            ]

    setupMPPDefaults()
    colors = CommonConf.getLineColorsDict()
    fmts = CommonConf.getLineFormatsDict()
    linewidth = CommonConf.getLineMarkersLWDict()
    mrkrs = CommonConf.getLineMarkersDict()
    mrkrsize = CommonConf.getLineMarkersSizeDict()
    for solver in algs:
        fig = pp.figure(figsize=(12, 6))
        ax = fig.add_subplot(111)

        #if solver == BASE:
        #    continue
        ys = alg_sorted_lats[solver]
        print solver
        if solver == 'ecmp' or solver == 'edksp':
            markeredgecolor = colors[solver]
        else:
            markeredgecolor = 'None'
        ax.plot(
            #alg_sorted_lats[BASE],
            ys,
            alpha=0.5,
            color=colors[solver],
            label=CommonConf.gen_label(solver),
            linewidth=linewidth[solver],
            linestyle='None',
            markevery=1,
            markeredgecolor=markeredgecolor,
            markeredgewidth=mrkrsize[solver] / 4,
            marker=mrkrs[solver],
            markersize=mrkrsize[solver] * 1.5)

        ax.set_xlabel("Node Pairs")
        if rtt_hop == 'rtt':
            ax.set_ylabel("RTT (ms)")
        else:
            ax.set_ylabel("hop count")

        ax.spines['right'].set_visible(False)
        ax.spines['top'].set_visible(False)
        ax.yaxis.set_ticks_position('left')
        ax.xaxis.set_ticks_position('bottom')

        ax.xaxis.set_ticks([])
        # handles, labels = ax.get_legend_handles_labels()
        # # or sort them by labels
        # hl = sorted(zip(handles, labels), key=operator.itemgetter(1))
        # hl = hl[1:5]+[hl[0]]+[hl[5]] # Put racke in correct position
        # handles2, labels2 = zip(*hl)
        # ax.legend(handles2, labels2, loc='best', borderaxespad=0., fancybox=True, ncol=3)
        pp.locator_params(nbins=4)
        pp.tight_layout(pad=0)
        pp.savefig(out_file.split('.')[0] + solver + '.pdf')
Beispiel #19
0
    if title:
        network_title = ax.text(
            0.98,
            0.98,
            G.graph['Network'],
            horizontalalignment='right',
            #weight='heavy',
            fontsize=16,
            color=title_color,
            verticalalignment='top',
            transform=ax.transAxes)

    if options.showalg:
        ax.text(0.02,
                0.02,
                CommonConf.gen_label(solver),
                style='normal',
                horizontalalignment='left',
                fontsize=max(label_font_size, 16),
                color=title_color,
                verticalalignment='top',
                transform=ax.transAxes)

    # Show colorbar for edge color encoding
    if options.link_util:
        a = np.array([[0, max_scale]])
        im = plt.imshow(a, cmap=cm.rainbow)
        ax = plt.gca()
        divider = make_axes_locatable(ax)
        cax = divider.append_axes("right", size="2%", pad=0.02)
        plt.colorbar(im, cax=cax)
Beispiel #20
0
def plotfigure(metric_name, dotfile, mode):
    curf = "expData"
    todofolder = [
        f for f in listdir(curf)
        if op.isdir(op.join(curf, f)) & ("burst_" + mode + "_" + dotfile in f)
    ]
    mydict = {}
    curname = 0
    totiter = 0
    xx = []
    for folder in todofolder:
        print(folder)
        xx.append(100 * float(folder[folder.rfind('_') + 1:]))
        curname += 1
        picked_file = [
            f for f in listdir(op.join(curf, folder))
            if op.isfile(op.join(curf, folder, f))
            & (metric_name + '.dat' in f) & (not 'swp' in f)
        ]
        if (len(picked_file) > 1):
            assert (False)
        picked_file = picked_file[0]
        f = open(op.join(curf, folder, picked_file))
        for line in f.readlines():
            if "solver" in line:
                continue
            words = line.split("\t")
            if (len(words) < 4):
                continue
            if (not words[0] in mydict):
                mydict[words[0]] = [[] for i in range(len(todofolder))]
            if (int(words[1]) > totiter):
                totiter = int(words[1])
            mydict[words[0]][curname - 1].append(float(words[2]))
    mean_list = {}
    var_list = {}
    for alg in mydict:
        mean_list[alg] = OrderedDict()
        var_list[alg] = OrderedDict()
        i = 0
        for all_num in mydict[alg]:
            #mean_list[alg][xx[i]]=numpy.mean(numpy.array(all_num), axis=0)
            #var_list [alg][xx[i]]=numpy.std(numpy.array(all_num), axis=0)
            mean_list[alg][xx[i]] = all_num[flash_time]
            var_list[alg][xx[i]] = 0
            i += 1

    totiter += 1
    fig = pp.figure(figsize=(18, 9))
    dotted = 0
    m = CommonConf.getLineMarkers()
    linest = CommonConf.getLineFormats()
    colors = CommonConf.getLineColors()

    for alg in sorted(mydict):
        print(alg, ':')
        for key in sorted(mean_list[alg]):
            print(key, mean_list[alg][key])
        ml = []
        kl = []
        vl = []
        for key in sorted(mean_list[alg]):
            kl.append(key)
            ml.append(mean_list[alg][key])
            vl.append(var_list[alg][key])
        xs = np.asarray(kl) + random.random() * 3
        pp.errorbar(xs,
                    ml,
                    vl,
                    label=alg,
                    linestyle=linest[dotted],
                    marker=m[dotted],
                    color=colors[dotted])
        dotted += 1
    x1, x2, y1, y2 = pp.axis()
    pp.axis((x1, x2 + 0.1, y1, y2 + 0.05))
    pp.legend(loc='best', prop={'size': 14}, bbox_to_anchor=(1.02, 1))
    pp.tight_layout(pad=20)
    pp.xlabel('Burst amount')
    pp.ylabel(metric_name)
    pp.savefig("expData/burst_" + dotfile + "_" + metric_name + ".svg")
    pp.close(fig)
Beispiel #21
0
def display(
    all_latencies, directory
):  # all_latencies : solver -> #tm(0-23) -> path_len -> frac_traffic
    scheme_latency_dist = OrderedDict(
    )  # solver -> path_length -> (frac_tput_mean, frac_tput_std)
    for solver in all_latencies.keys():
        lat_percentile = get_latency_percentile(all_latencies, solver)
        scheme_latency_dist[solver] = lat_percentile
    CommonConf.setupMPPDefaults()
    fmts = CommonConf.getLineFormatsDict()
    mrkrs = CommonConf.getLineMarkersDict()
    mrkrsize = CommonConf.getLineMarkersSizeDict()
    mrkrlw = CommonConf.getLineMarkersLWDict()
    colors = CommonConf.getLineColorsDict()
    fig = pp.figure(figsize=(9, 6))
    ax = fig.add_subplot(111)
    max_lat = 0
    for solver, latencies in scheme_latency_dist.iteritems():
        max_lat = max(max_lat, max(latencies.keys()))

    gap = 1
    for solver, latencies in scheme_latency_dist.iteritems():
        if solver not in solver_list:
            continue
        xs = []
        xsall = sorted(latencies.keys())
        for i in range(0, len(xsall)):
            if (i % gap == 0):
                xs.append(xsall[i])
        if (len(xsall) - 1) % gap != 0:
            xs.append(xsall[-1])

        ys = [latencies[lat][0] for lat in xs]
        ydevs = [latencies[lat][1] for lat in xs]
        #        ax.plot((xs[-1], max_lat), (ys[-1], ys[-1]), linestyle=':',
        #                marker=mrkrs[solver],
        #                color=colors[solver],
        #                markersize=mrkrsize[solver],
        #                markerfacecolor='none',
        #                markeredgecolor=colors[solver],
        #                markeredgewidth=mrkrsize[solver]/4,
        #                linewidth=mrkrlw[solver])

        new_xs = np.linspace(min(xs), max(xs), (max(xs) - min(xs)) * 3 + 1)
        print new_xs
        yinterp = pchip(xs, ys)
        ydevsinterp = pchip(xs, ydevs)
        new_ys = yinterp(new_xs)
        new_ydevs = ydevsinterp(new_xs)
        ax.errorbar(
            new_xs,
            new_ys,  # yerr=new_ydevs,
            label=CommonConf.gen_label(solver),  # marker=mrkrs[solver],
            linestyle=fmts[solver],
            color=colors[solver],
            markersize=mrkrsize[solver],
            markerfacecolor='none',
            markeredgecolor=colors[solver],
            markeredgewidth=mrkrsize[solver] / 4,
            markevery=None,  # len(new_xs)/20,
            errorevery=len(new_xs) / 20,
            linewidth=mrkrlw[solver])
        ax.fill_between(new_xs,
                        new_ys - new_ydevs,
                        new_ys + new_ydevs,
                        facecolor=colors[solver],
                        alpha=0.3,
                        interpolate=True,
                        edgecolor=colors[solver])
    ax.set_xlabel(X_LABEL)
    ax.set_ylabel(Y_LABEL)
    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)
    ax.yaxis.set_ticks_position('left')
    ax.xaxis.set_ticks_position('bottom')
    ax.legend(loc='best', borderaxespad=0., fancybox=True)
    pp.subplots_adjust(left=0.1, right=0.8, top=0.9, bottom=0.1)
    pp.ylim(0.0, 1.05)
    xmin, xmax = ax.get_xlim()
    xmax = (xmax + (xmax % 2))
    pp.xlim(3, 350)
    pp.tight_layout(pad=0)
    pp.savefig(directory + "/LatencyCDF.pdf")
Beispiel #22
0
#sqlquery
demografia_all = sql.demografia_all()
domeny = sql.domeny(poczatek, koniec)
smsy = sql.smsy(poczatek, koniec)
kategorie_app = sql.kategorie_app(poczatek, koniec)
polaczenia = sql.polaczenie(poczatek, koniec)
wybrane_app = sql.wybrane_app(poczatek, koniec)

domeny_2 = sql.domeny(poczatek_2, koniec_2)
smsy_2 = sql.smsy(poczatek_2, koniec_2)
kategorie_app_2 = sql.kategorie_app(poczatek_2, koniec_2)
polaczenia_2 = sql.polaczenie(poczatek_2, koniec_2)
wybrane_app_2 = sql.wybrane_app(poczatek_2, koniec_2)

#pobieranie danych
cm.executeAndSaveIdList(os + 'data_raw/id_list.csv',demografia_all,['dve_id;dve_usr_id'])
print('---Data saved to ..data_raw/id_list.csv')
cm.executeAndSaveDemografy(os + 'data_raw/demografia/demografia_all.csv',demografia_all,['dve_id','dve_usr_id','Zaznacz_swoją_płeć','Określ_swoje_wykszałcenie','Wskaż_wielkość_miejscowości','Wiek'])
print('---Data saved to ..data_raw/demografia/demografia_all.csv')
cm.executeAndSave(os + 'data_raw/domeny/domeny'+ '_'+ poczatek+ '.csv',domeny, ['dve_id;wbhh_hourperiod;wdmn_domain;wywolan;unikalni_uzytkownicy'])
cm.executeAndSave(os + 'data_raw/domeny/domeny'+ '_'+ poczatek_2+ '.csv',domeny_2, ['dve_id;wbhh_hourperiod;wdmn_domain;wywolan;unikalni_uzytkownicy'])
print('---Data saved to ...data_raw/domeny/domeny.csv')
cm.executeAndSave(os + 'data_raw/kategorie_app/kategorie_app'+ '_'+ poczatek+ '.csv', kategorie_app, ['aprh_hourperiod;dve_id;appc_catname;czas'])
cm.executeAndSave(os + 'data_raw/kategorie_app/kategorie_app'+ '_'+ poczatek_2+ '.csv', kategorie_app_2, ['aprh_hourperiod;dve_id;appc_catname;czas'])
print('---Data saved to ...data_raw/kategorie_app/kategorie_app.csv')
cm.executeAndSave(os + 'data_raw/polaczenia/polaczenia'+ '_'+ poczatek+ '.csv', polaczenia, ['dve_id;calh_hourperiod;call-przychodzace-czas;call-wychodzace-czas'])
cm.executeAndSave(os + 'data_raw/polaczenia/polaczenia'+ '_'+ poczatek_2+ '.csv', polaczenia_2, ['dve_id;calh_hourperiod;call-przychodzace-czas;call-wychodzace-czas'])
print('---Data saved to ...data_raw/polaczenia/polaczenia.csv')
cm.executeAndSave(os + 'data_raw/smsy/smsy'+ '_'+ poczatek+ '.csv',smsy,['dve_id;smsh_hourperiod;sms-dlugosc-odebrane;sms-dlugosc-wyslane'])
cm.executeAndSave(os + 'data_raw/smsy/smsy'+ '_'+ poczatek_2+ '.csv',smsy_2,['dve_id;smsh_hourperiod;sms-dlugosc-odebrane;sms-dlugosc-wyslane'])
print('---Data saved to ...data_raw/smsy/smsy.csv')
Beispiel #23
0
def display(all_congestions, snapshot, directory, outfile):
    sort_cong = OrderedDict()
    for scheme in sorted(all_congestions.keys()):
        sort_cong[scheme] = get_scheme_congestions(all_congestions, snapshot,
                                                   scheme)

    CommonConf.setupMPPDefaults()
    colors = CommonConf.getLineColorsDict()
    fmts = CommonConf.getLineFormatsDict()
    linewidth = CommonConf.getLineMarkersLWDict()
    mrkrs = CommonConf.getLineMarkersDict()
    mrkrsize = CommonConf.getLineMarkersSizeDict()

    fig = pp.figure(figsize=(9, 6))
    ax = fig.add_subplot(111)
    mxl = 0
    num_sample = 1000
    for solver, cong_dist in sort_cong.iteritems():
        if solver not in CommonConf.solver_list:
            continue
        ys = [x / len(cong_dist) for x in range(0, len(cong_dist))]
        gap = int(len(ys) / num_sample) + 1
        xx = []
        yy = []
        for i in range(0, len(ys)):
            if (i % gap == 0):
                xx.append(cong_dist[i])
                yy.append(1 - ys[i])
        if (len(ys) - 1) % gap != 0:
            xx.append(cong_dist[-1])
            yy.append(1 - ys[-1])

        ydevs = [0] * len(yy)
        #ax.errorbar(xx, yy, yerr=ydevs,
        #        alpha=0.8,
        #        color=colors[solver],
        #        label=CommonConf.gen_label(solver),
        #        linewidth=linewidth[solver],
        #        linestyle=fmts[solver],
        #        marker=None,#mrkrs[solver],
        #        markersize=mrkrsize[solver])
        ax.plot(
            xx,
            yy,
            alpha=0.8,
            color=colors[solver],
            label=CommonConf.gen_label(solver),
            linewidth=linewidth[solver],
            linestyle=fmts[solver],
            marker=None,  #mrkrs[solver],
            markersize=mrkrsize[solver])

    ax.set_xlabel(X_LABEL)
    ax.set_ylabel(Y_LABEL)
    ax.legend(loc='best', borderaxespad=0., fancybox=True)
    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)
    ax.xaxis.set_ticks_position('bottom')
    ax.yaxis.set_ticks_position('left')
    #pp.subplots_adjust(left=0.2, right=0.95, top=0.95, bottom=0.15)
    xmax = pp.xlim()[1]
    if xmax > 1:
        ax.set_xlabel(X_EXPLABEL)
        ax.set_xscale("log", nonposx='clip')
        ax.set_yscale("log", nonposx='clip')
        print pp.xlim()
        xmax = pp.xlim()[1]
        ax.xaxis.set_major_formatter(ScalarFormatter())
        #ax.yaxis.set_major_formatter(ScalarFormatter())
        ax.axvline(x=1, color='r', lw=2, ls='-')
        currentAxis = pp.gca()
        currentAxis.add_patch(
            Rectangle((1, 0), xmax, 1, facecolor="red", alpha=0.05))
        pp.xlim(1e-2, 1e2)
        pp.ylim(1e-4, 1e0)
    pp.tight_layout(pad=0)
    pp.savefig(directory + "/" + outfile + ".pdf")