Resolving conflicts
[satune.git] / src / analyzer / tunerloganalyzer.py
index 8f8f395..d47df1f 100644 (file)
@@ -17,6 +17,8 @@ class AutoTunerArgParser:
        def getRunNumber(self):
                return self.args.number[0]
 
        def getRunNumber(self):
                return self.args.number[0]
 
+PROBLEMS = []
+
 TUNABLEHEADER = ["DECOMPOSEORDER", "MUSTREACHGLOBAL", "MUSTREACHLOCAL", "MUSTREACHPRUNE", "OPTIMIZEORDERSTRUCTURE",
                 "ORDERINTEGERENCODING", "PREPROCESS", "NODEENCODING", "EDGEENCODING", "MUSTEDGEPRUNE", "ELEMENTOPT",
                 "ENCODINGGRAPHOPT", "ELEMENTOPTSETS", "PROXYVARIABLE", "MUSTVALUE", "NAIVEENCODER", "VARIABLEORDER",
 TUNABLEHEADER = ["DECOMPOSEORDER", "MUSTREACHGLOBAL", "MUSTREACHLOCAL", "MUSTREACHPRUNE", "OPTIMIZEORDERSTRUCTURE",
                 "ORDERINTEGERENCODING", "PREPROCESS", "NODEENCODING", "EDGEENCODING", "MUSTEDGEPRUNE", "ELEMENTOPT",
                 "ENCODINGGRAPHOPT", "ELEMENTOPTSETS", "PROXYVARIABLE", "MUSTVALUE", "NAIVEENCODER", "VARIABLEORDER",
@@ -92,8 +94,16 @@ def loadSolverTime(row, filename):
        row["EXECTIME"] = configs["EXECTIME"]
 
 def loadProblemName(row,filename):
        row["EXECTIME"] = configs["EXECTIME"]
 
 def loadProblemName(row,filename):
+       global PROBLEMS
        with open(filename) as f:
        with open(filename) as f:
-               row["PROBLEM"] = f.readline().replace("\n","")
+               problem = f.readline().replace("\n","")
+               probNumber = int(f.readline())
+               if probNumber >= len(PROBLEMS):
+                       PROBLEMS.insert(probNumber,problem)
+               elif PROBLEMS[probNumber] != problem:
+                       PROBLEMS[probNumber] = problem
+               row["PROBLEM"] = problem
+
 def loadTunerNumber(row, filename):
        with open(filename) as f:
                row["TUNERNUMBER"] = f.readline().replace("\n","")
 def loadTunerNumber(row, filename):
        with open(filename) as f:
                row["TUNERNUMBER"] = f.readline().replace("\n","")
@@ -134,14 +144,18 @@ def analyzeLogs(file):
                rows.append(row)
        return rows, data
 
                rows.append(row)
        return rows, data
 
-def tunerNumberAnalysis(file, rows):
+def tunerCountAnalysis(file, rows):
        global TUNABLEHEADER
        global TUNABLEHEADER
+       global PROBLEMS
        tunercount = {}
        tunernumber = {}
        for row in rows:
                mystr=""
                for i in range(18):
        tunercount = {}
        tunernumber = {}
        for row in rows:
                mystr=""
                for i in range(18):
-                       mystr+=row[TUNABLEHEADER[i]]
+                       if not row[TUNABLEHEADER[i]]:
+                               mystr += "."
+                       else:
+                               mystr+=row[TUNABLEHEADER[i]]
                if mystr not in tunercount:
                        tunercount.update({mystr : 1})
                        tunernumber.update({mystr : str(row["TUNERNUMBER"])})
                if mystr not in tunercount:
                        tunercount.update({mystr : 1})
                        tunernumber.update({mystr : str(row["TUNERNUMBER"])})
@@ -153,19 +167,35 @@ def tunerNumberAnalysis(file, rows):
        print ("Number of repititive tuners")
        for key in tunercount:
                if tunercount[key] > 1:
        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 combineRowForEachTuner(rows):
+       global PROBLEMS
+       newRows = []
+       combined = None
+       for row in rows:
+               if row["PROBLEM"] == PROBLEMS[0]:
+                       combined = row
+               for key in row:
+                       if row[key]:
+                               combined[key] = row[key]
+               if row["PROBLEM"] == PROBLEMS[len(PROBLEMS)-1]:
+                       newRows.append(combined)
+       return newRows
 
 def transformDataset(rows):
        print(rows)
 
 def transformDataset(rows):
        print(rows)
+
+
 def main():
        global TUNABLEHEADER
        file = open("tuner.csv", "w")
        rows, data = analyzeLogs(file)
 def main():
        global TUNABLEHEADER
        file = open("tuner.csv", "w")
        rows, data = analyzeLogs(file)
-       tunerNumberAnalysis(file, rows)
+       tunerCountAnalysis(file, combineRowForEachTuner(rows) )
        file.close()
        #transformDataset(data)
        pl.plot(data, TUNABLEHEADER)
        file.close()
        #transformDataset(data)
        pl.plot(data, TUNABLEHEADER)
-       return
+
 
 if __name__ == "__main__":
        main()
 
 if __name__ == "__main__":
        main()