Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix the bug raised by Tchimou.
[simgrid.git] / src / surf / maxmin.c
index 6c2fd6c..61be934 100644 (file)
@@ -126,6 +126,11 @@ void lmm_constraint_shared(lmm_constraint_t cnst)
   cnst->shared = 0;
 }
 
+int lmm_constraint_is_shared(lmm_constraint_t cnst)
+{
+  return (cnst->shared);
+}
+
 void lmm_constraint_free(lmm_system_t sys, lmm_constraint_t cnst)
 {
   remove_constraint(sys, cnst);
@@ -241,9 +246,10 @@ void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst,
     if (var->cnsts[i].constraint == cnst)
       break;
 
-  if (i < var->cnsts_number)
-    var->cnsts[i].value += value;
-  else
+  if (i < var->cnsts_number) {
+    if(cnst->shared) var->cnsts[i].value += value;
+    else var->cnsts[i].value = MAX(var->cnsts[i].value,value);
+  }  else
     lmm_expand(sys, cnst, var, value);
 }
 
@@ -456,6 +462,7 @@ void lmm_solve(lmm_system_t sys)
   xbt_swag_foreach(var, var_list) {
     int nb=0;
     int i;
+    if(var->weight<=0.0) break;
     var->value = 0.0;
     for (i = 0; i < var->cnsts_number; i++) {
       if(var->cnsts[i].value==0.0) nb++;
@@ -499,6 +506,7 @@ void lmm_solve(lmm_system_t sys)
     var_list = &(sys->saturated_variable_set);
 
     xbt_swag_foreach(var, var_list) {
+      if(var->weight<=0.0) DIE_IMPOSSIBLE;
       /* First check if some of these variables have reach their upper
          bound and update min_usage accordingly. */
       DEBUG5
@@ -642,6 +650,9 @@ void lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var,
     else
       xbt_swag_insert_at_tail(elem, &(elem->constraint->element_set));
   }
+  if(!weight)
+    var->value = 0.0;
+
   XBT_OUT;
 }