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))
import readMap import dfs import hill_solve import analyse map = readMap.read_complete_map('Russiadfs5.csv') signal_costs = analyse.get_cost_scheme(1) analyse.print_costs(map, signal_costs)
import analyse import readMap import sim_an_search s = '3' begin_temp = 0 new_begin_temp = 0 end_temp = 0 new_end_temp = 0 best_score = 0 average_score = 0 c = analyse.get_cost_scheme(int(s)) signals = list(c.keys()) while(True): with open('best_temp_' + s + '.txt', 'r') as text: for line in text: split_line = line.split(',') begin_temp = int(split_line[0]) end_temp = float(split_line[1]) 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
import analyse import readMap import hill_solve for x in range(6, 13): signal_costs = analyse.get_cost_scheme(int(x)) signals = list(signal_costs.keys()) costs_list = [] for y in range(20): map = readMap.read_complete_map('Russiadfs.txt') hill_solve.hill_climber(map, signal_costs, signals, iterations=200000) 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_hill.txt', 'a') as text: text.write(str(x)) text.write(',') for cost in costs_list: text.write(str(cost)) text.write(',') text.write('\n')
import analyse <<<<<<< HEAD for x in range(1, 19): scheme = analyse.get_cost_scheme(x) with open('scheme.txt', 'a') as text: text.write(str(scheme['zA'])) text.write(',') text.write(str(scheme['zB'])) text.write(',') text.write(str(scheme['zC'])) text.write(',') text.write(str(scheme['zD'])) text.write(',') text.write(str(scheme['zE'])) text.write(',') text.write(str(scheme['zF'])) text.write(',') text.write(str(scheme['zG'])) text.write(',') text.write('\n') ======= import draw import readMap map = readMap.read_complete_map('UnitedStatesdfs.txt') signal_costs = analyse.get_cost_scheme(4) draw.draw_america_2(map, signal_costs)
from numpy.random import choice import analyse scheme = analyse.get_cost_scheme(1) print(scheme) sum = 0 for cost in list(scheme.keys()): sum += scheme[cost] weights = [] for cost in list(scheme.keys()): x = scheme[cost] y = x/sum weights.append(1/y) sum_2 = 0 for weight in weights: sum_2 += weight weights_2 = [] for weight in weights: weights_2.append(weight/sum_2) print(weights_2)