-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
294 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import matplotlib.pyplot as pyplot | ||
import matplotlib.ticker as mtick | ||
|
||
import sys | ||
|
||
xAxis = "Number of States" | ||
yAxis = "Average Amount of Minimization Completed" | ||
title = "Comparison of Incremental Minimization Rates" | ||
|
||
testsfile = sys.argv[1] | ||
xIndex = int(sys.argv[2]) | ||
percent1_index = int(sys.argv[3]) | ||
percent2_index = int(sys.argv[4]) | ||
increment = int(sys.argv[5]) | ||
cutoff = int(sys.argv[6]) | ||
|
||
def toNum(s): | ||
if s.isdigit(): | ||
return int(s) | ||
else: | ||
return float(s) | ||
|
||
def generate_data(data, increment, cutoff): | ||
def format_tick(start, end): | ||
return "{} - {}".format(start, end) | ||
|
||
def get_tick_from_point(point): | ||
mod = int(point) % increment | ||
start = point - mod | ||
return format_tick(start, start+increment-1) | ||
|
||
data.sort(key = lambda r: r[xIndex]) | ||
ticks = [] | ||
tick_map = {} | ||
p1_data = [] | ||
p2_data = [] | ||
for i in range(0, cutoff, increment): | ||
tick_start = i | ||
tick_end = (i + increment) - 1 | ||
ticks.append(format_tick(tick_start, tick_end)) | ||
cur_index = 0 | ||
count = 1 | ||
for row in range(0, len(data)): | ||
x = data[row][xIndex] | ||
if x >= cutoff: | ||
break | ||
p1 = data[row][percent1_index] | ||
p2 = data[row][percent2_index] | ||
tick = ticks[cur_index] | ||
actual_tick = get_tick_from_point(x) | ||
while(tick != actual_tick): | ||
cur_index += 1 | ||
if len(p1_data) < cur_index: | ||
raise NotImplementedError() #TODO: implement if no data in range | ||
tick = ticks[cur_index] | ||
if len(p1_data) == cur_index: | ||
count = 1 | ||
p1_data.append(p1) | ||
p2_data.append(p2) | ||
else: | ||
count += 1 | ||
p1_data[cur_index] += (p1 - p1_data[cur_index])/float(count) | ||
p2_data[cur_index] += (p2 - p2_data[cur_index])/float(count) | ||
print(ticks) | ||
print(len(ticks)) | ||
print(len(p1_data)) | ||
for i in range(0,len(ticks)): | ||
print "{} : {} : {}".format(ticks[i], str(p1_data[i]), str(p2_data[i])) | ||
assert(len(ticks) == len(p1_data)) | ||
assert(len(p1_data) == len(p2_data)) | ||
return ticks, p1_data, p2_data | ||
|
||
with open(testsfile, "r") as f: | ||
fStrings = f.read().split('\n') | ||
|
||
title_row = fStrings[0].split(',') | ||
fData = [[toNum(datum) for datum in row.split(',') if datum] | ||
for row in fStrings[1:] if row] | ||
|
||
ticks, p1_data, p2_data = generate_data(fData, increment, cutoff) | ||
|
||
p1_data = [p1*100 for p1 in p1_data] | ||
p2_data = [p2*100 for p2 in p2_data] | ||
fig, ax = pyplot.subplots(1,1) | ||
percent_format = mtick.FormatStrFormatter("%.0f%%") | ||
ax.bar([a - 0.15 for a in range(0,len(p1_data))], p1_data, width=0.30, label="Symbolic Incremental") | ||
ax.bar([b + 0.15 for b in range(0,len(p2_data))], p2_data, width=0.30, label="'Naive' Incremental") | ||
pyplot.xticks(range(0, len(ticks)), ticks, fontsize=6) | ||
ax.yaxis.set_major_formatter(percent_format) | ||
pyplot.xlabel(xAxis) | ||
pyplot.ylabel(yAxis) | ||
pyplot.title(title) | ||
pyplot.legend(loc=0) | ||
pyplot.savefig("budget_graph.png", dpi=600) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import sys | ||
|
||
file1 = sys.argv[1] | ||
file2 = sys.argv[2] | ||
base_index = int(sys.argv[3]) | ||
comp_index = int(sys.argv[4]) | ||
|
||
def toNum(s): | ||
if s.isdigit(): | ||
return int(s) | ||
else: | ||
return float(s) | ||
|
||
with open(file1, "r") as f: | ||
f1 = f.read().split("\n") | ||
|
||
with open(file2, "r") as f: | ||
f2 = f.read().split("\n") | ||
|
||
title_row = f1[0].split(',') | ||
#assert(all(title1 == title2 for title1, title2 in zip(title_row, f2[0].split(',')))) | ||
f1Data = [[toNum(datum) for datum in row.split(',') if datum] | ||
for row in f1[1:] if row] | ||
f2Data = [[toNum(datum) for datum in row.split(',') if datum] | ||
for row in f2[1:] if row] | ||
|
||
good = 0 | ||
bad = 0 | ||
for row in f1Data: | ||
if row[0] > 50 and row[1] < 150 and row[0] == row[1]: | ||
if row[5] <= row[6]: | ||
good += 1 | ||
else: | ||
bad +=1 | ||
print(good) | ||
print(bad) | ||
|
||
|
||
f1Average = 0 | ||
f2Average = 0 | ||
f1Min = max([row[base_index] for row in f1Data]) | ||
print("adsadad") | ||
f1Max = 0 | ||
negs = [] | ||
count = 0.0 | ||
for row in range(0,min(len(f1Data),len(f2Data))): | ||
if f1Data[row][0] < 50: | ||
continue | ||
count += 1 | ||
if f1Data[row][:4] != f2Data[row][:4]: | ||
if len(f1Data) > len(f2Data): | ||
f1Data.pop(row) | ||
elif len(f1Data) < len(f2Data): | ||
f2Data.pop(row) | ||
else: | ||
raise Exception("Data tables not expressing same data") | ||
|
||
f1Comp = f1Data[row][base_index] - f1Data[row][comp_index] | ||
f2Comp = f2Data[row][base_index] - f2Data[row][comp_index] | ||
if f1Comp < f1Min: | ||
f1Min = f1Comp | ||
if f1Comp > f1Max: | ||
f1Max = f1Comp | ||
if f1Comp <= 0: | ||
negs.append(f1Data[row]) | ||
if count == 0: | ||
f1Average = f1Comp | ||
f2Average = f2Comp | ||
else: | ||
count += 1.0 | ||
f1Average += (f1Comp - f1Average)/count | ||
f2Average += (f2Comp - f2Average)/count | ||
|
||
for n in negs: | ||
print n | ||
print('avg') | ||
print(f1Average) | ||
print('min') | ||
print(f1Min) | ||
print('max') | ||
print(f1Max) | ||
print(count) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import matplotlib.pyplot as pyplot | ||
import sys | ||
|
||
xAxis = "Number of States" | ||
yAxis = "Average Minimization Time (ms)" | ||
title = "Comparison of SFA Minimization Algorithms" | ||
|
||
testsfile = sys.argv[1] | ||
xIndex = int(sys.argv[2]) | ||
graph_indices = [int(i) for i in sys.argv[3:-1]] | ||
cutoff = int(sys.argv[-1]) | ||
|
||
def toNum(s): | ||
if s.isdigit(): | ||
return int(s) | ||
else: | ||
return float(s) | ||
|
||
def mergeData(data, index): | ||
data.sort(key = lambda x: x[index]) | ||
new_data = [] | ||
count = 1 | ||
for row in data: | ||
if new_data and new_data[-1][index] == row[index]: | ||
old_row = new_data[-1] | ||
count += 1 | ||
for i in range(0, len(old_row)): | ||
if i != index: | ||
old_row[i] += (row[i] - old_row[i])/float(count) #running average | ||
else: | ||
count = 1 | ||
new_data.append(row) | ||
return new_data | ||
|
||
with open(testsfile, "r") as f: | ||
fStrings = f.read().split('\n') | ||
|
||
title_row = fStrings[0].split(',') | ||
fData = [[toNum(datum) for datum in row.split(',') if datum] | ||
for row in fStrings[1:] if row] | ||
|
||
average_mins = [] | ||
for row in fData: | ||
if row[0] <= 400 and row[0] != row[1]: | ||
average_mins.append(row[1]/float(row[0])) | ||
print("average") | ||
print(sum(average_mins)/len(average_mins)) | ||
|
||
fData = mergeData(fData, xIndex) | ||
|
||
xData = [row[xIndex] for row in fData if row[xIndex] <= cutoff] | ||
for i in graph_indices: | ||
graphData = [row[i] for row in fData[:len(xData)]] | ||
pyplot.plot(xData, graphData, label=title_row[i], linewidth=1.0) | ||
pyplot.yscale("log") | ||
pyplot.legend(loc=0) | ||
pyplot.xlabel(xAxis) | ||
pyplot.ylabel(yAxis) | ||
pyplot.title(title) | ||
pyplot.savefig("graph.png", dpi=600) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import numpy | ||
import matplotlib.pyplot as pyplot | ||
import matplotlib.colors as colors | ||
|
||
import sys | ||
|
||
xAxis = "Percentage of Automata Minimized" | ||
yAxis = "Number of States" | ||
title = "Progress of Naive Incremental Minimization" | ||
|
||
testsfile = sys.argv[1] | ||
|
||
def toNum(s): | ||
if s.isdigit(): | ||
return int(s) | ||
else: | ||
return float(s) | ||
|
||
with open(testsfile, "r") as f: | ||
fStrings = f.read().split("\n") | ||
|
||
title_row = fStrings[0].split(',') | ||
x = [toNum(s) for s in title_row[1:-1] if s] | ||
|
||
y = [] | ||
z = [] | ||
index = 0 | ||
dataDict = {} | ||
for row in fStrings[1:]: | ||
if row: | ||
row = row.split(",") | ||
print(row) | ||
states = toNum(row[0]) | ||
for percent in row[1:-1]: | ||
z.append(toNum(percent)) | ||
y.append(states) | ||
|
||
|
||
x = abs(numpy.unique(x)) | ||
y = abs(numpy.unique(y)) | ||
X,Y = numpy.meshgrid(x,y) | ||
z = abs(numpy.array(z)) | ||
Z = z.reshape(len(y),len(x)) | ||
print(y) | ||
print(x) | ||
print(Z.min()) | ||
pyplot.pcolormesh(X,Y,Z) | ||
bar = pyplot.colorbar() | ||
bar.set_label("Percentage of Time Passed") | ||
|
||
pyplot.title(title) | ||
pyplot.ylabel(yAxis) | ||
pyplot.xlabel(xAxis) | ||
pyplot.xticks(range(0,101,10),["{}%".format(str(int(p)*10)) for p in title_row[1:-1]]) | ||
pyplot.savefig("heatmap.png", dpi=600) |