Merge branch 'tuner' of ssh://demsky.eecs.uci.edu/home/git/constraint_compiler into...
author <hamed@DESKTOP-SG54322.localdomain> <>
Thu, 6 Dec 2018 23:10:14 +0000 (15:10 -0800)
committer <hamed@DESKTOP-SG54322.localdomain> <>
Thu, 6 Dec 2018 23:10:14 +0000 (15:10 -0800)
src/analyzer/plot.py [new file with mode: 0644]
src/analyzer/tunerloganalyzer.py

diff --git a/src/analyzer/plot.py b/src/analyzer/plot.py
new file mode 100644 (file)
index 0000000..dfd73f0
--- /dev/null
@@ -0,0 +1,42 @@
+import numpy as np
+import matplotlib.pyplot as plt
+IMAGEDIR = "report/pics/"
+
+def generateHistograms(X, header):
+       global IMAGEDIR
+       for i, c in enumerate(X.T):
+               plt.hist(c)
+               plt.savefig(IMAGEDIR + header[i] + "-hist.pdf")
+               plt.clf()
+
+def generateScatterPlot(X, Y, header):
+       global IMAGEDIR
+       for i, feature in enumerate(X.T):
+               values = np.unique(feature)
+               values = np.sort(values)
+               geomean = []
+               for value in values:
+                       a =Y[np.where(feature == value)]
+                       a = np.array(map(lambda x :  x**(1.0/len(a)), a))
+                       geomean.append(a.prod())
+               plt.plot(feature, Y, 'r.')
+               for ii in range(0, len(geomean)-1):
+                       plt.plot(values[ii:ii + 2], geomean[ii:ii + 2], 'bo-')
+               plt.savefig(IMAGEDIR + header[i] + "-scat.pdf")
+               plt.clf()
+
+def plot(data, header):
+       global IMAGEDIR
+       header=header[6:-1]
+       data = np.array(data)
+       X = data[:, 6:-4]
+       X[X==''] = '-1'
+       X = X.astype(np.float)
+       Y = data[:, -2]
+       Y = Y.astype(np.float)
+       generateHistograms(X, header)
+       generateScatterPlot(X, Y, header)
+
+       
+
+
index d4e52cc..8f8f395 100644 (file)
@@ -2,7 +2,7 @@ import re
 import argparse
 import sys
 import os
-
+import plot as pl
 
 class AutoTunerArgParser:
        def __init__(self):
@@ -60,10 +60,13 @@ def printHeader(file):
 def dump(file, row):
        global TUNABLEHEADER
        mystr=""
+       data = []
        for i in range(len(TUNABLEHEADER)):
                mystr += row[TUNABLEHEADER[i]]+ ","
-       print "mystr is:"+ mystr
+               data.append(row[TUNABLEHEADER[i]])
+       print ("mystr is:"+ mystr)
        print >>file, mystr
+       return data
 
 def loadTunerInfo(row, filename):
        with open(filename) as f:
@@ -99,6 +102,7 @@ def analyzeLogs(file):
        argprocess = AutoTunerArgParser()
        printHeader(file)
        rows = []
+       data = []
        for i in range(argprocess.getRunNumber()):
                row = {"DECOMPOSEORDER" : "",
                        "MUSTREACHGLOBAL" : "",
@@ -126,9 +130,9 @@ def analyzeLogs(file):
                loadTunerInfo(row, argprocess.getFolder()+"/tuner"+str(i)+"used")
                loadSolverTime(row, argprocess.getFolder()+"/log"+str(i))
                loadProblemName(row, argprocess.getFolder()+"/problem"+str(i))
-               dump(file, row)
+               data.append(dump(file, row))
                rows.append(row)
-       return rows
+       return rows, data
 
 def tunerNumberAnalysis(file, rows):
        global TUNABLEHEADER
@@ -146,17 +150,21 @@ def tunerNumberAnalysis(file, rows):
                        tunernumber[mystr] += "-" + str(row["TUNERNUMBER"])
 
        problems = set(map(lambda x: x["PROBLEM"], rows))
-       print "Number of repititive tuners"
+       print ("Number of repititive tuners")
        for key in tunercount:
                if tunercount[key] > 1:
-                       print key + "(ids:" + tunernumber[key]  + ") = #" + str(tunercount[key])
-
+                       print (key + "(ids:" + tunernumber[key]  + ") = #" + str(tunercount[key]))
 
+def transformDataset(rows):
+       print(rows)
 def main():
+       global TUNABLEHEADER
        file = open("tuner.csv", "w")
-       rows = analyzeLogs(file)
+       rows, data = analyzeLogs(file)
        tunerNumberAnalysis(file, rows)
        file.close()
+       #transformDataset(data)
+       pl.plot(data, TUNABLEHEADER)
        return
 
 if __name__ == "__main__":