get_percent_different(eager_xstar_totals_lst, xstar_totals_lst), 2,
    "Opt. Solution Improvement")


def to_percent(y, position):
    # Ignore the passed in position. This has the effect of scaling the default
    # tick locations.
    s = str(100 * y)

    # The percent symbol needs escaping in latex
    if matplotlib.rcParams['text.usetex'] is True:
        return s + r'$\%$'
    else:
        return s + '%'


plt.ylim(bottom=0)

formatter = FuncFormatter(to_percent)

# Set the formatter
plt.gca().yaxis.set_major_formatter(formatter)

plt.xticks(kNumRobotsList)
plt.xlabel("Agent Count")
plt.ylabel("Lazy vs Eager X* Mean Runtime Improvement")
#plt.yscale('log')
plot_helper.legend(loc=3)
plot_helper.save_fig("xstar_eager_vs_lazy")
plt.show()
Exemplo n.º 2
0
    save_data_to_file(
        "xstar_totals_lst_ci_{}_{}e{}.txt".format(experiment_name,
                                                  scenario_name, inflation),
        xstar_totals_lst)
    save_data_to_file(
        "mstar_totals_lst_ci_{}_{}e{}.txt".format(experiment_name,
                                                  scenario_name, inflation),
        mstar_totals_lst)
else:
    print("===Using saved trials")
    xstar_firsts_lst = read_saved_data_from_file(
        "xstar_firsts_lst_ci_{}_{}e{}.txt".format(experiment_name,
                                                  scenario_name, inflation))
    xstar_totals_lst = read_saved_data_from_file(
        "xstar_totals_lst_ci_{}_{}e{}.txt".format(experiment_name,
                                                  scenario_name, inflation))
    mstar_totals_lst = read_saved_data_from_file(
        "mstar_totals_lst_ci_{}_{}e{}.txt".format(experiment_name,
                                                  scenario_name, inflation))

plot_helper.plot_ci(kNumRobotsList, xstar_firsts_lst, 3, "X* First Solution")
plot_helper.plot_ci(kNumRobotsList, xstar_totals_lst, 3, "X* Opt. Solution")
plot_helper.plot_ci(kNumRobotsList, mstar_totals_lst, 3, "M* Solution")
plt.xticks(kNumRobotsList)
plt.xlabel("Agent Count")
plt.ylabel("Runtime (ms)")
plt.yscale('log')
plot_helper.legend(loc=2)
plot_helper.save_fig("xstar_vs_mstar_agents_vs_runtime")
plt.show()
xstar_totals_lst = []

if kRunNewTrials:
    print("===Running new trials")
    for inflation in kInflationValues:
        seed = int(inflation * 100 * 53 + 17)
        print("Inflation:", inflation)
        print("X*")
        xstar_first_exps, xstar_total_exps = run_xstar(num_robots, inflation)
        xstar_firsts_lst.append(xstar_first_exps)
        xstar_totals_lst.append(xstar_total_exps)

    save_data_to_file("xstar_firsts_lst_{}_{}e{}.txt".format(experiment_name, scenario_name, inflation), xstar_firsts_lst)
    save_data_to_file("xstar_totals_lst_{}_{}e{}.txt".format(experiment_name, scenario_name, inflation), xstar_totals_lst)
else:
    inflation = kInflationValues[-1]
    print("===Using saved trials")
    xstar_firsts_lst = read_saved_data_from_file("xstar_firsts_lst_{}_{}e{}.txt".format(experiment_name, scenario_name, kInflationValues[-1]))
    xstar_totals_lst = read_saved_data_from_file("xstar_totals_lst_{}_{}e{}.txt".format(experiment_name, scenario_name, kInflationValues[-1]))

plot_helper.plot(kInflationValues, xstar_firsts_lst, 2, "X* First Solution")
plot_helper.plot(kInflationValues, xstar_totals_lst, 2, "X* Full Solution")
plt.ylim(bottom=0)
plt.xticks(kInflationValues)
plt.xlabel("Heuristic Inflation")
plt.ylabel("State Expansions")
#plt.yscale('log')
plot_helper.legend(loc=1)
plot_helper.save_fig("xstar_heuristic_inflation")
plt.show()
    save_data_to_file(
        "xstar_totals_lst_ci_{}_{}e{}.txt".format(experiment_name,
                                                  scenario_name, inflation),
        xstar_totals_lst)
    save_data_to_file(
        "mstar_totals_lst_ci_{}_{}e{}.txt".format(experiment_name,
                                                  scenario_name, inflation),
        mstar_totals_lst)
else:
    print("===Using saved trials")
    xstar_firsts_lst = read_saved_data_from_file(
        "xstar_firsts_lst_ci_{}_{}e{}.txt".format(experiment_name,
                                                  scenario_name, inflation))
    xstar_totals_lst = read_saved_data_from_file(
        "xstar_totals_lst_ci_{}_{}e{}.txt".format(experiment_name,
                                                  scenario_name, inflation))
    mstar_totals_lst = read_saved_data_from_file(
        "mstar_totals_lst_ci_{}_{}e{}.txt".format(experiment_name,
                                                  scenario_name, inflation))

plot_helper.plot_ci(kNumRobotsList, xstar_totals_lst, 3, "X* Opt. Solution")
plot_helper.plot_ci(kNumRobotsList, xstar_firsts_lst, 3, "X* First Solution")
plot_helper.plot_ci(kNumRobotsList, mstar_totals_lst, 3, "M* Solution")
plt.xticks(kNumRobotsList)
plt.xlabel("Agent Count")
plt.ylabel("Runtime (ms)")
plt.yscale('log')
plot_helper.legend(loc=2)
plot_helper.save_fig("xstar_vs_mstar_agents_vs_runtime_random_field")
plt.show()
Exemplo n.º 5
0
xstar_firsts_lst = []
xstar_totals_lst = []

if kRunNewTrials:
    print("===Running new trials")
    for num_robots in kAgentCount:
        seed = int(num_robots * 100 * 53 + 17)
        print("Agent Count:", num_robots)
        print("X*")
        xstar_first_exps, xstar_total_exps = run_xstar(num_robots)
        xstar_firsts_lst.append(xstar_first_exps)
        xstar_totals_lst.append(xstar_total_exps)

    save_data_to_file("xstar_firsts_lst_{}_{}e{}.txt".format(experiment_name, scenario_name, inflation), xstar_firsts_lst)
    save_data_to_file("xstar_totals_lst_{}_{}e{}.txt".format(experiment_name, scenario_name, inflation), xstar_totals_lst)
else:
    print("===Using saved trials")
    xstar_firsts_lst = read_saved_data_from_file("xstar_firsts_lst_{}_{}e{}.txt".format(experiment_name, scenario_name, inflation))
    xstar_totals_lst = read_saved_data_from_file("xstar_totals_lst_{}_{}e{}.txt".format(experiment_name, scenario_name, inflation))

plot_helper.plot(kAgentCount, xstar_firsts_lst, 2, "X* First Solution")
plot_helper.plot(kAgentCount, xstar_totals_lst, 2, "X* Opt. Solution")
plt.ylim(bottom=5)
plt.xticks(kAgentCount)
plt.xlabel("Agent Count")
plt.ylabel("Number of Expansions")
plt.yscale('log')
plot_helper.legend(loc=2)
plot_helper.save_fig("xstar_agent_sweep")
plt.show()
xstar_firsts_lst = []
xstar_totals_lst = []

if kRunNewTrials:
    print("===Running new trials")
    for radius in kRadiusValues:
        seed = int(radius * 100 * 53 + 17)
        print("radius:", radius)
        print("X*")
        xstar_first_exps, xstar_total_exps = run_xstar(num_robots, radius)
        xstar_firsts_lst.append(xstar_first_exps)
        xstar_totals_lst.append(xstar_total_exps)

    save_data_to_file("xstar_firsts_lst_{}_{}e{}.txt".format(experiment_name, scenario_name, inflation), xstar_firsts_lst)
    save_data_to_file("xstar_totals_lst_{}_{}e{}.txt".format(experiment_name, scenario_name, inflation), xstar_totals_lst)
else:
    print("===Using saved trials")
    xstar_firsts_lst = read_saved_data_from_file("xstar_firsts_lst_{}_{}e{}.txt".format(experiment_name, scenario_name, inflation))
    xstar_totals_lst = read_saved_data_from_file("xstar_totals_lst_{}_{}e{}.txt".format(experiment_name, scenario_name, inflation))

plot_helper.plot(kRadiusValues, xstar_firsts_lst, 2, "X* First Solution")
plot_helper.plot(kRadiusValues, xstar_totals_lst, 2, "X* Opt. Solution")
plt.ylim(bottom=0)
plt.xticks(kRadiusValues)
plt.xlabel("Radius Values")
plt.ylabel("State Expansions")
#plt.yscale('log')
plot_helper.legend(loc=4)
plot_helper.save_fig("xstar_radius_sweep")
plt.show()
plot_helper.plot(xs, final_percentage_iterations, 2, None)


def to_percent(y, position):
    # Ignore the passed in position. This has the effect of scaling the default
    # tick locations.
    s = str(100 * y)

    # The percent symbol needs escaping in latex
    if matplotlib.rcParams['text.usetex'] is True:
        return s + r'$\%$'
    else:
        return s + '%'


plt.ylim(bottom=0)

formatter = FuncFormatter(to_percent)

# Set the formatter
plt.gca().yaxis.set_major_formatter(formatter)

#plot_helper.plot(kAgentCount, xstar_totals_lst, 2, "X* Opt. Solution")
plt.xticks(xs)
plt.xlabel("Iteration Count")
plt.ylabel("Percentage of Total Computation Time")
#plt.yscale('log')
#plot_helper.legend(loc=2)
plot_helper.save_fig("xstar_computation_time_vs_iteration")
plt.show()