Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The default alias name is now build from the name of the host of the process and...
[simgrid.git] / src / surf / lagrange.c
index 62f2516..479a91a 100644 (file)
@@ -9,7 +9,6 @@
  */
 #include "xbt/log.h"
 #include "xbt/sysdep.h"
-#include "xbt/mallocator.h"
 #include "maxmin_private.h"
 
 #include <stdlib.h>
@@ -220,6 +219,7 @@ void lagrange_solve(lmm_system_t sys)
     if (!var->weight)
       var->value = 0.0;
     else {
+      int nb = 0;
       if (var->bound < 0.0) {
        DEBUG1("#### NOTE var(%d) is a boundless variable", i);
        var->mu = -1.0;
@@ -229,11 +229,14 @@ void lagrange_solve(lmm_system_t sys)
        var->new_mu = 2.0;
        var->value = new_value(var);
       }
-      DEBUG3("#### var(%d) %p ->df :  %e", i, var, var->df);
-      DEBUG3("#### var(%d) %p ->mu :  %e", i, var, var->mu);
-      DEBUG3("#### var(%d) %p ->weight: %e", i, var, var->weight);
-      DEBUG3("#### var(%d) %p ->bound: %e", i, var, var->bound);
-      i++;
+      DEBUG2("#### var(%p) ->df :  %e", var, var->df);
+      DEBUG2("#### var(%p) ->mu :  %e", var, var->mu);
+      DEBUG2("#### var(%p) ->weight: %e", var, var->weight);
+      DEBUG2("#### var(%p) ->bound: %e", var, var->bound);
+      for (i = 0; i < var->cnsts_number; i++) {
+       if(var->cnsts[i].value==0.0) nb++;
+      }
+      if(nb==var->cnsts_number) var->value = 1.0;
     }
   }
 
@@ -605,3 +608,37 @@ double func_reno_fpi(lmm_variable_t var, double x)
 /*   xbt_assert0(res_fpi>0.0,"Don't call me with stupid values!"); */
   return sqrt(res_fpi);
 }
+
+
+/* Implementing new Reno-2
+ * For Reno-2:  $f(x)   = U_f(x_f) = \frac{{2}{D_f}}*ln(2+x*D_f)$
+ * Therefore:   $fp(x)  = 2/(Df*x + 2)
+ * Therefore:   $fpi(x) = (2*Df)/x - 4
+ */
+#define RENO2_SCALING 1.0
+double func_reno2_f(lmm_variable_t var, double x)
+{
+  xbt_assert0(var->df > 0.0, "Don't call me with stupid values!");
+  return RENO2_SCALING * (1.0/var->df) * log((x*var->df)/(2.0*x*var->df+3.0));
+}
+
+double func_reno2_fp(lmm_variable_t var, double x)
+{
+  return RENO2_SCALING * 3.0/(var->df*x*(2.0*var->df*x+3.0));
+}
+
+double func_reno2_fpi(lmm_variable_t var, double x)
+{
+  double res_fpi;
+  double tmp;
+
+  xbt_assert0(x > 0.0, "Don't call me with stupid values!");
+  tmp= x*var->df*var->df;
+  res_fpi= tmp*(9.0*x+24.0);
+  
+  if (res_fpi <= 0.0)
+    return 0.0;
+
+  res_fpi = RENO2_SCALING * (-3.0*tmp + sqrt(res_fpi))/(4.0*tmp);
+  return res_fpi;
+}