+static double partial_diff_lambda(double lambda, void *param_cnst);
+
+static int __check_feasible(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;
+
+ 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 feasability for constraint (%p): sat = %f, lambda = %f ",
+ cnst, tmp - cnst->bound, cnst->lambda);
+ }
+
+ xbt_swag_foreach(var, var_list) {
+ if (!var->weight)
+ break;
+ if (var->bound < 0)
+ continue;
+ DEBUG3("Checking feasability 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;
+}
+
+static double new_value(lmm_variable_t var)
+{
+ double tmp = 0;
+ int i;
+
+ for (i = 0; i < var->cnsts_number; i++) {
+ tmp += (var->cnsts[i].constraint)->lambda;
+ }
+ if (var->bound > 0)
+ tmp += var->mu;
+ DEBUG3("\t Working on var (%p). cost = %e; Weight = %e", var, tmp,
+ var->weight);
+ //uses the partial differential inverse function
+ return var->func_fpi(var, tmp);
+}
+
+static double new_mu(lmm_variable_t var)
+{
+ double mu_i = 0.0;
+ double sigma_i = 0.0;
+ int j;
+
+ for (j = 0; j < var->cnsts_number; j++) {
+ sigma_i += (var->cnsts[j].constraint)->lambda;
+ }
+ mu_i = var->func_fp(var, var->bound) - sigma_i;
+ if (mu_i < 0.0)
+ return 0.0;
+ return mu_i;
+}
+
+static double dual_objective(xbt_swag_t var_list, xbt_swag_t cnst_list)
+{
+ lmm_constraint_t cnst = NULL;
+ lmm_variable_t var = NULL;
+
+ double obj = 0.0;
+
+ xbt_swag_foreach(var, var_list) {
+ double sigma_i = 0.0;
+ int j;