Ejemplo n.º 1
0
def generate_loss_rate_cdf(results_repository):
    trial_name = "test-trial-830656277"
    seed_numbers = [trial_name]
    for idx, trial_type in enumerate(TRIAL_TYPES):
        loss_rates_for_seed_number = []
        for seed_number in seed_numbers:
            loss_rate_per_flow = generate_loss_rates(results_repository,
                                                     trial_type, seed_number)
            xs = [0.0]
            ys = [0.0]
            for ctr, loss_rate in enumerate(sorted(loss_rate_per_flow)):
                xs.append(loss_rate)
                ys.append((ctr + 1) / len(loss_rate_per_flow))
            plt.plot(xs,
                     ys,
                     linestyle="-",
                     marker=helpers.marker_style(idx),
                     label=LABEL_NAMES[idx],
                     color=helpers.line_color(idx))
    plt.rc("font", **cfg.FONT)
    plt.rc("legend", edgecolor="black")
    # xtick_locations = [200, 400, 600, 800, 1000]
    plt.xlim(0.0)
    plt.ylim(0.0, 1.0)
    xtick_locations, xtick_labels = plt.xticks()
    ytick_locations, ytick_labels = plt.yticks()
    plt.xticks(xtick_locations[1:],
               [helpers.tick_font(x_i, "%.2f") for x_i in xtick_locations][1:])
    plt.yticks(ytick_locations[1:],
               [helpers.tick_font(y_i, "%.1f") for y_i in ytick_locations][1:])
    plt.ylabel("CDF", **cfg.AXIS_LABELS)
    helpers.save_figure("loss-rate-cdf.pdf", 1)
Ejemplo n.º 2
0
def generate_simulation_run_time_plot(results_repository):
    def mean_confidence_interval(data, confidence=0.95):
        a = 1.0 * np.array(data)
        n = len(a)
        m, se = np.mean(a), scipy.stats.sem(a)
        h = se * scipy.stats.t.ppf((1 + confidence) / 2., n - 1)
        # return m, m-h, m+h
        return h

    series_data = {}

    for flow_count in [100, 500, 1000]:
        data_for_node_counts = []
        for node_count in [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]:
            data_for_single_count = []
            seed_numbers = [
                742349042, 2787879137, 3102739139, 2303690384, 1672982999,
                2501915964, 2853959085, 3163893110, 462786850, 4124106680
            ]

            for seed_number in seed_numbers:
                sim = read_results(results_repository, flow_count, node_count,
                                   seed_number)
                data_for_single_count.append(sim.solution_time)
            pp.pprint(data_for_single_count)
            ci = mean_confidence_interval(data_for_single_count)
            data_for_node_counts.append(
                (node_count, np.mean(data_for_single_count), ci))
        series_data[flow_count] = data_for_node_counts

    for idx, (flow_count, data_for_node_counts) in enumerate(
            sorted(series_data.items(), key=lambda t: t[0])):
        xs = [d_i[0] for d_i in data_for_node_counts]
        ys = [d_i[1] for d_i in data_for_node_counts]
        std_dev = [d_i[2] for d_i in data_for_node_counts]
        plt.errorbar(xs,
                     ys,
                     label="\\LARGE{%d VLs}" % flow_count,
                     marker=cfg.MARKER_STYLE[idx],
                     linestyle=helpers.line_style(idx),
                     color=helpers.line_color(idx),
                     yerr=std_dev,
                     capsize=2)

    plt.rc("text", usetex=True)
    matplotlib.rcParams['text.latex.preamble'] = [
        r'\usepackage{amsmath}', r'\usepackage{amssymb}'
    ]
    plt.rc("font", **cfg.FONT)
    plt.rc("legend", edgecolor="black")
    xtick_locations = [200, 400, 600, 800, 1000]
    ytick_locations = [2, 4, 6, 8, 10, 12, 14]
    plt.xticks(xtick_locations,
               [helpers.tick_font(x_i) for x_i in xtick_locations])
    plt.yticks(ytick_locations,
               [helpers.tick_font(y_i) for y_i in ytick_locations])
    plt.xlabel("Number of Nodes", **cfg.AXIS_LABELS)
    plt.ylabel("Running Time (s)", **cfg.AXIS_LABELS)
    helpers.save_figure("sim-running-time.pdf", 1)
Ejemplo n.º 3
0
def generate_heterogeneous_links_instantaneous_rate_plot():
    link_rate_count = 100
    labels = {
        (100, 0): "\\LARGE{$\\mu=100$, $\\text{CoV}=0.0$}",
        (100, 50): "\\LARGE{$\\mu=100$, $\\text{CoV}=0.5$}",
        (100, 100): "\\LARGE{$\\mu=100$, $\\text{CoV}=1.0$}"
    }

    colors = {(100, 0): "red", (100, 50): "lime", (100, 100): "blue"}
    plt.plot(range(link_rate_count), [100 for _ in range(link_rate_count)],
             label=labels[100, 0],
             color=colors[100, 0])
    for mu, sigma in [(100, 50), (100, 100)]:
        link_rates = heterogeneous_links.get_heterogeneous_link_rates(
            mu, sigma**2, link_rate_count)
        xs = range(len(link_rates))
        ys = link_rates
        plt.plot(xs, ys, label=labels[mu, sigma], color=colors[mu, sigma])

    plt.rc('font', **cfg.FONT)
    plt.xlim(0, link_rate_count - 1)
    plt.xlabel("Time", **cfg.AXIS_LABELS)
    plt.ylabel("Transmission Rate (Mbps)", **cfg.AXIS_LABELS)
    xtick_locations, xtick_labels = plt.xticks()
    ytick_locations, ytick_lables = plt.yticks()
    plt.ylim(0, ytick_locations[-1])
    plt.xticks(xtick_locations[1:], ["" for x_i in xtick_locations])
    plt.yticks(ytick_locations[1:],
               [helpers.tick_font(y_i, "%.0f") for y_i in ytick_locations][1:])
    helpers.save_figure("actual-model-tx-rates.pdf", 1, no_legend=False)
Ejemplo n.º 4
0
def generate_traffic_on_path_bar_plot(data_file):
    def read_literal_from_file(data_file):
        with data_file.open("r") as fd:
            python_literal = eval(fd.read())
        return python_literal

    path_data = read_literal_from_file(data_file)
    xs = []
    ys = []
    target_path_ratios = [0.5, 0.3, 0.2]
    cs = []

    bar_width = 0.2
    pos = 0.1
    for path_idx, (k, v) in enumerate(
            sorted(path_data.items(), key=lambda t: t[1], reverse=True)):
        y_val = v / sum(path_data.values())
        cs.append("blue")
        cs.append("green")
        plt.bar(pos - 0.01, y_val, bar_width, color="gray", edgecolor="black")
        pos += bar_width
        plt.bar(pos + 0.01,
                target_path_ratios[path_idx],
                bar_width,
                color="blue",
                edgecolor="black")
        pos += bar_width

        pos += 0.1
        print("VALUE: %f" % (abs(y_val - target_path_ratios[path_idx]) /
                             target_path_ratios[path_idx]))

    # labels=["Path %d" % path_idx for path_idx in range(1, 4)]
    # plt.bar(xs, ys, edgecolor="black", color=cs)
    legend_labels = [
        "\\Large{expected data volume}", "\\Large{actual data volume}"
    ]
    legend_colors = ["blue", "gray"]
    patches = [
        matplotlib.patches.Patch(color=c, label=l, edgecolor="black")
        for c, l in zip(legend_colors, legend_labels)
    ]
    plt.legend(handles=patches, ncol=2, **cfg.LEGEND)
    xtick_labels = ["Path %d" % path_id for path_id in range(1, 4)]
    xtick_locations = [l_i for l_i in np.arange(0.2, 1.5, 0.5)]
    plt.xticks(xtick_locations, xtick_labels)

    ytick_locations, ytick_labels = plt.yticks()
    plt.yticks(ytick_locations,
               [helpers.tick_font(y_i, "%.1f") for y_i in ytick_locations])

    plt.ylabel("Normalized Data Volume", **cfg.AXIS_LABELS)
    helpers.save_figure("per-path-data-volume.pdf", no_legend=True)
Ejemplo n.º 5
0
def generate_link_utilization_box_plot(results_repository):
    list_of_mean_utils = []
    for trial_type in TRIAL_TYPES:
        mean_link_utils_per_seed_number = []
        for idx, seed_number in enumerate(["test-trial-830656277"]):
            utilization_results, the_vle_trial, end_host_results = read_results(
                results_repository, trial_type, seed_number)
            link_utilization_data = compute_network_util_over_time(
                utilization_results)

            link_ids = [(s, d) for s, t in link_utilization_data[0].items()
                        for d in t.keys()]
            mean_utils = {}
            for s, d in link_ids:
                link_utils_over_time = []
                for time_idx, net_snapshot in enumerate(link_utilization_data):
                    try:
                        link_utils_over_time.append(net_snapshot[s][d])
                    except KeyError:
                        print(
                            "net_snapshot at time %d did not contain link %s -> %s"
                            % (time_idx, s, d))

                mean_utils[s, d] = ((mean(link_utils_over_time) * 8) / 10**6 /
                                    1000)

            list_of_mean_utils.append(mean_utils)
    pp.pprint([list(v.values()) for v in list_of_mean_utils])
    bp = plt.boxplot([list(v.values()) for v in list_of_mean_utils],
                     labels=LABEL_NAMES,
                     whiskerprops={"linestyle": "--"},
                     flierprops={
                         "marker": "x",
                         "markerfacecolor": "red",
                         "markeredgecolor": "red"
                     })

    for element in ["boxes"]:
        plt.setp(bp[element], color="blue")

    plt.setp(bp["medians"], color="red")

    plt.rc("font", **cfg.FONT)
    plt.rc("legend", edgecolor="black")
    # xtick_locations = [200, 400, 600, 800, 1000]
    # ytick_locations = [2, 4, 6, 8, 10, 12, 14]
    ytick_locations, _ = plt.yticks()
    plt.yticks(ytick_locations,
               [helpers.tick_font(y_i, "%.1f") for y_i in ytick_locations])
    plt.ylabel("Link Utilization", **cfg.AXIS_LABELS)
    helpers.save_figure("link-utilization-box-plot.pdf", 3, no_legend=True)
Ejemplo n.º 6
0
def generate_throughput_over_time_plot(data_file):
    def read_literal_from_file(data_file):
        with data_file.open("r") as fd:
            python_literal = eval(fd.read())
        return python_literal

    path_id_to_ratio_map = {4: 0.5, 8: 0.3, 12: 0.2}
    path_to_tputs = read_literal_from_file(data_file)
    num_points = 15
    for plot_idx, (path_id, tputs) in enumerate(
            sorted(path_to_tputs.items(), key=lambda t: t[0])):
        tputs = tputs[1:num_points + 1]
        xs = np.arange(num_points)
        plt.plot(xs,
                 tputs,
                 linestyle="-.",
                 marker=marker_style(plot_idx),
                 color=line_color(plot_idx))
        plt.plot(np.arange(len(tputs)),
                 [path_id_to_ratio_map[path_id] for _ in range(len(tputs))],
                 color=line_color(plot_idx),
                 linestyle="-",
                 linewidth=0.75)

    lines = [
        matplotlib.lines.Line2D([0], [0],
                                c="black",
                                linestyle=s_i,
                                linewidth=width)
        for s_i, width in [("-", 0.75), ("-.", 1.0)]
    ]
    legend_labels = [
        "\\Large{expected throughput}", "\\Large{actual throughput}"
    ]
    plt.legend(lines, legend_labels, ncol=1, **cfg.LEGEND)

    plt.ylim(0.0, 0.6)
    xtick_locations, xtick_labels = plt.xticks()
    plt.xticks(xtick_locations[1:-1], ["" for _ in xtick_locations][1:-1])
    ytick_locations, ytick_labels = plt.yticks()
    plt.yticks(ytick_locations[1:],
               [helpers.tick_font(y_i) for y_i in ytick_locations][1:])

    plt.xlabel("Time", **cfg.AXIS_LABELS)
    plt.ylabel("Normalized Throughput", **cfg.AXIS_LABELS)

    helpers.save_figure("per-path-throughput.pdf", no_legend=True)
Ejemplo n.º 7
0
def generate_flow_rate_plot(results_repository):
    trial_name = "test-trial-830656277"
    utiliztation_results, the_vle_trial, end_host_results = read_results(
        results_repository, "link-embedding", trial_name)
    pp.pprint(the_vle_trial.actual_flow_tx_rates)
    for flow_rates in the_vle_trial.actual_flow_tx_rates[:5]:
        plt.plot(np.arange(len(flow_rates)), flow_rates)

    # plt.rc('text', usetex=True)
    plt.xlim(0, 59)
    plt.rc('font', **cfg.FONT)
    plt.xlabel("Time", **cfg.AXIS_LABELS)
    plt.ylabel("Transmission Rate (Mbps)", **cfg.AXIS_LABELS)
    xtick_locations, xtick_labels = plt.xticks()
    ytick_locations, ytick_lables = plt.yticks()
    plt.xticks(xtick_locations[1:], ["" for x_i in xtick_locations])
    plt.yticks(ytick_locations[1:],
               [helpers.tick_font(y_i, "%.0f") for y_i in ytick_locations][1:])

    # plt.legend(ncol=2, **cfg.LEGEND)
    helpers.save_figure("actual-trace-tx-rates.pdf", 2, no_legend=True)
Ejemplo n.º 8
0
def generate_virtual_link_count_plot(results_repository):
    trial_to_virtual_link_counts = {}
    for trial_type in TRIAL_TYPES:
        trial_to_virtual_link_counts[trial_type] = []
        for idx, seed_number in enumerate(SEED_NUMBERS):
            utilization_results, the_vle_trial, end_host_results = read_results(
                results_repository, trial_type, seed_number)
            number_of_virtual_links = len(the_vle_trial.solver_results.flows)
            trial_to_virtual_link_counts[trial_type].append(
                number_of_virtual_links)

    data_to_be_plotted = {}
    width = 0.1
    box_offset = (width / 2)
    box_locations = []
    for trial_idx, trial_type in enumerate(TRIAL_TYPES):
        mean_virtual_link_count = np.mean(
            trial_to_virtual_link_counts[trial_type])
        virtual_link_count_std_dev = np.std(
            trial_to_virtual_link_counts[trial_type])
        box_locations.append(box_offset)
        plt.bar(box_offset,
                int(mean_virtual_link_count),
                width,
                color="blue",
                edgecolor="black",
                yerr=virtual_link_count_std_dev,
                ecolor="red",
                capsize=2)
        box_offset += (width + 0.1)

    xtick_locations, xtick_labels = plt.xticks()
    plt.xticks(box_locations, LABEL_NAMES)

    ytick_locations, ytick_labels = plt.yticks()
    plt.yticks(ytick_locations,
               [helpers.tick_font(int(y_i)) for y_i in ytick_locations])

    plt.ylabel("No. of Admitted VLs", **cfg.AXIS_LABELS)
    helpers.save_figure("virtual-link-counts.pdf", no_legend=True)
Ejemplo n.º 9
0
def generate_flow_means_plot():
    tx_rate_list, mean_flow_tx_rates, std_dev_flow_tx_rates = core_taps.get_rates_for_flows(
    )

    number_of_flows_to_plot = 40
    plt.errorbar([idx + 1 for idx in range(number_of_flows_to_plot)],
                 mean_flow_tx_rates[:number_of_flows_to_plot],
                 color="red",
                 marker="D",
                 yerr=std_dev_flow_tx_rates[:number_of_flows_to_plot],
                 linestyle="",
                 capsize=2)

    plt.rc('font', **cfg.FONT)
    plt.xlim(0, number_of_flows_to_plot)
    plt.ylabel("Mean Transmission Rate (Mbps)", **cfg.AXIS_LABELS)
    plt.xlabel("Virtual Links", **cfg.AXIS_LABELS)
    xtick_locations, xtick_labels = plt.xticks()
    ytick_locations, ytick_lables = plt.yticks()
    plt.xticks(xtick_locations[1:], ["" for x_i in xtick_locations][1:])
    plt.yticks(ytick_locations[1:],
               [helpers.tick_font(y_i, "%.0f") for y_i in ytick_locations][1:])

    helpers.save_figure("mean-trace-tx-rates.pdf", 2, no_legend=True)
Ejemplo n.º 10
0
def generate_heterogeneous_links_mean_rate_plot():
    link_rate_count = 1000
    number_of_links = 10
    labels = {
        (100, 0): "$\\mu=100$, $\\text{CoV}=0.0$",
        (100, 50): "$\\mu=100$, $\\text{CoV}=0.5$",
        (100, 100): "$\\mu=100$, $\\text{CoV}=1.0$"
    }
    colors = {(100, 0): "red", (100, 50): "lime", (100, 100): "blue"}

    flow_stats = []
    loc_idx = [idx + 1 for idx in range(number_of_links * 3)]
    idx = 0
    np.random.shuffle(loc_idx)
    msize = 4.0
    for _ in range(number_of_links):
        link_rates = [100 for _ in range(link_rate_count)]
        flow_stats.append((np.mean(link_rates), np.std(link_rates), colors[100,
                                                                           0]))
        plt.errorbar(loc_idx[idx],
                     np.mean(link_rates),
                     yerr=0,
                     color=colors[100, 0],
                     capsize=2,
                     linestyle="",
                     marker="D",
                     markersize=msize)
        idx += 1

    for mu, sigma in [(100, 50), (100, 100)]:
        for _ in range(number_of_links):
            link_rates = heterogeneous_links.get_heterogeneous_link_rates(
                mu, sigma**2, link_rate_count)
            flow_stats.append(
                (np.mean(link_rates), np.std(link_rates), colors[mu, sigma]))
            plt.errorbar(loc_idx[idx],
                         np.mean(link_rates),
                         yerr=np.std(link_rates),
                         color=colors[mu, sigma],
                         capsize=2,
                         linestyle="",
                         marker="D",
                         markersize=msize)
            idx += 1

    # plot_order = np.random.choice(flow_stats, size=len(flow_stats), replace=False)
    # plot_order = flow_stats
    # np.random.shuffle(plot_order)
    # err     = [p_i[1] for p_i in plot_order]
    # ys      = [p_i[0] for p_i in plot_order]
    # color_list  = [p_i[2] for p_i in plot_order]
    # plt.errorbar(range(len(ys)), ys, yerr=err, linestyle="", marker="D",
    #         capsize=2, c=color_list)

    lines = [
        matplotlib.lines.Line2D([0], [0],
                                c=c_i,
                                linestyle="",
                                marker="D",
                                markersize=msize)
        for c_i in [colors[100, 0], colors[100, 50], colors[100, 100]]
    ]
    legend_labels = [
        "\\LARGE{%s}" % labels[100, 0],
        "\\LARGE{%s}" % labels[100, 50],
        "\\LARGE{%s}" % labels[100, 100]
    ]
    plt.legend(lines, legend_labels, ncol=1, **cfg.LEGEND)

    plt.rc('font', **cfg.FONT)
    plt.xlim(0, number_of_links * 3)
    plt.ylabel("Mean Transmission Rate (Mbps)", **cfg.AXIS_LABELS)
    plt.xlabel("Virtual Links", **cfg.AXIS_LABELS)
    xtick_locations, xtick_labels = plt.xticks()
    ytick_locations, ytick_lables = plt.yticks()
    plt.ylim(0, ytick_locations[-1])
    plt.xticks(xtick_locations[1:], ["" for x_i in xtick_locations][1:])
    plt.yticks(ytick_locations[1:],
               [helpers.tick_font(y_i, "%.0f") for y_i in ytick_locations][1:])
    helpers.save_figure("mean-model-tx-rates.pdf", 1, no_legend=True)