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;
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);
}
}
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);
}