Пример #1
0
def generate_all_seed_rules(kernel_set, gl):
    import utils, asp, functs, excps
    generated_seeds, str_generated_seeds = [], []
    for c in kernel_set:
        for seed in generated_seeds:
            utils.analyze_use_try([c], [],
                                  incremental_search=True,
                                  preserve=generated_seeds)
            (_, pos, negs,
             optimization_score) = asp.ind(kernel_generalization=True,
                                           incremental_search=True)
            (all_solutions, _, _) = asp.ind(find_all_optimal=True,
                                            incremental_search=True,
                                            opt=optimization_score)
            for solution in all_solutions:
                if len(solution) > 1:
                    (use_2, _) = functs.split_use_2_3(solution)
                    (ok, use_head_body_map
                     ) = functs.head_body_use_atoms_filter(use_2)
                    if ok:
                        new = utils.form_new_clauses(
                            use_head_body_map, incremental_kernel_search=True)
                        if not new[0].as_string in str_generated_seeds:
                            generated_seeds.append(new[0])
                            str_generated_seeds.append(new[0].as_string)
                    else:
                        msg = 'Found a solution use(i,j) atom with no corresponding use(i,0) atom'
                        raise excps.Use_2_HeadNotAbducedException(
                            msg, gl.logger)
            print('seeds:')
            utils.see(generated_seeds)
    #return (seed_model,seed_rule,pos,negs,optimization_score)
    return generated_seeds
Пример #2
0
def generate_all_seed_rules(kernel_set,gl):
    import utils,asp,functs,excps
    generated_seeds,str_generated_seeds = [],[]
    for c in kernel_set:
        for seed in generated_seeds:
            utils.analyze_use_try([c],[],incremental_search=True,preserve=generated_seeds)  
            (_,pos,negs,optimization_score) = asp.ind(kernel_generalization=True,
                                                      incremental_search=True)  
            (all_solutions,_,_) = asp.ind(find_all_optimal=True,
                                       incremental_search=True,
                                       opt=optimization_score)
            for solution in all_solutions:    
                if len(solution) > 1:
                    (use_2,_) = functs.split_use_2_3(solution)
                    (ok,use_head_body_map) = functs.head_body_use_atoms_filter(use_2)
                    if ok :
                        new = utils.form_new_clauses(use_head_body_map,incremental_kernel_search=True)
                        if not new[0].as_string in str_generated_seeds: 
                            generated_seeds.append(new[0])
                            str_generated_seeds.append(new[0].as_string)
                    else:
                        msg = 'Found a solution use(i,j) atom with no corresponding use(i,0) atom'
                        raise excps.Use_2_HeadNotAbducedException(msg,gl.logger)
            print('seeds:')
            utils.see(generated_seeds)
    #return (seed_model,seed_rule,pos,negs,optimization_score)            
    return generated_seeds    
Пример #3
0
def batchMode():
    u.clear_prior()
    u.post_exmpl_constraints(heuristic_search=False,set_cover_search=False,
                             clause_level_search=False)
    (newclauses,retained,specialized) = ([],[],[])
    (newclauses,retained,specialized) = \
                    u.revise(is_new_example=True,
                    debug=False,
                    newcl=newclauses,
                    refcl=specialized,
                    retcl=retained,heuristic_search=False,
                    set_cover_search=False,
                    clause_level_search=False,
                    incremental_solve=False) 
    print('\n')                  
    u.see(newclauses)               
Пример #4
0
def batchMode():
    u.clear_prior()
    u.post_exmpl_constraints(heuristic_search=False,
                             set_cover_search=False,
                             clause_level_search=False)
    (newclauses, retained, specialized) = ([], [], [])
    (newclauses,retained,specialized) = \
                    u.revise(is_new_example=True,
                    debug=False,
                    newcl=newclauses,
                    refcl=specialized,
                    retcl=retained,heuristic_search=False,
                    set_cover_search=False,
                    clause_level_search=False,
                    incremental_solve=False)
    print('\n')
    u.see(newclauses)