import readMap import dfs import analyse import sim_an_search map = readMap.read_empty_map('NewChina.txt') signal_cost = analyse.get_cost_scheme(4) signals = ['zA', 'zB', 'zC', 'zD', 'zE', 'zF', 'zG'] dfs.dfs(map, signals) sim_an_search.sim_an(map, signal_cost, signals, begin_temp=10) analyse.print_costs(map, signal_cost) print(analyse.analyse_conflicts(map)) print(analyse.analyse_adjacent_states(map))
signals = ['zA', 'zB', 'zC', 'zD', 'zE', 'zF', 'zG'] cost1 = {'zA': 12, 'zB': 26, 'zC': 27, 'zD': 30, 'zE': 37, 'zF': 39, 'zG': 41} cost2 = {'zA': 19, 'zB': 20, 'zC': 21, 'zD': 23, 'zE': 36, 'zF': 37, 'zG': 38} cost3 = {'zA': 16, 'zB': 17, 'zC': 31, 'zD': 33, 'zE': 36, 'zF': 56, 'zG': 57} cost4 = {'zA': 3, 'zB': 34, 'zC': 36, 'zD': 39, 'zE': 41, 'zF': 43, 'zG': 58} costlist = [cost1, cost2, cost3, cost4] begintemp = {12: 8, 19: 4, 16: 8, 3: 14} citer = 1 endtemp = [0.001, 0.01, 0.1, 0.25, 0.5, 0.75, 1, 1.5, 2] with open("endtempstats.txt", 'a') as text: for c in costlist: for e in endtemp: m = 0 print('end: ' + str(e)) text.write(str(citer) + ',') text.write(str(begintemp[c['zA']]) + ',') text.write(str(e) + ',') for y in range(20): map = readMap.read_complete_map('Russiadfs.txt') map = sim_an_search.sim_an(map, c, signals, 200000, begintemp[c['zA']], e) freq = analyse.analyse_signal_frequentie(map) costs = analyse.get_cost(freq, c) text.write(str(costs) + ', ') m += costs print('mean: ' + str(m / 20)) text.write('\n') citer += 1
import analyse import readMap import sim_an_search s = '5' signal_costs = analyse.get_cost_scheme(int(s)) signals = list(signal_costs.keys()) for x in range(23, 31): costs_list = [] for y in range(20): map = readMap.read_complete_map('Russiadfs.txt') sim_an_search.sim_an(map, signal_costs, signals, begin_temp=x, end_temp=0.5) freq = analyse.analyse_signal_frequentie(map) costs = analyse.get_cost(freq, signal_costs) costs_list.append(costs) print(costs) print('number = ' + str(x)) with open('costs_stats_scheme' + s, 'a') as text: text.write(str(x)) text.write(',') for cost in costs_list: text.write(str(cost)) text.write(',') text.write('\n')
best_score = int(split_line[2]) average_score = float(split_line[3]) iterations = int(split_line[4]) new_begin_temp = begin_temp + random.choice([-2, -1, 0, 1, 2]) if new_begin_temp < 0: new_begin_temp = 1 new_end_temp = end_temp + random.choice([-0.2, -0.1, 0, 0.1, 0.2]) if new_end_temp < 0: new_end_temp = 0.1 m = 0 lowest_costs = 10000 print('begin = ' + str(new_begin_temp) + ' end = ' + str(new_end_temp)) for y in range(10): map = readMap.read_complete_map('Russiadfs.txt') map = sim_an_search.sim_an(map, c, signals, 200000, new_begin_temp, new_end_temp) freq = analyse.analyse_signal_frequentie(map) costs = analyse.get_cost(freq, c) if costs < lowest_costs: lowest_costs = costs m += costs print(y) mean = m / 10 print('mean = '+str(mean)+' lowest = '+str(lowest_costs)) iterations += 1 if lowest_costs < best_score: with open('best_temp_'+ s +'.txt', 'w') as text: text.write(str(new_begin_temp)) text.write(',') text.write(str(new_end_temp)) text.write(',')
signals = ['zA', 'zB', 'zC', 'zD', 'zE', 'zF', 'zG'] cost1 = {'zA':12, 'zB':26, 'zC':27, 'zD':30, 'zE':37, 'zF':39, 'zG':41} cost2 = {'zA':19, 'zB':20, 'zC':21, 'zD':23, 'zE':36, 'zF':37, 'zG':38} cost3 = {'zA':16, 'zB':17, 'zC':31, 'zD':33, 'zE':36, 'zF':56, 'zG':57} cost4 = {'zA':3, 'zB':34, 'zC':36, 'zD':39, 'zE':41, 'zF':43, 'zG':58} costlist = [cost1, cost2, cost3, cost4] begintemp = [9, 5, 9, 15] maplist = [readMap.read_complete_map('Ukrainedfs.txt'), readMap.read_complete_map('UnitedStatesdfs.txt'), readMap.read_complete_map('Russiadfs.txt')] with open('temptation.txt', 'a') as text: for m in range(3): for c in range(4): lowest_cost = 2000 for y in range(20): map = maplist[m] sim_an_search.sim_an(map, costlist[c], signals, begin_temp=begintemp[c], end_temp=0.5) freq = analyse.analyse_signal_frequentie(map) costs = analyse.get_cost(freq, costlist[c]) if costs < lowest_cost: lowest_cost = costs print(m, c + 1, y, lowest_cost) text.write(str(m) + str(c + 1) + ': ' + str(lowest_cost)) text.write('\n')