def run_tests(mes_functions, number_of_rooms, room_limit, seed = 0): ''' Run tests and save it to files @param mes_functions: [mesure function1,...] when measure function1 is (number_of_rooms,room_limit) => db of results all db's saved in working directory with names {start_time}{test functoin name} ''' result_folder = "results" base = os.path.join(os.getcwd(),result_folder) if not os.path.exists(base): os.mkdir(base) print "Start Running" print "=============" for mf in mes_functions: test_filename = strftime("%Y-%m-%d_at_%H-%M_") + mf.__name__ + str(seed) + ".pck" path= os.path.join(base, test_filename ) dbs = mf(number_of_rooms, room_limit, seed) print "saved:", path psave(dbs,path) print "===== DONE ======"
def run_tests(mes_functions, number_of_rooms, room_limit, seed=0): ''' Run tests and save it to files @param mes_functions: [mesure function1,...] when measure function1 is (number_of_rooms,room_limit) => db of results all db's saved in working directory with names {start_time}{test functoin name} ''' result_folder = "results" base = os.path.join(os.getcwd(), result_folder) if not os.path.exists(base): os.mkdir(base) print "Start Running" print "=============" for mf in mes_functions: test_filename = strftime("%Y-%m-%d_at_%H-%M_") + mf.__name__ + str( seed) + ".pck" path = os.path.join(base, test_filename) dbs = mf(number_of_rooms, room_limit, seed) print "saved:", path psave(dbs, path) print "===== DONE ======"
def test_mesure_soleves2(rooms,width_domain): max_depth = 40 def BeamSolve(beam_width): algorithm = beam_search.BeamSearch(beam_width, max_depth) heuristic = heuristics.PowerHeuristic() agent = measure_agent.MeasureAgent(algorithm, heuristic) def solution_len(*args, **kwrds): solution = agent.solve(*args, **kwrds) if solution is None: solution = [] return [len(solution)] return solution_len x = width_domain solve_impl_list = [ BeamSolve(i) for i in x ] header = ['No','RoomId'] + ['Beam%s' % i for i in x] #rooms = dict(all_static_rooms.items()[:7]) #rooms = all_static_rooms print print results = mes2.compare_measured_soleves(solve_impl_list, rooms, 1000) #named_results = [[name] + list(r) for r , name in zip(results,solve_impl_names)] time_table = [range(len(results[0][0]))] + results[1] t = xplot.table_to_csv2(time_table,header=header) psave(t, r'C:\Users\inesmeya\Desktop\source\din\t.pck') #y = [ for coll in time_table[2:] ] y = [ reduce(lambda x,y: x + int(y != 0),coll,0) for coll in time_table[2:]] print print "GGGG y=", y y = [ 100.0 * float(i) / float(len(rooms)) for i in y ] print print "GGGG y=", y dir = r'C:\Users\inesmeya\Desktop\source\din' html_name = dir + '\\' + 'index.html' img_name = dir + '\\' + 'img.png' xplot.html.add_header("Picture Demo") #pylab.axvspan(0, 400, 0, 100) xplot.plot_result((('width', x),('solved', y)), title='Picture title', label='label', filename=img_name) xplot.html.add_img(img_name) xplot.html.add_header("Table demo") xplot.html.add_paragraph("Tons of text about this particular table") xplot.html.add_table(time_table, 'The Title of table', header=header) xplot.html.save(html_name) #print d print t
def save_roomset(name, count, seed, rs): path = roomset_filepath(name, count, seed) psave(rs, path) print "Room set saved:", path
def test_mesure_soleves2(rooms, width_domain): max_depth = 40 def BeamSolve(beam_width): algorithm = beam_search.BeamSearch(beam_width, max_depth) heuristic = heuristics.PowerHeuristic() agent = measure_agent.MeasureAgent(algorithm, heuristic) def solution_len(*args, **kwrds): solution = agent.solve(*args, **kwrds) if solution is None: solution = [] return [len(solution)] return solution_len x = width_domain solve_impl_list = [BeamSolve(i) for i in x] header = ['No', 'RoomId'] + ['Beam%s' % i for i in x] #rooms = dict(all_static_rooms.items()[:7]) #rooms = all_static_rooms print print results = mes2.compare_measured_soleves(solve_impl_list, rooms, 1000) #named_results = [[name] + list(r) for r , name in zip(results,solve_impl_names)] time_table = [range(len(results[0][0]))] + results[1] t = xplot.table_to_csv2(time_table, header=header) psave(t, r'C:\Users\inesmeya\Desktop\source\din\t.pck') #y = [ for coll in time_table[2:] ] y = [ reduce(lambda x, y: x + int(y != 0), coll, 0) for coll in time_table[2:] ] print print "GGGG y=", y y = [100.0 * float(i) / float(len(rooms)) for i in y] print print "GGGG y=", y dir = r'C:\Users\inesmeya\Desktop\source\din' html_name = dir + '\\' + 'index.html' img_name = dir + '\\' + 'img.png' xplot.html.add_header("Picture Demo") #pylab.axvspan(0, 400, 0, 100) xplot.plot_result((('width', x), ('solved', y)), title='Picture title', label='label', filename=img_name) xplot.html.add_img(img_name) xplot.html.add_header("Table demo") xplot.html.add_paragraph("Tons of text about this particular table") xplot.html.add_table(time_table, 'The Title of table', header=header) xplot.html.save(html_name) #print d print t
def save_roomset(name, count, seed,rs): path = roomset_filepath(name, count, seed) psave(rs,path) print "Room set saved:", path