X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8ea2649a94e38ff0333ca955277091e7d4af8dd4..40b9540a553006e50628eb13c451c354a0671d3e:/testsuite/surf/lmm_usage.c diff --git a/testsuite/surf/lmm_usage.c b/testsuite/surf/lmm_usage.c index 3fe0ddba3f..3b534d9f48 100644 --- a/testsuite/surf/lmm_usage.c +++ b/testsuite/surf/lmm_usage.c @@ -54,26 +54,36 @@ static double dichotomy(double func(double), double min, double max, if ((min_func > 0 && max_func < 0)) abort(); + SHOW_EXPR(min_error); + while (overall_error > min_error) { + SHOW_EXPR(overall_error); if ((min_func > 0 && max_func > 0) || (min_func < 0 && max_func < 0) || (min_func > 0 && max_func < 0)) { abort(); } + SHOW_EXPR(min); + SHOW_EXPR(min_func); + SHOW_EXPR(max); + SHOW_EXPR(max_func); + middle = (max + min) / 2.0; if ((min == middle) || (max == middle)) { break; } middle_func = func(middle); + SHOW_EXPR(middle); + SHOW_EXPR(middle_func); if (middle_func < 0) { min = middle; min_func = middle_func; - overall_error = max - middle_func; + overall_error = max_func - middle_func; } else if (middle_func > 0) { max = middle; max_func = middle_func; - overall_error = max - middle_func; + overall_error = middle_func-min_func; } else { overall_error = 0; } @@ -124,10 +134,10 @@ void test1(method_t method) R_2 = lmm_variable_new(Sys, (void *) "R 2", 1.0, -1.0, 1); R_3 = lmm_variable_new(Sys, (void *) "R 3", 1.0, -1.0, 1); - lmm_update_variable_latency(Sys, R_1_2_3, 1.0); - lmm_update_variable_latency(Sys, R_1, 1.0); - lmm_update_variable_latency(Sys, R_2, 1.0); - lmm_update_variable_latency(Sys, R_3, 1.0); + lmm_update_variable_weight(Sys, R_1_2_3, 1.0); + lmm_update_variable_weight(Sys, R_1, 1.0); + lmm_update_variable_weight(Sys, R_2, 1.0); + lmm_update_variable_weight(Sys, R_3, 1.0); lmm_expand(Sys, L1, R_1_2_3, 1.0); lmm_expand(Sys, L2, R_1_2_3, 1.0); @@ -187,7 +197,7 @@ void test1(method_t method) a_test_1 = a; b_test_1 = b; - x = dichotomy(diff_lagrange_test_1, 0, a, 1e-8); + x = dichotomy(diff_lagrange_test_1, 0, a, 1e-13); if (x < 0) x = 0; @@ -253,8 +263,8 @@ void test2(method_t method) T1 = lmm_variable_new(Sys, (void *) "T1", 1.0, -1.0, 1); T2 = lmm_variable_new(Sys, (void *) "T2", 1.0, -1.0, 1); - lmm_update_variable_latency(Sys, T1, 1.0); - lmm_update_variable_latency(Sys, T2, 1.0); + lmm_update_variable_weight(Sys, T1, 1.0); + lmm_update_variable_weight(Sys, T2, 1.0); lmm_expand(Sys, CPU1, T1, 1.0); @@ -306,12 +316,12 @@ void test3(method_t method) 1, 1, 1, 1, 1 }; - - A = (double **) calloc(links + 5, sizeof(double)); + + /*A = xbt_new0(double*, links + 5);*/ + A = xbt_new0(double*, links + 5); for (i = 0; i < links + 5; i++) { - A[i] = (double *) calloc(flows + 5, sizeof(double)); - + A[i] = xbt_new0(double, flows + 5); for (j = 0; j < flows + 5; j++) { A[i][j] = 0.0; @@ -402,12 +412,12 @@ void test3(method_t method) - tmp_name = (char **) calloc(31, sizeof(char *)); + tmp_name = xbt_new0(char *,31); /* * Creates the constraints */ - tmp_cnst = calloc(15, sizeof(lmm_constraint_t)); + tmp_cnst = xbt_new0(lmm_constraint_t,15); for (i = 0; i < 15; i++) { tmp_name[i] = bprintf("C_%03d", i); tmp_cnst[i] = lmm_constraint_new(Sys, (void *) tmp_name[i], B[i]); @@ -417,12 +427,12 @@ void test3(method_t method) /* * Creates the variables */ - tmp_var = calloc(16, sizeof(lmm_variable_t)); + tmp_var = xbt_new0(lmm_variable_t,16); for (j = 0; j < 16; j++) { tmp_name[i + j] = bprintf("X_%03d", j); tmp_var[j] = lmm_variable_new(Sys, (void *) tmp_name[i + j], 1.0, -1.0, 15); - lmm_update_variable_latency(Sys, tmp_var[j], 1.0); + lmm_update_variable_weight(Sys, tmp_var[j], 1.0); } /*