-/* Copyright (c) 2004-2013. The SimGrid Team.
+/* Copyright (c) 2004-2014. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-
#include "xbt/sysdep.h"
#include "xbt/log.h"
#include "xbt/mallocator.h"
} s_dyn_light_t, *dyn_light_t;
XBT_EXPORT_NO_IMPORT(double) sg_maxmin_precision = 0.00001;
+XBT_EXPORT_NO_IMPORT(double) sg_surf_precision = 0.00001;
static void *lmm_variable_mallocator_new_f(void);
static void lmm_variable_mallocator_free_f(void *var);
return (var->value);
}
-XBT_INLINE double lmm_variable_getbound(lmm_variable_t var)
+double lmm_variable_getbound(lmm_variable_t var)
{
return (var->bound);
}
sys->modified = 1;
- XBT_DEBUG("remove elem(value %lf, cnst %p, var %p) in var %p",
+ XBT_DEBUG("remove elem(value %f, cnst %p, var %p) in var %p",
elem->value, elem->constraint, elem->variable, var);
lmm_expand(sys, cnst, var, value);
}
-void lmm_elem_set_value(lmm_system_t sys, lmm_constraint_t cnst,
- lmm_variable_t var, double value)
-{
- int i;
-
- for (i = 0; i < var->cnsts_number; i++)
- if (var->cnsts[i].constraint == cnst)
- break;
-
- if (i < var->cnsts_number) {
- var->cnsts[i].value = value;
- sys->modified = 1;
- lmm_update_modified_set(sys, cnst);
- } else
- DIE_IMPOSSIBLE;
-}
-
lmm_constraint_t lmm_get_cnst_from_var(lmm_system_t /*sys*/,
lmm_variable_t var,
int num)
}
XBT_DEBUG("%s", trace_buf);
trace_buf[0] = '\000';
- xbt_assert(!double_positive(sum - cnst->bound),
+ xbt_assert(!double_positive(sum - cnst->bound, sg_maxmin_precision),
"Incorrect value (%f is not smaller than %f): %g",
sum, cnst->bound, sum - cnst->bound);
}
if (var->bound > 0) {
XBT_DEBUG("'%d'(%f) : %f (<=%f)", var->id_int, var->weight, var->value,
var->bound);
- xbt_assert(!double_positive(var->value - var->bound),
+ xbt_assert(!double_positive(var->value - var->bound, sg_maxmin_precision),
"Incorrect value (%f is not smaller than %f",
var->value, var->bound);
} else {
cnst->usage = elem->value / elem->variable->weight;
make_elem_active(elem);
- ActionLmmPtr action = static_cast<ActionLmmPtr>(elem->variable->id);
+ ActionPtr action = static_cast<ActionPtr>(elem->variable->id);
if (sys->keep_track && !action->is_linked())
sys->keep_track->push_back(*action);
}
if (min_bound < 0) {
var->value = min_usage / var->weight;
+ XBT_DEBUG("Setting %p (%d) value to %f\n", var, var->id_int, var->value);
} else {
- if (min_bound == var->bound)
+ if (min_bound == var->bound) {
var->value = var->bound;
+ XBT_DEBUG("Setting %p (%d) value to %f\n", var, var->id_int, var->value);
+ }
else {
+ XBT_DEBUG("Do not consider %p (%d)\n", var, var->id_int);
xbt_swag_remove(var, var_list);
continue;
}
elem = &var->cnsts[i];
cnst = elem->constraint;
if (cnst->shared) {
- double_update(&(cnst->remaining), elem->value * var->value);
- double_update(&(cnst->usage), elem->value / var->weight);
+ double_update(&(cnst->remaining), elem->value * var->value, sg_maxmin_precision);
+ double_update(&(cnst->usage), elem->value / var->weight, sg_maxmin_precision);
if(cnst->usage<=0 || cnst->remaining<=0) {
if (cnst->cnst_light) {
int index = (cnst->cnst_light-cnst_light_tab);
elem_list = &(cnst->element_set);
xbt_swag_foreach(_elem, elem_list) {
elem = (lmm_element_t)_elem;
- if (elem->variable->weight <= 0 || elem->variable->value > 0)
- break;
+ if (elem->variable->weight <= 0) break;
+ if (elem->variable->value > 0) continue;
if (elem->value > 0)
cnst->usage = MAX(cnst->usage, elem->value / elem->variable->weight);
}
#ifdef HAVE_LATENCY_BOUND_TRACKING
XBT_INLINE int lmm_is_variable_limited_by_latency(lmm_variable_t var)
{
- return (double_equals(var->bound, var->value));
+ return (double_equals(var->bound, var->value, sg_maxmin_precision));
}
#endif