+ overall_error=0;
+ DEBUG1("Iteration %d ", iteration);
+ xbt_swag_foreach(var, var_list) {
+ if(var->weight <=0)
+ var->value = 0.0;
+ else {
+ tmp = 0;
+ for(i=0; i<var->cnsts_number; i++){
+ tmp += (var->cnsts[i].constraint)->lambda;
+ if(var->bound > 0)
+ tmp+=var->mu;
+ }
+
+ //computes de overall_error
+ if(overall_error < fabs(var->value - 1.0/tmp)){
+ overall_error = fabs(var->value - 1.0/tmp);
+ }
+
+ var->value = 1.0 / tmp;
+ }
+
+
+ DEBUG2("======> value of var (%p) = %e", var, var->value);
+ }
+ }
+
+
+ //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;
+ }
+
+ tmp = tmp - cnst->bound;
+
+
+ if(tmp != 0 || cnst->lambda != 0){
+ WARN4("The link %s(%p) doesn't match the KKT property, value expected (=0) got (lambda=%e) (sum_rho=%e)", (char *)cnst->id, cnst, cnst->lambda, tmp);
+ }
+
+ }
+
+
+ //verify the KKT property of each flow
+ xbt_swag_foreach(var, var_list){
+ if(var->bound <= 0 || var->weight <= 0) continue;
+ tmp = 0;
+ tmp = (var->value - var->bound);
+
+
+ if(tmp != 0 || var->mu != 0){
+ WARN4("The flow %s(%p) doesn't match the KKT property, value expected (=0) got (lambda=%e) (sum_rho=%e)", (char *)var->id, var, var->mu, tmp);
+ }
+
+ }
+
+
+ if(overall_error <= epsilon_min_error){
+ DEBUG1("The method converge in %d iterations.", iteration);
+ }else{
+ WARN1("Method reach %d iterations, which is the maxmimun number of iterations allowed.", iteration);
+ }
+
+
+
+}
+
+/*
+ * Returns a double value corresponding to the result of a dicotomi proccess with
+ * respect to a given variable/constraint (\mu in the case of a variable or \lambda in
+ * case of a constraint) and a initial value init.
+ *
+ * @param init initial value for \mu or \lambda
+ * @param diff a function that computes the differential of with respect a \mu or \lambda
+ * @param var_cnst a pointer to a variable or constraint
+ * @param min_erro a minimun error tolerated
+ *
+ * @return a double correponding to the result of the dicotomial process
+ */
+double dicotomi(double init, double diff(double, void*), void *var_cnst, double min_error){
+ double min, max;
+ double overall_error;
+ double middle;
+
+ min = max = init;
+ overall_error = 1;
+
+ DEBUG0("STARTING DICOTOMI... Debuggin, format used [min, max], [D(min),D(max)]");
+
+ while(overall_error > min_error){
+ DEBUG4("====> [%e, %e] , [%e,%e]", min, max, diff(min, var_cnst), diff(max, var_cnst));
+
+ if( diff(min, var_cnst) > 0 && diff(max, var_cnst) > 0 ){
+ if(min == max){
+ min = min / 2.0;
+ }else{
+ max = min;
+ }
+ }else if( diff(min, var_cnst) < 0 && diff(max, var_cnst) < 0 ){
+ if(min == max){
+ max = max * 2.0;
+ }else{
+ min = max;
+ }
+ }else if( diff(min, var_cnst) < 0 && diff(max, var_cnst) > 0 ){
+ middle = (max + min)/2.0;
+
+ if( diff(middle, var_cnst) < 0 ){
+ min = middle;
+ }else if( diff(middle, var_cnst) > 0 ){
+ max = middle;
+ }else{
+ WARN0("Found an optimal solution with 0 error!");
+ overall_error = 0;