Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
typo in unit test name
[simgrid.git] / src / surf / maxmin.c
index 250e3e7..37c7f5e 100644 (file)
@@ -183,7 +183,7 @@ lmm_variable_t lmm_variable_new(lmm_system_t sys, void *id,
   var->weight = weight;
   var->bound = bound;
   var->value = 0.0;
-  var->df = 0.0;
+
 
   var->func_f = func_f_def;
   var->func_fp = func_fp_def;
@@ -452,6 +452,7 @@ void lmm_solve(lmm_system_t sys)
   xbt_swag_t var_list = NULL;
   xbt_swag_t elem_list = NULL;
   double min_usage = -1;
+  double min_bound = -1;
 
   if (!(sys->modified))
     return;
@@ -514,8 +515,11 @@ void lmm_solve(lmm_system_t sys)
           var, var->bound, var->weight, min_usage,
           var->bound * var->weight);
       if ((var->bound > 0) && (var->bound * var->weight < min_usage)) {
-       min_usage = var->bound * var->weight;
-       DEBUG1("Updated min_usage=%f", min_usage);
+       if(min_bound<0)
+         min_bound = var->bound;
+       else
+         min_bound = MIN(min_bound,var->bound);
+       DEBUG1("Updated min_bound=%f", min_bound);
       }
     }
 
@@ -523,7 +527,16 @@ void lmm_solve(lmm_system_t sys)
     while ((var = xbt_swag_getFirst(var_list))) {
       int i;
 
-      var->value = min_usage / var->weight;
+      if(min_bound<0) {
+       var->value = min_usage / var->weight;
+      } else {
+       if(min_bound == var->bound)
+         var->value = var->bound;
+       else {
+         xbt_swag_remove(var, var_list);
+         continue;
+       }
+      }
       DEBUG5("Min usage: %f, Var(%p)->weight: %f, Var(%p)->value: %f ",
             min_usage, var, var->weight, var, var->value);
 
@@ -560,6 +573,7 @@ void lmm_solve(lmm_system_t sys)
     /* Find out which variables reach the maximum */
     cnst_list = &(sys->active_constraint_set);
     min_usage = -1;
+    min_bound = -1;
     xbt_swag_foreach(cnst, cnst_list) {
       saturated_constraint_set_update(sys, cnst, &min_usage);
     }
@@ -607,24 +621,6 @@ void lmm_update_variable_bound(lmm_system_t sys, lmm_variable_t var,
   var->bound = bound;
 }
 
-/** \brief Add the value delta to var->df (the sum of latencies).
- * 
- *  \param sys the lmm_system_t associated
- *  \param var the lmm_variable_t which need to updated
- *  \param delta the variation of the latency
- * 
- *  Add the value delta to var->df (the sum of latencys associated to the
- *  flow). Whenever this function is called a change is  signed in the system. To
- *  avoid false system changing detection it is a good idea to test 
- *  (delta != 0) before calling it.
- *
- */
-void lmm_update_variable_latency(lmm_system_t sys, lmm_variable_t var,
-                                double delta)
-{
-  sys->modified = 1;
-  var->df += delta;
-}
 
 void lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var,
                                double weight)