Esempio n. 1
0
/*
 * Export probabilities of switches from Prolog to C.  Switches is
 * a list of switches, each of which takes the form:
 *
 *   sw(Id,InstanceIds,Probs,SmoothCs,Fixed,FixedH),
 *
 * where
 *    Id:          identifier of the switch
 *    InstanceIds: list of ids of the instances of the switch
 *    Probs:       current probabilities assigned to the instance switches
 *    SmoothCs:    current pseudo counts assigned to the instance switches
 *    Fixed:       probabilities fixed?
 *    FixedH:      pseudo counts fixed?
 *
 * The structures for switch instances have been allocated. This
 * function only fills out the initial probabilities.
 */
int pc_export_sw_info_1(void)
{
    int sw_id,instance_id,fixed,fixed_h;
    double prob,smooth;
    TERM p_switches, p_switch;
    TERM p_instance_list,p_prob_list,p_smooth_list;
    TERM p_prob,p_smooth;

    p_switches = bpx_get_call_arg(1,1);

    while (bpx_is_list(p_switches)) {
        /* p_switch: sw(Id,InstList,ProbList,SmoothCList,FixedP,FixedH) */
        p_switch = bpx_get_car(p_switches);

        sw_id           = bpx_get_integer(bpx_get_arg(1,p_switch));
        p_instance_list = bpx_get_arg(2,p_switch);
        p_prob_list     = bpx_get_arg(3,p_switch);
        p_smooth_list   = bpx_get_arg(4,p_switch);
        fixed           = bpx_get_integer(bpx_get_arg(5,p_switch));
        fixed_h         = bpx_get_integer(bpx_get_arg(6,p_switch));

        while (bpx_is_list(p_instance_list)) {
            instance_id = bpx_get_integer(bpx_get_car(p_instance_list));
            p_prob      = bpx_get_car(p_prob_list);
            p_smooth    = bpx_get_car(p_smooth_list);

            if (bpx_is_integer(p_prob)) {
                prob = (double)bpx_get_integer(p_prob);
            }
            else if (bpx_is_float(p_prob)) {
                prob = bpx_get_float(p_prob);
            }
            else {
                RET_ERR(illegal_arguments);
            }

            if (bpx_is_integer(p_smooth)) {
                smooth = (double)bpx_get_integer(p_smooth);
            }
            else if (bpx_is_float(p_smooth)) {
                smooth = bpx_get_float(p_smooth);
            }
            else {
                RET_ERR(illegal_arguments);
            }

            switch_instances[instance_id]->inside         = prob;
            switch_instances[instance_id]->fixed          = fixed;
            switch_instances[instance_id]->fixed_h        = fixed_h;
            switch_instances[instance_id]->smooth_prolog  = smooth;

            p_instance_list = bpx_get_cdr(p_instance_list);
            p_prob_list     = bpx_get_cdr(p_prob_list);
            p_smooth_list   = bpx_get_cdr(p_smooth_list);
        }
        p_switches = bpx_get_cdr(p_switches);
    }

    return BP_TRUE;
}
Esempio n. 2
0
int pc_set_std_ratio_1(void)
{
    std_ratio = bpx_get_float(bpx_get_call_arg(1,1));
    return BP_TRUE;
}
Esempio n. 3
0
int pc_set_itemp_rate_1(void)
{
    itemp_rate = bpx_get_float(bpx_get_call_arg(1,1));
    return BP_TRUE;
}
Esempio n. 4
0
int pc_set_prism_epsilon_1(void)
{
    prism_epsilon = bpx_get_float(bpx_get_call_arg(1,1));
    return BP_TRUE;
}