def check_successors(tester, generator, k, goal_typ): sk = UnfinishedLeaf() sk_smart = UnfinishedLeaf(goal_typ) all_trees = set(tr.tree for tr in ts(generator.gamma, k, goal_typ, 0)) if all_trees: check_successors_acc(tester, generator, k, goal_typ, sk, sk_smart, all_trees)
def separate_error_ip_new(): goal, gamma, max_k = d3() gene = Generator(gamma) k = 2 skel = UnfinishedLeaf(goal) set_log_printing(True) t = time.time() next_skels = skel.successors_smart(gene, k) log_expansion(skel, next_skels, t)
def separate_error_bad_smart_expansion_2017_02_28(): print('Separating error: bad_expansion_2017_02_28') problem_goal, problem_gamma, _ = d3() gene = Generator(problem_gamma) problem_k = 5 skel_0 = UnfinishedLeaf(problem_goal) set_log_printing(True) def succ(sk, path=None, is_smart=True, goal_typ=None): t = time.time() if is_smart: next_sks = sk.successors_smart(gene, problem_k) else: next_sks = sk.successors(gene, problem_k, goal_typ) log_expansion(sk, next_sks, t) if not path: return next_sks else: i = path[0] path = path[1:] next_one = next_sks[i] print(' i=', i, 'selected:', next_one) return succ(next_one, path, is_smart, goal_typ) if path else next_one bug_path_1 = [0, 0, 0, 2, 0, 0] # (((k (? ?)) ?) ?) bug_path_2 = [0, 0, 0, 2, 0, 0] skel = succ(skel_0, bug_path_1, False, problem_goal) print(skel) print() seed = 42 random.seed(seed) print('seed:', seed) tree = gene.gen_one_uf(skel, problem_k, problem_goal) log(str(tree)) log('is_well_typed:', tree.is_well_typed(gene.gamma)) print() skel = succ(skel_0, bug_path_2) print(skel) print()
def test_mcts(self): env = domain_parity_apptree.make_env_app_tree() node = MCTNode(UFTNode(UnfinishedLeaf(), 3)) run_basic_mcts(node, env, 1, 3)
def test_nmcs(self): env = domain_parity_apptree.make_env_app_tree() node = UFTNode(UnfinishedLeaf(), 3) run_basic_nmcs(node, env, 0)
IS_LOG_PRINTING = True check_skeletons(TestGen()) if not True: goal, gamma, max_k = d2() # print(gamma, '\n') # gamma.add_internal_pair() # todo uplne smazat až bude fungovat print(gamma, '\n') gen = Generator(gamma) k = 2 skeleton = UnfinishedLeaf() skeleton_smart = UnfinishedLeaf(goal) succs = skeleton.successors(gen, k, goal) print('[', ','.join(str(s) for s in succs), ']') succs_smart = skeleton_smart.successors_smart(gen, k) print('[', ','.join(str(s) for s in succs_smart), ']') skeleton = succs[0] skeleton_smart = succs_smart[0] succs = skeleton.successors(gen, k, goal) print('[', ','.join(str(s) for s in succs), ']') succs_smart = skeleton_smart.successors_smart(gen, k)
def test_mcts(self): env = domain_koza_apptree.make_env_app_tree() node = MCTNode(ChooseKTNode(UnfinishedLeaf(), 5)) run_basic_mcts(node, env)
def test_nmcs(self): env = domain_koza_apptree.make_env_app_tree() node = ChooseKTNode(UnfinishedLeaf(), 10) run_basic_nmcs(node, env)
domain = domain_physics_smart else: assert False make_env = lambda: domain.make_env_app_tree(smart=args.smart_uf) elif args.stack: if args.domain == D_KOZA_POLY: domain = domain_koza_stack elif args.domain == D_PARITY: domain = domain_parity_stack else: assert False make_env = lambda: domain.make_env_stack(args.k) else: assert False uf_factory = lambda env: UnfinishedLeaf() if args.smart_uf: uf_factory = lambda env: UnfinishedLeaf(typ=env.goal) if args.nmcs: # Nested MC Search def one_iteration(worker_env): env = make_env() evals_before = env.count_evals() assert not evals_before time_before = time.time() root = construct_root_node(args, env) indiv = nested_mc_search(root, max_level=args.nmcs_level, fitness=env.fitness, finish=env.finish,