Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Distinguish between time precision and sharing precision.
[simgrid.git] / testsuite / surf / lmm_usage.c
index 586cd8c..060ed25 100644 (file)
@@ -1,6 +1,6 @@
 /* A few tests for the maxmin library                                       */
 
-/* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2007-2014. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test,
 typedef enum {
   MAXMIN,
   LAGRANGE_RENO,
-  LAGRANGE_VEGAS,
+  LAGRANGE_VEGAS
 } method_t;
 
 static double dichotomy(double func(double), double min, double max,
@@ -122,7 +122,7 @@ void test1(method_t method)
     lmm_set_default_protocol_function(func_reno_f, func_reno_fpi,
                                       func_reno_fpi);
 
-  Sys = lmm_system_new();
+  Sys = lmm_system_new(1);
   L1 = lmm_constraint_new(Sys, (void *) "L1", a);
   L2 = lmm_constraint_new(Sys, (void *) "L2", b);
   L3 = lmm_constraint_new(Sys, (void *) "L3", a);
@@ -173,7 +173,7 @@ void test1(method_t method)
     max_deviation =
         MAX(max_deviation, fabs(lmm_variable_getvalue(R_1_2_3) - (a - x)));
 
-    if (max_deviation > MAXMIN_PRECISION) {
+    if (max_deviation > 0.00001) { // Legacy value used in lagrange.c
       XBT_WARN("Max Deviation from optimal solution : %g", max_deviation);
       XBT_WARN("Found x = %1.20f", x);
       XBT_WARN("Deviation from optimal solution (R_1 = %g): %1.20f", x,
@@ -208,7 +208,7 @@ void test1(method_t method)
     max_deviation =
         MAX(max_deviation, fabs(lmm_variable_getvalue(R_1_2_3) - (a - x)));
 
-    if (max_deviation > MAXMIN_PRECISION) {
+    if (max_deviation > 0.00001) { // Legacy value used in lagrange.c
       XBT_WARN("Max Deviation from optimal solution : %g", max_deviation);
       XBT_WARN("Found x = %1.20f", x);
       XBT_WARN("Deviation from optimal solution (R_1 = %g): %1.20f", x,
@@ -229,6 +229,10 @@ void test1(method_t method)
   PRINT_VAR(R_2);
   PRINT_VAR(R_3);
 
+  lmm_variable_free(Sys, R_1_2_3);
+  lmm_variable_free(Sys, R_1);
+  lmm_variable_free(Sys, R_2);
+  lmm_variable_free(Sys, R_3);
   lmm_system_free(Sys);
 }
 
@@ -250,7 +254,7 @@ void test2(method_t method)
     lmm_set_default_protocol_function(func_reno_f, func_reno_fp,
                                       func_reno_fpi);
 
-  Sys = lmm_system_new();
+  Sys = lmm_system_new(1);
   CPU1 = lmm_constraint_new(Sys, (void *) "CPU1", 200.0);
   CPU2 = lmm_constraint_new(Sys, (void *) "CPU2", 100.0);
 
@@ -279,6 +283,8 @@ void test2(method_t method)
   PRINT_VAR(T1);
   PRINT_VAR(T2);
 
+  lmm_variable_free(Sys, T1);
+  lmm_variable_free(Sys, T2);
   lmm_system_free(Sys);
 }
 
@@ -397,7 +403,7 @@ void test3(method_t method)
     lmm_set_default_protocol_function(func_reno_f, func_reno_fp,
                                       func_reno_fpi);
 
-  Sys = lmm_system_new();
+  Sys = lmm_system_new(1);
 
 
 
@@ -451,6 +457,8 @@ void test3(method_t method)
     PRINT_VAR(tmp_var[j]);
   }
 
+  for (j = 0; j < 16; j++)
+    lmm_variable_free(Sys, tmp_var[j]);
   xbt_free(tmp_var);
   xbt_free(tmp_cnst);
   for (i = 0; i < 31; i++)