Resolving conflicts
authorHamed Gorjiara <hgorjiar@uci.edu>
Fri, 14 Dec 2018 23:48:48 +0000 (15:48 -0800)
committerHamed Gorjiara <hgorjiar@uci.edu>
Fri, 14 Dec 2018 23:48:48 +0000 (15:48 -0800)
1  2 
src/analyzer/tunerloganalyzer.py

@@@ -2,7 -2,7 +2,7 @@@ import r
  import argparse
  import sys
  import os
+ import plot as pl
  
  class AutoTunerArgParser:
        def __init__(self):
@@@ -17,8 -17,6 +17,8 @@@
        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",
@@@ -62,10 -60,13 +62,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:
@@@ -91,16 -92,8 +94,16 @@@ def loadSolverTime(row, filename)
        row["EXECTIME"] = configs["EXECTIME"]
  
  def loadProblemName(row,filename):
 +      global PROBLEMS
        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","")
@@@ -109,6 -102,7 +112,7 @@@ def analyzeLogs(file)
        argprocess = AutoTunerArgParser()
        printHeader(file)
        rows = []
+       data = []
        for i in range(argprocess.getRunNumber()):
                row = {"DECOMPOSEORDER" : "",
                        "MUSTREACHGLOBAL" : "",
                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):
 +def tunerCountAnalysis(file, rows):
        global TUNABLEHEADER
 +      global PROBLEMS
        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"])})
                        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 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 main():
+       global TUNABLEHEADER
        file = open("tuner.csv", "w")
-       rows = analyzeLogs(file)
+       rows, data = analyzeLogs(file)
 -      tunerNumberAnalysis(file, rows)
 +      tunerCountAnalysis(file, combineRowForEachTuner(rows) )
        file.close()
-       return
+       #transformDataset(data)
+       pl.plot(data, TUNABLEHEADER)
 -      return
++
  
  if __name__ == "__main__":
        main()