#print AvgRuntimeVND np.savetxt("Runtime_Tabu.txt", np.array(RuntimeTabu)) np.savetxt("Runtime_VND.txt", np.array(RuntimeVND)) #plotting Runtimes of both algorithms on instance#6 plt.plot(range(1, 21), RuntimeTabu[5], 'ro', label='Tabu') plt.plot(range(1, 21), RuntimeVND[5], 'bo', label='VND') plt.xlabel('Iteration') plt.xlim(1, 20) plt.ylabel('Runtime (s)') plt.ylim(0, 40) plt.title('Runtimes Comparison of Tabu Search and VND') plt.legend() plt.show() #Generating Scatter Plot #help(plot_scatter.plot_scatter_plot) plot_scatter.plot_scatter_plot(np.array(AvgRuntimeTabu), np.array(AvgRuntimeVND), labels=["Tabu", "VND"], title='Tabu VS VND', save='scatter.png') plt.show() #Generating Boxplot #help(plt.boxplot) plt.figure() plt.boxplot((RuntimeTabu, RuntimeVND)) plt.show()
import matplotlib.pyplot as plt import numpy as np from plot_scatter import plot_scatter_plot from pylab import * data_sa = [.1246404793, .2860261318, .0802291212, .0753011860, .0662239493, 3.0800689215, 1.5275161933, .7680770744, .1372658342, 1.6589732123, .6470984249, 1.5993877497, 9.9692374581, 30.0060543784] data_hc = [.0659917897, .0711625110, .0735541013, .0686513972, .0650763787, .4528222578, .1932201330, .1268824969, .1493043956, 1.4135952366, .3481941039, .5358545771, 13.2071397053, 30.0059365538] labels = ['Simulated annealing', 'Hill Climbing'] plt.boxplot([data_sa, data_hc]) plt.xticks([1, 2], labels) plt.ylabel("Runtime in sec") plt.yscale('log') plt.grid() #plt.show() savefig('box_plot.png') plot_scatter_plot(np.array(data_sa), np.array(data_hc), labels, save="scatter_plot.png", max_val=30)
satisfiable = False print("\nRuntimes, each columns show timetaken on one of iterations and row shows datasets.\n" "Eg. row 0 column 3 show time taken to solve first dataset on 4th iteration\n") print(time_matrix1) print(time_matrix2) tm1_avg = np.mean(time_matrix1, axis=1) tm2_avg = np.mean(time_matrix2, axis=1) print(tm1_avg) print(tm2_avg) plt.hist(time_matrix1[0], bins=40, normed=True, cumulative=True, histtype='step', color='b', label='WalkSAT') plt.hist(time_matrix2[0], bins=40, normed=True, cumulative=True, histtype='step', color='r', label='TabuSearch') plt.title("WalkSat vs TabuSearch") plt.xlabel("TimeTaken in Secs") plt.ylabel("Probability") plt.legend() plt.savefig('sls_runtime.png') ps.plot_scatter_plot(tm1_avg, tm2_avg,labels=["WalkSat", "Tabu"], title="WalkSat vs TabuSearch", save="ps.png", debug=False, min_val=0, max_val=0.6, grey_factor=1, linefactors=None, user_fontsize=20, dpi=200) data = [tm1_avg, tm2_avg] fig = plt.figure() ax = fig.add_subplot(111) plt.ylabel("Runtime Ratio") ax.boxplot(data) ax.set_xticklabels(["WalkSat", "Tabu"]) plt.savefig("boxplot.png")