+static int __check_kkt(xbt_swag_t cnst_list, xbt_swag_t var_list, int warn)
+{
+ xbt_swag_t elem_list = NULL;
+ lmm_element_t elem = NULL;
+ lmm_constraint_t cnst = NULL;
+ lmm_variable_t var = NULL;
+
+ double tmp;
+
+ //verify the KKT property for each link
+ xbt_swag_foreach(cnst, cnst_list) {
+ tmp = 0;
+ elem_list = &(cnst->element_set);
+ xbt_swag_foreach(elem, elem_list) {
+ var = elem->variable;
+ if (var->weight <= 0)
+ continue;
+ tmp += var->value;
+ }
+
+ if (double_positive(tmp - cnst->bound)) {
+ if (warn)
+ WARN3
+ ("The link (%p) is over-used. Expected less than %f and got %f",
+ cnst, cnst->bound, tmp);
+ return 0;
+ }
+ DEBUG3("Checking KKT for constraint (%p): sat = %f, lambda = %f ",
+ cnst, tmp - cnst->bound, cnst->lambda);
+ }
+
+ //verify the KKT property of each flow
+ xbt_swag_foreach(var, var_list) {
+ if (var->bound < 0 || var->weight <= 0)
+ continue;
+ DEBUG3("Checking KKT for variable (%p): sat = %f mu = %f", var,
+ var->value - var->bound, var->mu);
+
+ if (double_positive(var->value - var->bound)) {
+ if (warn)
+ WARN3
+ ("The variable (%p) is too large. Expected less than %f and got %f",
+ var, var->bound, var->value);
+ return 0;
+ }
+ }
+ return 1;
+}
+