Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics in debug messages
[simgrid.git] / src / surf / maxmin.cpp
index d30d207..7152a9e 100644 (file)
@@ -48,7 +48,7 @@ lmm_system_t lmm_system_new(int selective_update)
   l->selective_update_active = selective_update;
   l->visited_counter = 1;
 
-  XBT_DEBUG("Setting selective_update_active flag to %d\n",
+  XBT_DEBUG("Setting selective_update_active flag to %d",
          l->selective_update_active);
 
   xbt_swag_init(&(l->variable_set),
@@ -431,6 +431,31 @@ lmm_variable_t lmm_get_var_from_cnst(lmm_system_t /*sys*/,
     return NULL;
 }
 
+//if we modify the swag between calls, normal version may loop forever
+//this safe version ensures that we browse the swag elements only once
+lmm_variable_t lmm_get_var_from_cnst_safe(lmm_system_t /*sys*/,
+                                     lmm_constraint_t cnst,
+                                     lmm_element_t * elem,
+                                     lmm_element_t * nextelem,
+                                     int * numelem)
+{
+  if (!(*elem)){
+    *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->element_set));
+    *numelem = xbt_swag_size(&(cnst->element_set))-1;
+  }else{
+    *elem = *nextelem;
+    if(*numelem>0){
+     (*numelem) --;
+    }else
+      return NULL;
+  }
+  if (*elem){
+    *nextelem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->element_set.offset);
+    return (*elem)->variable;
+  }else
+    return NULL;
+}
+
 void *lmm_constraint_id(lmm_constraint_t cnst)
 {
   return cnst->id;
@@ -651,7 +676,7 @@ void lmm_solve(lmm_system_t sys)
           cnst->usage = elem->value / elem->variable->weight;
 
         make_elem_active(elem);
-        ActionPtr action = static_cast<ActionPtr>(elem->variable->id);
+        Action *action = static_cast<Action*>(elem->variable->id);
         if (sys->keep_track && !action->is_linked())
           sys->keep_track->push_back(*action);
       }
@@ -692,9 +717,9 @@ void lmm_solve(lmm_system_t sys)
            var->bound * var->weight);
       if ((var->bound > 0) && (var->bound * var->weight < min_usage)) {
         if (min_bound < 0)
-          min_bound = var->bound;
+          min_bound = var->bound*var->weight;
         else
-          min_bound = MIN(min_bound, var->bound);
+          min_bound = MIN(min_bound, (var->bound*var->weight));
         XBT_DEBUG("Updated min_bound=%f", min_bound);
       }
     }
@@ -709,7 +734,7 @@ void lmm_solve(lmm_system_t sys)
         XBT_DEBUG("Setting %p (%d) value to %f\n", var, var->id_int, var->value);
       } else {
        //If there exist a variable that can reach its bound, only update it (and other with the same bound) for now.
-        if (min_bound == var->bound) {
+           if (double_equals(min_bound, var->bound*var->weight, sg_maxmin_precision)){
           var->value = var->bound;
           XBT_DEBUG("Setting %p (%d) value to %f\n", var, var->id_int, var->value);
         }
@@ -785,7 +810,7 @@ void lmm_solve(lmm_system_t sys)
     saturated_constraint_set->pos = 0;
     int pos;
     for(pos=0; pos<cnst_light_num; pos++){
-       xbt_assert(cnst_light_tab[pos].cnst->active_element_set.count>0, "Cannot saturate more a constraint that has no active element! You want to check the maxmin precision and possible rounding effects." );
+      xbt_assert(cnst_light_tab[pos].cnst->active_element_set.count>0, "Cannot saturate more a constraint that has no active element! You may want to change the maxmin precision (--cfg=maxmin/precision:<new_value>) because of possible rounding effects.\n\tFor the record, the usage of this constraint is %g while the maxmin precision to which it is compared is %g.\n\tThe usage of the previous constraint is %g.", cnst_light_tab[pos].cnst->usage, sg_maxmin_precision, cnst_light_tab[pos-1].cnst->usage);
       saturated_constraint_set_update(
           cnst_light_tab[pos].remaining_over_usage,
           pos,