import grader import analyzeH5 as an5 import sys #import importlib # importlib.reload(an5) method = sys.argv[1] sub = sys.argv[2] ans = sys.argv[3] N=-1 grader.grader(ans,sub,N,method)
def generate(CONST_reactants, CONST_products, globalDict): ########################################################################### ####### Here is the main method for the best set of parameters search:####### global inCounter, gener, DIST #inCounter is the main file number that added to the file. Gener must be global too so that this function can use its methods before instantiation #2/5/16: for each file, products and reactants contains a list of: filename, basename, template of the file and a dictionary inside reacInputs, prodInputs = [], [] inputProcessor(CONST_reactants, reacInputs, True, {}) #True means it is the first run inputProcessor(CONST_products, prodInputs, True, {}) gener = generatorReac(reacInputs, prodInputs, globalDict) print('\nThis part is about to calculate the best set of parameters') dictsListOfThisGeneration = [globalDict] for generationNum in range(1, maxGenerations): dictListOfNextGeneration = [] #The lower the grade, the better gradesListOfThisGeneration = [] #[(dict,grade),...] print('**************\nThis is generation number: ' + str(generationNum) + '\n**************') #A loop in THIS generation, to measure the dicts: for dict in dictsListOfThisGeneration: reacInputs, prodInputs = [], [] inputProcessor(CONST_reactants, reacInputs, False, dict) #False mean it is not the first run inputProcessor(CONST_products, prodInputs, False, dict) gener = generatorReac(reacInputs, prodInputs, dict) reacOutputs = gener.getReacOutFilenames() prodOutputs = gener.getProdOutFilenames() errorHandler = grader() grade = errorHandler.getDictGrade(reacOutputs, prodOutputs) gradesListOfThisGeneration.append((dict, grade, inCounter)) inCounter += 1 def dictGradeReturner(tuppled): return (tuppled[1]) #Putting the favorable dicts first: gradesListOfThisGeneration = sorted(gradesListOfThisGeneration, key=dictGradeReturner) print('\033[41m' + 'TEST: inCounter:%s GradeList: %s' % (inCounter, [ str(gradd[1]) + ' ' + str(gradd[2]) for gradd in gradesListOfThisGeneration ]) + '\033[0m') stdout.flush() numberOfDictsInNextGen = int( random.gauss(populationSizeOfEachGeneration, 7)) #Edit! 2 is the mean of the gaussian distribution if numberOfDictsInNextGen == 0: numberOfDictsInNextGen = 2 elif numberOfDictsInNextGen < 0: numberOfDictsInNextGen = abs(numberOfDictsInNextGen) + 1 for numm in range(numberOfDictsInNextGen): #Matchmaker chooses the parents randomly from the list of dicts. Priority is higher for preciding dicts: matchmaker = mater(gradesListOfThisGeneration) matchmaker.makeCrossovers(generationNum) matchmaker.applyMutations(generationNum) dictListOfNextGeneration.append(matchmaker.getChild()) dictsListOfThisGeneration = dictListOfNextGeneration #exit() #meanDeltaE=gener.getMeanDeltaE() #meanDeltaE is the float DeltaE that is inside "temp" #print ('\nMeanDeltaE'+str(meanDeltaE)) #temp=(-meanDeltaE/log(0.5)) # Temperature declaration #print (str(temp)+" This is the temp\n") #print ('temp:',temp) print(gener) #Printing the results!!
#get data for line in sys.stdin: markingData += line #merge this into grader j = json.loads(markingData) date = j["markingDate"] ansFiles = j["ansFiles"] ''' studentFiles = j["studentFiles"] assName = j["assName"] ''' #get grades package g = grader(markingData) l = g.getPackage() # Open database connection db = MySQLdb.connect("localhost", "root", "", "cadgrader") # prepare a cursor object using cursor() method cursor = db.cursor() for ass in l: try: # Execute the SQL command sql = """INSERT INTO marking_data(Student_Number, Assignment_Name, Submission_File_Name, Answer_File_Name, Version, Vol_Mark, SA_Mark, CoG_Mark, MoI_Mark, Subjective_Mark, Total_Mark, Flag, Identifier, Marking_Date, Reasons_Flagged) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""" cursor.execute(sql, (ass[0], ass[1], ass[2], ass[3], ass[5], ass[4][0], ass[4][1], ass[4][2], ass[4][3], ass[4][4], 30, ass[6],
print("Content-Type: text/html\n") #print("The foo data is: " + data["foo"].value) #print("<br />") #print("The bar data is: " + str(data["bar"].value)) #j = json.loads(data["bar"].value) print("<br />") if ("bar" in data): j = json.loads(data["bar"].value) if ("lat" in j and "lon" in j): print("The JSON VALUES" + str(j["lat"]) + str(j["lon"])) if ("assName" in j): print("The JSON VALUES" + str(j["assName"]) + str(j["markingDate"]) + str(j["ansFiles"]) + str(j["studentFiles"]) + str(j["mMetrics"]) + str(j["tolerance"])) #print(j["assName"]) g = grader(data["bar"].value) l = g.getPackage() date = str(j["markingDate"]) # Open database connection db = MySQLdb.connect("localhost", "root", "", "cadgrader") # prepare a cursor object using cursor() method cursor = db.cursor() for ass in l: try: # Execute the SQL command sql = """INSERT INTO marking_data(Student_Number, Assignment_Name, Submission_File_Name, Answer_File_Name, Version, Vol_Mark, SA_Mark, CoG_Mark, MoI_Mark, Subjective_Mark, Total_Mark, Flag, Identifier, Marking_Date, Reasons_Flagged) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""" cursor.execute( sql, (ass[0], ass[1], ass[2], ass[3], ass[5], ass[4][0],