Ejemplo n.º 1
0
def plot_moreprojects():
    data = read_csv("moreprojects")
    data = data[(data.hungry <= 40) & data.success]

    # drop known outliers:
    data = data[~((data.projects == 6) & (data.hungry == 35))]
    data = data[~((data.projects == 8) & (data.hungry == 39))]

    projects = [5, 6, 7, 8, 9]
    labels = [f"{n} projects" for n in projects]
    x_ticks = data[data.projects == projects[0]].hungry.unique()

    fig, ax = resultlib.prepare_graph()

    for n, label in zip(projects, labels):
        subsel = data[data.projects == n][["hungry", "nsec"]]
        grouping = subsel.groupby("hungry")["nsec"]
        line = grouping.median()
        ax.plot(line.index, line.values, "-", label=label)

    ax.set_xlabel("Number of workers")
    plt.legend()
    plt.xticks(x_ticks, rotation="vertical")
    # plt.yscale("log")

    fig.tight_layout()
    plt.savefig("workers-moreprojects.pdf")
    plt.close()
Ejemplo n.º 2
0
def plot_morerooms():
    data = read_csv("morerooms-optimizing")
    data = data[["hungry", "nsec"]][data.hungry < 16]
    grouping = data.groupby("hungry")["nsec"]

    xticks, series = zip(*grouping)

    fig, ax = resultlib.prepare_graph()
    ax.boxplot(series, showfliers=False, positions=xticks)
    # plt.xticks(range(1, len(series) + 1), xticks)

    def exp(x, a, b, c):
        return a * np.exp(b * x) + c

    meds = grouping.median()
    popt, _ = curve_fit(exp, meds.index, meds.values)

    fitx = np.linspace(xticks[0], xticks[-1], 100)
    fity = exp(fitx, *popt)
    plt.plot(fitx, fity, "-")

    ax.set_xlabel("Number of workers")
    fig.tight_layout()
    plt.savefig("workers-morerooms.pdf")
    plt.close()
Ejemplo n.º 3
0
def plot_badsolver():
    data = read_csv("badsolver-growingprojects")
    groups = data.groupby("projects")["nsec"]

    projects = list(range(4, 31, 4))

    fig, ax = resultlib.prepare_graph()
    for p in projects:
        series = groups.get_group(p)
        series = series.sort_values(ascending=True).reset_index(drop=True)
        ax.plot(series.index, series, "-", label=f"{p} projects")

    perc_ticks = list(range(0, 101, 10))
    plt.xticks([p * 5 for p in perc_ticks], perc_ticks)
    ax.set_xlabel("Percentile")
    plt.legend()

    fig.tight_layout()
    plt.savefig("badsolver.pdf")
    plt.close()
Ejemplo n.º 4
0
def plot_timeouts():
    data = resultlib.read_csv("timelimits", COLUMNS)
    data.timeout //= 1000
    flt = data[data.success]
    grouping = flt.groupby("timeout")["utility"]
    xticks, series = zip(*grouping)

    fig, ax = resultlib.prepare_graph()
    plt.xticks(rotation="vertical")
    ax.boxplot(series, showfliers=False, positions=xticks)

    def log(x, a, b):
        return a + b * np.log(x)

    meds = grouping.median()
    popt, _ = curve_fit(log, meds.index, meds.values)

    fitx = np.linspace(xticks[0], xticks[-1], 100)
    fity = log(fitx, *popt)
    ax.plot(fitx, fity, "-")

    color = "#d62728"
    ax2 = ax.twinx()
    ax2.set_yticks(list(range(0, 101, 10)))
    ax2.set_ylim(0, 100)
    perc = 100 - grouping.count()
    ax2.plot(perc.index, perc.values, "--", color=color)

    ax2.set_ylabel("Failed attempts (out of 100)")
    ax2.tick_params(axis="y", labelcolor=color)

    plt.xlim(0.5, 30.5)

    ax.set_xlabel("Time limit (s)")
    ax.set_ylabel("Total utility")

    fig.tight_layout()
    plt.savefig("timelimits.pdf")
    plt.close()
Ejemplo n.º 5
0
def plot_onebyone():
    data = read_csv("oneworker-params")
    data = data[data.success]
    x_ticks = data.lunch_n.unique()
    project_counts = data.projects.unique()
    colors = make_colors(len(project_counts))
    labels = [f"{n} projects" for n in project_counts]

    fig, ax = resultlib.prepare_graph()

    def poly(x, a, b, e):
        return a * x ** e + b

    for label, color, n in zip(labels, colors, project_counts):
        subsel = data[data.projects == n][["lunch_n", "nsec"]]
        grouping = subsel.groupby("lunch_n")["nsec"]
        linedata = grouping.mean()
        lineerr = grouping.std()
        ax.errorbar(
            linedata.index,
            linedata.values,
            yerr=lineerr,
            fmt="o",
            label=label,
            color=color,
        )

        popt, _ = curve_fit(poly, linedata.index, linedata.values)

        fitx = np.linspace(x_ticks[0], x_ticks[-1], 100)
        fity = poly(fitx, *popt)
        plt.plot(fitx, fity, "-", color=colors[1])

    plt.xticks(x_ticks, rotation="45")
    plt.legend(loc="upper left")
    ax.set_xlabel("Number of lunch rooms")
    fig.tight_layout()
    plt.savefig("workers-oneworker.pdf")
    plt.close()
Ejemplo n.º 6
0
def plot_variables():
    fig, ax = resultlib.prepare_graph()

    for ifn, header, fmt in zip(FILES, HEADERS, FORMATS):
        data = read_csv(ifn)
        subsel = data[data.success]
        subsel = subsel[[ifn, "nsec"]]
        if ifn == "constraints":
            subsel.constraints /= 100
        grouping = subsel.groupby(ifn)["nsec"]
        line = grouping.mean()
        ax.plot(line.index, line.values, fmt, label=header)

    x_ticks = range(500, 10001, 500)
    plt.xticks(x_ticks, rotation="vertical")

    # fig, ax = box_graph(datasets, labels, colors, x_ticks, "vertical")
    ax.set_xlabel("Number of elements")

    plt.legend()
    fig.tight_layout()
    plt.savefig("variables.pdf")
    plt.close()
Ejemplo n.º 7
0
def plot_simple():
    data = read_csv("workercount-simple")
    projects = data.projects.unique()
    fmts = {5: "-o", 15: "-v", 50: "-x"}

    fig, ax = resultlib.prepare_graph()

    for n in projects:
        subsel = data[data.projects == n][["workers", "nsec"]]
        grouping = subsel.groupby("workers")["nsec"]
        line = grouping.median()
        lineerr = grouping.std()
        ax.errorbar(
            line.index, line.values, yerr=lineerr, fmt=fmts[n], label=f"{n} projects"
        )

    plt.legend()
    plt.xticks(line.index, rotation="45")
    ax.set_xlabel("Number of workers")

    fig.tight_layout()
    plt.savefig("workers-simple.pdf")
    plt.close()
Ejemplo n.º 8
0
def plot_variablemem():
    fig, ax = resultlib.prepare_graph()

    for ifn, header, fmt in zip(FILES, HEADERS, FORMATS):
        data = read_csv(ifn)
        data.memory *= 1e-6
        subsel = data[data.success]
        subsel = subsel[[ifn, "memory"]]
        if ifn == "constraints":
            subsel.constraints /= 100
        grouping = subsel.groupby(ifn)["memory"]
        line = grouping.max()
        ax.plot(line.index, line.values, fmt, label=header)

    x_ticks = range(500, 10001, 500)
    plt.xticks(x_ticks, rotation="vertical")

    ax.set_ylabel("Peak memory usage (MB)")
    ax.set_xlabel("Number of elements")

    plt.legend()
    fig.tight_layout()
    plt.savefig("variablemem.pdf")
    plt.close()