def new_experiment_sequence(new_grid, union_find, show_progress): resulting_representations = [] connections = RandomConnectionBag(len(new_grid), union_find) iterations = 0 max_num_of_random_connections = len(new_grid)*3 period = 10 delay = False effective_iterations = 0 while iterations < max_num_of_random_connections: x,y = connections.get_next_spiraled() if union_find.count == 1: break if effective_iterations%period == 0 and show_progress and not delay: next_representation = new_grid.State_info(new_grid, union_find) resulting_representations.append(next_representation.get_represantation()) # print next_representation # print union_find # print 'iterations consumed:', iterations # print 'connections left', len(connections) if union_find.connected(x,y): delay = False else: delay = False effective_iterations +=1 union_find.union(x, y) # delay = False iterations += 1 print union_find last_representation = new_grid.State_info(new_grid, union_find) resulting_representations.append(next_representation.get_represantation(True)) print 'iterations consumed:', iterations print len(resulting_representations) return resulting_representations
def new_experiment(new_grid, union_find, show_progress): connections = RandomConnectionBag(len(new_grid), union_find) iterations = 0 max_num_of_random_connections = len(new_grid) period = new_grid.size() * 10 start = datetime.now() while iterations < max_num_of_random_connections: x, y = connections.get_next_spiraled() if union_find.count == 1: break if iterations % period == 0 and show_progress: print union_find print 'iterations consumed:', iterations print 'connections left', len(connections) union_find.union(x, y) # delay = False iterations += 1 end = datetime.now() print 'iterations consumed:', iterations print union_find return iterations, (end - start).total_seconds()
def new_experiment(new_grid, union_find, show_progress): connections = RandomConnectionBag(len(new_grid), union_find) iterations = 0 max_num_of_random_connections = len(new_grid) period = new_grid.size()*10 start = datetime.now() while iterations < max_num_of_random_connections: x,y = connections.get_next_spiraled() if union_find.count == 1: break if iterations%period == 0 and show_progress: print union_find print 'iterations consumed:', iterations print 'connections left', len(connections) union_find.union(x, y) # delay = False iterations += 1 end = datetime.now() print 'iterations consumed:', iterations print union_find return iterations, (end -start).total_seconds()
def new_experiment_sequence(new_grid, union_find, show_progress): resulting_representations = [] connections = RandomConnectionBag(len(new_grid), union_find) iterations = 0 max_num_of_random_connections = len(new_grid) * 3 period = 10 delay = False effective_iterations = 0 while iterations < max_num_of_random_connections: x, y = connections.get_next_spiraled() if union_find.count == 1: break if effective_iterations % period == 0 and show_progress and not delay: next_representation = new_grid.State_info(new_grid, union_find) resulting_representations.append( next_representation.get_represantation()) # print next_representation # print union_find # print 'iterations consumed:', iterations # print 'connections left', len(connections) if union_find.connected(x, y): delay = False else: delay = False effective_iterations += 1 union_find.union(x, y) # delay = False iterations += 1 print union_find last_representation = new_grid.State_info(new_grid, union_find) resulting_representations.append( next_representation.get_represantation(True)) print 'iterations consumed:', iterations print len(resulting_representations) return resulting_representations