Пример #1
0
void test_inputs__par2X(void)
{
    int i;
    ssm_par2X(X, par, calc, nav);

    double expected_sv_inc[] = {    
        pow(10,-5)*1000000, //I_nyc
        1e-05*1000000,      //I_paris
        0.07*1000000,       //S_nyc
        0.07*1000000,       //S_paris
	0.0,                //Inc_in_nyc
	0.0                 //Inc_out
    };

    double expected_diff[] = {    
        log(20.0),          //r0_nyc
        log(20.0)           //r0_paris
    };

    for(i=0; i<nav->states_sv_inc->length; i++){
	cl_check(X->proj[nav->states_sv_inc->p[i]->offset] == expected_sv_inc[i]);
    }

    for(i=0; i<nav->states_diff->length; i++){
	cl_check(X->proj[nav->states_diff->p[i]->offset] == expected_diff[i]);
    }    
}
// Pawn targets.
void test_position_targets_suite__000(void) {
    setup("Kd1,e2", "Ke8,d4");
	Position *p = start();

	cl_check(targets(p, E2) == (bit[E3] | bit[E4]));
	cl_check(targets(p, D4) == bit[D3]);
}
void test_position_targets_suite__020(void) {
	setup("Kd1,e2", "Ke8,d3,f3");
    Position *p = start();

	cl_check(targets(p, E2) == (bit[D3] | bit[E3] | bit[E4] | bit[F3]));
	cl_check(targets(p, D3) == (bit[E2] | bit[D2]));
	cl_check(targets(p, F3) == (bit[E2] | bit[F2]));
}
void test_position_targets_suite__030(void) {
	setup("Kd1,e2", "Ke8,d4");
    Position *p = start();
	p = make_move(p, new_enpassant(p, E2, E4)); // Creates en-passant on e3.

	cl_check(targets(p, E4) == bit[E5]);
	cl_check(targets(p, D4) == (bit[D3] | bit[E3]));
}
void test_position_targets_suite__010(void) {
	setup("Kd1,e2,d3", "Ke8,d4,e4");
    Position *p = start();

	cl_check(targets(p, E2) == bit[E3]);
	cl_check(targets(p, D3) == bit[E4]);
	cl_check(targets(p, D4) == maskNone);
	cl_check(targets(p, E4) == (bit[D3] | bit[E3]));
}
Пример #6
0
void test_inputs__X_new(void)
{
    int i;
    cl_check(X->length == 4+2+2);
    cl_check(X->dt0 == 0.25);
    cl_check(X->dt == X->dt0);

    for(i=0; i<X->length; i++){
        cl_check(X->proj[i] == 0.0);
    }
}
Пример #7
0
void test_inputs__remainders(void)
{
    int i;
    ssm_par2X(X, par, calc, nav);
       
    for(i=0; i<nav->states_remainders->length; i++){
	cl_check(nav->states_remainders->p[i]->f_remainder(X, par, calc, 0.0) == 1000000 - 1e-05*1000000 - 0.07*1000000);
    }
}
Пример #8
0
void test_inputs__theta2input(void)
{
    int i;
    ssm_input_t *input_test = ssm_input_new(jparameters, nav);    
    ssm_theta2input(input_test, theta, nav);

    for(i=0; i<input_test->size; i++){
	cl_check(fabs(gsl_vector_get(input_test, i) - gsl_vector_get(input, i))<1e-12);       
    }
    
    ssm_input_free(input_test);
}
Пример #9
0
void test_parameters__parameters_new(void)
{
    int i;
    char *expected_names[] = {"pr_I_nyc", "pr_I_paris", "S_nyc", "pr_S_paris", "sto", "r0_nyc", "r0_paris", "pr_v", "vol", "phi", "rep_all_CDC_inc", "rep_all_google_inc", "rep_nyc_CDC_inc", "rep_paris_CDC_prev"};

    cl_check(parameters_length == sizeof(expected_names)/sizeof(*expected_names));
    for(i=0; i<parameters_length; i++) {
        cl_assert(parameters[i]->offset == i);
        cl_assert(parameters[i]->offset_theta == -1);
        cl_assert_equal_s(parameters[i]->name, expected_names[i]);
    }

}
Пример #10
0
Файл: nav.c Проект: nvdnkpr/ssm
void test_nav__nav_it_theta_opts_no_diff(void)
{
    int i;

    ssm_options_t *opts_nd = ssm_options_new();
    opts_nd->noises_off = SSM_NO_DIFF;
    ssm_nav_t *nav_nd = ssm_nav_new(jparameters, opts_nd);

    cl_check(nav_nd->theta_no_icsv_no_icdiff->length == 7);
    cl_check(nav_nd->theta_icsv_icdiff->length == 3);

    char *expected_names[] = {"pr_I_nyc", "pr_I_paris", "pr_S_paris"};
    for(i=0; i<nav_nd->theta_icsv_icdiff->length; i++) {
        cl_assert_equal_s(nav_nd->theta_icsv_icdiff->p[i]->name, expected_names[i]);
    }

    char *expected_names_no[] = {"r0_nyc", "r0_paris", "pr_v", "rep_all_CDC_inc", "rep_all_google_inc", "rep_nyc_CDC_inc", "rep_paris_CDC_prev"};
    for(i=0; i<nav_nd->theta_no_icsv_no_icdiff->length; i++) {
        cl_assert_equal_s(nav_nd->theta_no_icsv_no_icdiff->p[i]->name, expected_names_no[i]);
    }

    ssm_options_free(opts_nd);
    ssm_nav_free(nav_nd);
}
Пример #11
0
Файл: nav.c Проект: nvdnkpr/ssm
void test_nav__nav_it_theta(void)
{
    int i;

    cl_check(nav->theta_all->length == 10);
    cl_check(nav->theta_no_icsv_no_icdiff->length == 5);
    cl_check(nav->theta_icsv_icdiff->length == 5);

    char *expected_names[] = {"pr_I_nyc", "pr_I_paris", "pr_S_paris", "r0_nyc", "r0_paris", "pr_v", "rep_all_CDC_inc", "rep_all_google_inc", "rep_nyc_CDC_inc", "rep_paris_CDC_prev"};
    for(i=0; i<nav->theta_all->length; i++) {
        cl_assert_equal_s(nav->theta_all->p[i]->name, expected_names[i]);
    }

    char *expected_names_ic[] = {"pr_I_nyc", "pr_I_paris", "pr_S_paris", "r0_nyc", "r0_paris"};
    for(i=0; i<nav->theta_icsv_icdiff->length; i++) {
        cl_assert_equal_s(nav->theta_icsv_icdiff->p[i]->name, expected_names_ic[i]);
    }

    char *expected_names_no[] = {"pr_v", "rep_all_CDC_inc", "rep_all_google_inc", "rep_nyc_CDC_inc", "rep_paris_CDC_prev"};
    for(i=0; i<nav->theta_no_icsv_no_icdiff->length; i++) {
        cl_assert_equal_s(nav->theta_no_icsv_no_icdiff->p[i]->name, expected_names_no[i]);
    }

}
Пример #12
0
void test_inputs__theta_new(void)
{
    int i;
    double expected[] = {
        ssm_f_logit_ab(5, 4, 6),               //I_nyc
        ssm_f_logit_ab(1e-05, 1e-6, 1e-4),     //I_paris
        ssm_f_logit_ab(0.07, 0.04, 0.09),      //S_paris
        ssm_f_logit_ab(20.0, 15.0, 35.0),      //r0_nyc
        ssm_f_logit_ab(20.0, 15.0, 35.0),      //r0_paris
        ssm_f_log(11.0),                       //v
        ssm_f_logit_ab(0.6, 0.5, 0.8),         //rep_all_CDC_inc
        ssm_f_logit_ab(0.6, 0.5, 0.8),         //rep_all_google_inc
        ssm_f_logit_ab(0.6, 0.5, 0.8),         //rep_nyc_CDC_inc
        ssm_f_logit_ab(0.6, 0.5, 0.8)          //rep_paris_CDC_prev
    };

    for(i=0; i<nav->theta_all->length; i++){
	cl_check(gsl_vector_get(theta, nav->theta_all->p[i]->offset_theta) == expected[i]);
    }
}
Пример #13
0
void test_inputs__var_new(void)
{
    int i, j;
    double expected[10][10] = {
        {0.01, 0,    0,    0,    0,    0,    0,    0,    0,    0},
        {0,    0.03, 0,    0,    0,    0,    0,    0,    0,    0},
        {0,    0,    0.02, 0,    0,    0,    0,    0,    0,    0},
        {0,    0,    0,    0.04, 0,    0.01, 0,    0,    0,    0},
        {0,    0,    0,    0,    0.02, 0,    0,    0,    0,    0},
        {0,    0,    0,    0.01, 0,    0.02, 0,    0,    0,    0},
        {0,    0,    0,    0,    0,    0,    0.02, 0,    0,    0},
        {0,    0,    0,    0,    0,    0,    0,    0.02, 0,    0},
        {0,    0,    0,    0,    0,    0,    0,    0,    0.02, 0},
        {0,    0,    0,    0,    0,    0,    0,    0,    0,    0.03}
    };

    for(i=0; i<nav->theta_all->length; i++){
        for(j=0; j<nav->theta_all->length; j++){
            cl_check(gsl_matrix_get(var, nav->theta_all->p[i]->offset_theta, nav->theta_all->p[j]->offset_theta) == expected[i][j]);
        }
    }
}
Пример #14
0
void test_inputs__input_new(void)
{
    int i;
    double expected[] = {
        5,     //I_nyc
        1e-05, //I_paris
        0,     //S_nyc (follow are initialized at 0)
        0.07,  //S_paris
        0.1,   //sto
        20,    //r0_nyc
        20,    //r0_paris
        11,    //v
        0.1,   //vol
        0.1,   //phi
        0.6,   //rep_all_CDC_inc
        0.6,   //rep_all_google_inc
        0.6,   //rep_nyc_CDC_inc
        0.6    //rep_paris_CDC_prev
    };

    for(i=0; i<nav->par_all->length; i++){
        cl_check(gsl_vector_get(input, nav->par_all->p[i]->offset) == expected[i]);
    }
}
Пример #15
0
void test_inputs__par_new(void)
{
    int i;
    double expected[] = {
        pow(10,-5)*1000000, //I_nyc
        1e-05*1000000,      //I_paris
        0.07*1000000,       //S_nyc
        0.07*1000000,       //S_paris
        0.1,                //sto
        20,                 //r0_nyc
        20,                 //r0_paris
        1.0/11.0,           //v
        0.1,                //vol
        0.1,                //phi
        0.6,                //rep_all_CDC_inc
        0.6,                //rep_all_google_inc
        0.6,                //rep_nyc_CDC_inc
        0.6                 //rep_paris_CDC_prev
    };

    for(i=0; i<nav->par_all->length; i++){
        cl_check(gsl_vector_get(par, nav->par_all->p[i]->offset) == expected[i]);
    }
}
Пример #16
0
void test_evaluate_pawns_suite__230(void) {
    setup("Ke1,e5", "Ke8,e4"); // Both passing.
    Position *p = start();
    int score = evaluate(p);
    cl_check(score == 5);
}
Пример #17
0
void test_evaluate_pawns_suite__220(void) {
    setup("Ke1,e4", "Ke8,d6"); // Can't pass.
    Position *p = start();
    int score = evaluate(p);
    cl_check(score == -3);
}
Пример #18
0
// Passed pawns.
void test_evaluate_pawns_suite__200(void) {
    setup("Ke1,h4", "Ke8,h5"); // Blocked.
    Position *p = start();
    int score = evaluate(p);
    cl_check(score == 5);
}
Пример #19
0
void test_evaluate_pawns_suite__120(void) {
    setup("Ke1,f4,f5", "Ke8,f7,h7");
    Position *p = start();
    int score = evaluate(p);
    cl_check(score == -33);
}
Пример #20
0
void test_evaluate_pawns_suite__570(void) {
    setup("Kb1,a2,c2,f2,g2,h2", "Kg8,a7,c7,f7,g7,h7"); // B2 hole but not enough power to bother.
    Position *p = start();
    int score = evaluate(p);
    cl_check(score == 5);
}
Пример #21
0
void test_evaluate_pawns_suite__250(void) {
    setup("Ke1,a5", "Kd8,h7"); // Both passing but white is much closer.
    Position *p = start();
    int score = evaluate(p);
    cl_check(score == 97);
}
Пример #22
0
void test_evaluate_pawns_suite__540(void) {
    setup("Kb1,a3,b4,c2,Qh3,Nh4", "Kb8,a7,b7,c7,Qh6,Nh5"); // A3,B4,c2 vs a7,b7,c7
    Position *p = start();
    int score = evaluate(p);
    cl_check(score == -10);
}
Пример #23
0
void test_evaluate_pawns_suite__310(void) {
    setup("Ke1,a2,c2,e2", "Ke8,a7,b7,c7"); // White pawns are isolated.
    Position *p = start();
    int score = evaluate(p);
    cl_check(score == -50);
}
Пример #24
0
// Doubled pawns.
void test_evaluate_pawns_suite__100(void) {
    setup("Ke1,h2,h3", "Kd8,a7,a6");
    Position *p = start();
    int score = evaluate(p);
    cl_check(score == rightToMove.endgame); // Right to move only.
}
Пример #25
0
void test_evaluate_pawns_suite__240(void) {
    setup("Kd1,e5", "Ke8,d5"); // Both passing but white is closer.
    Position *p = start();
    int score = evaluate(p);
    cl_check(score == 26);
}
Пример #26
0
void test_evaluate_pawns_suite__550(void) {
    setup("Kb1,b2,c2,h2,Qh3,Nh4", "Kb8,a7,b7,c7,Qh6,Nh5"); // b2,c2,H2 vs a7,b7,c7
    Position *p = start();
    int score = evaluate(p);
    cl_check(score == -31);
}
Пример #27
0
// Isolated pawns.
void test_evaluate_pawns_suite__300(void) {
    setup("Ke1,a5,c5", "Kd8,f4,h4"); // All pawns are isolated.
    Position *p = start();
    int score = evaluate(p);
    cl_check(score == 5);
}
Пример #28
0
void test_evaluate_pawns_suite__560(void) {
    setup("Ka1,a3,b2,Qc1,Nd2", "Kh8,g7,h6,Qf8,Ne7"); // a3,b2 == g7,h6
    Position *p = start();
    int score = evaluate(p);
    cl_check(score == 8);
}
Пример #29
0
void test_evaluate_pawns_suite__420(void) {
    setup("Ke1,Rb1,a2,g2", "Ke8,Rh8,h7,b7"); // White on semi-open file.
    Position *p = start();
    int score = evaluate(p);
    cl_check(score == 103);
}
Пример #30
0
void test_evaluate_pawns_suite__520(void) {
    setup("Kg1,f2,g2,h2,Qa3,Na4", "Kg8,a7,f7,g7,Qa6,Na5"); // h2,g2,h2 vs A7,f7,g7
    Position *p = start();
    int score = evaluate(p);
    cl_check(score == 47);
}