예제 #1
0
/*
 * Note: parameters are always refreshed in advance by $pc_export_sw_info/1,
 *       so it causes no problem to overwrite them temporarily
 */
int pc_compute_n_viterbi_rerank_4(void)
{
    TERM p_n_viterbi_list;
    int n,l,goal_id;

    n       = bpx_get_integer(bpx_get_call_arg(1,4));
    l       = bpx_get_integer(bpx_get_call_arg(2,4));
    goal_id = bpx_get_integer(bpx_get_call_arg(3,4));

    initialize_egraph_index();
    alloc_sorted_egraph(1);
    /* INIT_MIN_MAX_NODE_NOS; */
    RET_ON_ERR(sort_one_egraph(goal_id,0,1));
    if (verb_graph) print_egraph(0,PRINT_NEUTRAL);

    alloc_occ_switches();
    transfer_hyperparams_prolog();
	get_param_means();

    compute_n_max(l);

    get_n_most_likely_path_rerank(n,l,goal_id,&p_n_viterbi_list);

    release_occ_switches();

    return bpx_unify(bpx_get_call_arg(4,4),p_n_viterbi_list);
}
예제 #2
0
파일: graph.c 프로젝트: davidvaz/yap-cmake
int pc_import_occ_switches_3(void)
{
  CACHE_REGS
    TERM p_sw_list,p_sw_list0,p_sw_list1;
    TERM p_sw_ins_list0,p_sw_ins_list1,sw,sw_ins;
    TERM p_num_sw, p_num_sw_ins;
    int i;
    int num_sw_ins;
    void release_occ_switches();

#ifdef __YAP_PROLOG__
    TERM *hstart;
 restart:
    hstart = heap_top;
#endif
    p_sw_list    = bpx_get_call_arg(1,3);
    p_num_sw     = bpx_get_call_arg(2,3);
    p_num_sw_ins = bpx_get_call_arg(3,3);

    p_sw_list0 = bpx_build_nil();
    num_sw_ins = 0;
    for (i = 0; i < occ_switch_tab_size; i++) {
        SW_INS_PTR  ptr;

#ifdef __YAP_PROLOG__
	if ( heap_top + 64*1024 >= local_top ) {			    
	  H = hstart;
	  /* running out of stack */
	  extern int Yap_gcl(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop);

	  Yap_gcl(4*64*1024, 3, ENV, CP);
	  goto restart;
	}
#endif

        sw = bpx_build_structure("sw",2);
        bpx_unify(bpx_get_arg(1,sw), bpx_build_integer(i));

        p_sw_ins_list0 = bpx_build_nil();
        ptr = occ_switches[i];
        while (ptr != NULL) {
            num_sw_ins++;

            if (ptr->inside <= 0.0) ptr->inside = 0.0;  /* FIXME: quick hack */

            sw_ins = bpx_build_structure("sw_ins",4);
            bpx_unify(bpx_get_arg(1,sw_ins),bpx_build_integer(ptr->id));
            bpx_unify(bpx_get_arg(2,sw_ins),bpx_build_float(ptr->inside));
            bpx_unify(bpx_get_arg(3,sw_ins),bpx_build_float(ptr->smooth));
            bpx_unify(bpx_get_arg(4,sw_ins),bpx_build_float(ptr->total_expect));

            p_sw_ins_list1 = bpx_build_list();
            bpx_unify(bpx_get_car(p_sw_ins_list1),sw_ins);
            bpx_unify(bpx_get_cdr(p_sw_ins_list1),p_sw_ins_list0);
            p_sw_ins_list0 = p_sw_ins_list1;

            ptr = ptr->next;
        }

        bpx_unify(bpx_get_arg(2,sw),p_sw_ins_list0);

        p_sw_list1 = bpx_build_list();
        bpx_unify(bpx_get_car(p_sw_list1),sw);
        bpx_unify(bpx_get_cdr(p_sw_list1),p_sw_list0);
        p_sw_list0 = p_sw_list1;
    }

    release_occ_switches();

    return
        bpx_unify(p_sw_list,    p_sw_list0) &&
        bpx_unify(p_num_sw,     bpx_build_integer(occ_switch_tab_size)) &&
        bpx_unify(p_num_sw_ins, bpx_build_integer(num_sw_ins));
}