-revert of address_bw addition
[oweals/gnunet.git] / src / ats / plugin_ats_mlp.c
index 7dd31edf5c76f8a61d55d1470080c470b8318486..1b87fe119b9c3cb1d67ca249a7af9ca93ae7bda0 100644 (file)
@@ -81,7 +81,7 @@
  *    adapted using configuration settings and uses the following parameters:
  *      * MLP_MAX_DURATION:
  *        Maximum duration for a MLP solution procees (default: 3 sec.)
- *      * MLP_MAX_DURATION:
+ *      * MLP_MAX_ITERATIONS:
  *        Maximum number of iterations for a MLP solution process (default:
  *        1024)
  *      * MLP_MIN_CONNECTIONS:
  */
 #define DEBUG_MLP_PROBLEM_CREATION GNUNET_NO
 
-/**
- * Enable GLPK verbose output
- */
-#define VERBOSE_GLPK GNUNET_NO
 
 /**
  * Maximize bandwidth assigned
@@ -161,7 +157,7 @@ static int
 mlp_term_hook (void *info, const char *s)
 {
   /* Not needed atm struct MLP_information *mlp = info; */
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "%s", s);
+  LOG (GNUNET_ERROR_TYPE_ERROR, "%s", s);
   return 1;
 }
 
@@ -390,7 +386,7 @@ get_performance_info (struct ATS_Address *address, uint32_t type)
 
 struct CountContext
 {
-  const struct GNUNET_CONTAINER_MultiPeerMap *peers;
+  const struct GNUNET_CONTAINER_MultiPeerMap *map;
   int result;
 };
 
@@ -402,22 +398,50 @@ mlp_create_problem_count_addresses_it (void *cls,
   struct CountContext *cctx = cls;
 
   /* Check if we have to add this peer due to a pending request */
-  if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (cctx->peers, key))
+  if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (cctx->map, key))
     cctx->result++;
   return GNUNET_OK;
 }
 
 
 static int
-mlp_create_problem_count_addresses (const struct GNUNET_CONTAINER_MultiPeerMap *peers,
+mlp_create_problem_count_addresses (const struct GNUNET_CONTAINER_MultiPeerMap *requested_peers,
                                    const struct GNUNET_CONTAINER_MultiPeerMap *addresses)
 {
   struct CountContext cctx;
 
-  cctx.peers = peers;
+  cctx.map = requested_peers;
   cctx.result = 0;
   GNUNET_CONTAINER_multipeermap_iterate (addresses,
-                                        &mlp_create_problem_count_addresses_it, &cctx);
+           &mlp_create_problem_count_addresses_it, &cctx);
+  return cctx.result;
+}
+
+
+static int
+mlp_create_problem_count_peers_it (void *cls,
+                                   const struct GNUNET_PeerIdentity *key,
+                                   void *value)
+{
+  struct CountContext *cctx = cls;
+
+  /* Check if we have to addresses for the requested peer */
+  if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (cctx->map, key))
+    cctx->result++;
+  return GNUNET_OK;
+}
+
+
+static int
+mlp_create_problem_count_peers (const struct GNUNET_CONTAINER_MultiPeerMap *requested_peers,
+    const struct GNUNET_CONTAINER_MultiPeerMap *addresses)
+{
+  struct CountContext cctx;
+
+  cctx.map = addresses;
+  cctx.result = 0;
+  GNUNET_CONTAINER_multipeermap_iterate (requested_peers,
+           &mlp_create_problem_count_peers_it, &cctx);
   return cctx.result;
 }
 
@@ -835,7 +859,7 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp)
   /* create the glpk problem */
   p->prob = glp_create_prob ();
   GNUNET_assert (NULL != p->prob);
-  p->num_peers = GNUNET_CONTAINER_multipeermap_size (mlp->requested_peers);
+  p->num_peers = mlp_create_problem_count_peers (mlp->requested_peers, mlp->addresses);
   p->num_addresses = mlp_create_problem_count_addresses (mlp->requested_peers, mlp->addresses);
 
   /* Create problem matrix: 10 * #addresses + #q * #addresses + #q, + #peer + 2 + 1 */
@@ -1099,7 +1123,8 @@ GAS_mlp_solve_problem (void *solver)
   int res_lp = 0;
   int res_mip = 0;
 
-  struct GNUNET_TIME_Absolute start;
+  struct GNUNET_TIME_Absolute start_total;
+  struct GNUNET_TIME_Absolute start_cur_op;
   struct GNUNET_TIME_Relative dur_total;
   struct GNUNET_TIME_Relative dur_setup;
   struct GNUNET_TIME_Relative dur_lp;
@@ -1107,14 +1132,14 @@ GAS_mlp_solve_problem (void *solver)
 
   GNUNET_assert(NULL != solver);
 
-  if (GNUNET_YES == mlp->bulk_lock)
+  if (GNUNET_YES == mlp->stat_bulk_lock)
     {
-      mlp->bulk_request++;
+      mlp->stat_bulk_requests++;
       return GNUNET_NO;
     }
   notify(mlp, GAS_OP_SOLVE_START, GAS_STAT_SUCCESS,
-      (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
-  start = GNUNET_TIME_absolute_get();
+      (GNUNET_YES == mlp->stat_mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
+  start_total = GNUNET_TIME_absolute_get();
 
   if (0 == GNUNET_CONTAINER_multipeermap_size(mlp->requested_peers))
     {
@@ -1127,14 +1152,14 @@ GAS_mlp_solve_problem (void *solver)
       return GNUNET_OK; /* No addresses available */
     }
 
-  if ((GNUNET_NO == mlp->mlp_prob_changed)
-      && (GNUNET_NO == mlp->mlp_prob_updated))
+  if ((GNUNET_NO == mlp->stat_mlp_prob_changed)
+      && (GNUNET_NO == mlp->stat_mlp_prob_updated))
     {
       LOG(GNUNET_ERROR_TYPE_DEBUG, "No changes to problem\n");
       notify(mlp, GAS_OP_SOLVE_STOP, GAS_STAT_SUCCESS, GAS_INFO_NONE);
       return GNUNET_OK;
     }
-  if (GNUNET_YES == mlp->mlp_prob_changed)
+  if (GNUNET_YES == mlp->stat_mlp_prob_changed)
     {
       LOG(GNUNET_ERROR_TYPE_DEBUG, "Problem size changed, rebuilding\n");
       notify(mlp, GAS_OP_SOLVE_SETUP_START, GAS_STAT_SUCCESS, GAS_INFO_FULL);
@@ -1153,43 +1178,64 @@ GAS_mlp_solve_problem (void *solver)
       LOG(GNUNET_ERROR_TYPE_DEBUG, "Problem was updated, resolving\n");
     }
 
-  dur_setup = GNUNET_TIME_absolute_get_duration (start);
-  mlp->control_param_lp.presolve = GLP_YES;
-  /* Run LP solver */
+  dur_setup = GNUNET_TIME_absolute_get_duration (start_total);
 
+  /* Run LP solver */
   notify(mlp, GAS_OP_SOLVE_MLP_LP_START, GAS_STAT_SUCCESS,
-      (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
+      (GNUNET_YES == mlp->stat_mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
   LOG(GNUNET_ERROR_TYPE_DEBUG,
       "Running LP solver %s\n",
       (GLP_YES == mlp->control_param_lp.presolve)? "with presolver": "without presolver");
+  start_cur_op = GNUNET_TIME_absolute_get();
+
+  /* Solve LP */
+  mlp->control_param_lp.presolve = GLP_YES;
   res_lp = mlp_solve_lp_problem(mlp);
+
+  dur_lp = GNUNET_TIME_absolute_get_duration (start_cur_op);
   notify(mlp, GAS_OP_SOLVE_MLP_LP_STOP,
       (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL,
-      (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
+      (GNUNET_YES == mlp->stat_mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
 
-  dur_lp = GNUNET_TIME_absolute_get_duration (start);
-  dur_lp = GNUNET_TIME_relative_subtract(dur_lp, dur_setup);
 
   /* Run MLP solver */
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "Running MLP solver \n");
-  notify(mlp, GAS_OP_SOLVE_MLP_MLP_START, GAS_STAT_SUCCESS,
-      (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
-  res_mip = mlp_solve_mlp_problem(mlp);
-  notify(mlp, GAS_OP_SOLVE_MLP_MLP_STOP,
-      (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL,
-      (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
-  notify(mlp, GAS_OP_SOLVE_STOP,
-      (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL,
-      (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
+  if (GNUNET_OK == res_lp)
+  {
+    LOG(GNUNET_ERROR_TYPE_DEBUG, "Running MLP solver \n");
+    notify(mlp, GAS_OP_SOLVE_MLP_MLP_START, GAS_STAT_SUCCESS,
+        (GNUNET_YES == mlp->stat_mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
+    start_cur_op = GNUNET_TIME_absolute_get();
 
-  dur_mlp = GNUNET_TIME_absolute_get_duration (start);
-  dur_mlp = GNUNET_TIME_relative_subtract(dur_mlp, dur_setup);
-  dur_mlp = GNUNET_TIME_relative_subtract(dur_mlp, dur_lp);
-  dur_total = GNUNET_TIME_absolute_get_duration (start);
+    /* Solve MIP */
+    //mlp->control_param_mlp.presolve = GNUNET_YES;
+    res_mip = mlp_solve_mlp_problem(mlp);
+
+    dur_mlp = GNUNET_TIME_absolute_get_duration (start_cur_op);
+    dur_total = GNUNET_TIME_absolute_get_duration (start_total);
+
+    notify(mlp, GAS_OP_SOLVE_MLP_MLP_STOP,
+        (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL,
+        (GNUNET_YES == mlp->stat_mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
+  }
+  else
+  {
+    /* Do not execute mip solver since lp solution is invalid */
+    dur_mlp = GNUNET_TIME_UNIT_ZERO;
+    dur_total = GNUNET_TIME_absolute_get_duration (start_total);
+    notify(mlp, GAS_OP_SOLVE_MLP_MLP_STOP, GAS_STAT_FAIL,
+        (GNUNET_YES == mlp->stat_mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
+    res_mip = GNUNET_SYSERR;
+  }
+
+
+  /* Notify about end */
+  notify(mlp, GAS_OP_SOLVE_STOP,
+      ((GNUNET_OK == res_mip) && (GNUNET_OK == res_mip)) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL,
+      (GNUNET_YES == mlp->stat_mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
       "Execution time for %s solve: (total/setup/lp/mlp) : %llu %llu %llu %llu\n",
-      (GNUNET_YES == mlp->mlp_prob_changed) ? "full" : "updated",
+      (GNUNET_YES == mlp->stat_mlp_prob_changed) ? "full" : "updated",
       (unsigned long long) dur_total.rel_value_us,
       (unsigned long long) dur_setup.rel_value_us,
       (unsigned long long) dur_lp.rel_value_us,
@@ -1218,29 +1264,31 @@ GAS_mlp_solve_problem (void *solver)
       GAS_INFO_NONE);
 
   struct GNUNET_TIME_Absolute time = GNUNET_TIME_absolute_get();
-  if (GNUNET_YES == mlp->write_mip_mps)
+  if ( (GNUNET_YES == mlp->opt_dump_solution_all) ||
+      (mlp->opt_dump_solution_on_fail && ((GNUNET_OK != res_lp) || (GNUNET_OK != res_mip))) )
     {
       /* Write problem to disk */
-      GNUNET_asprintf(&filename, "problem_p_%u_a%u_%llu.mps", mlp->p.num_peers,
+      GNUNET_asprintf(&filename, "problem_p_%u_a%u_%llu.lp", mlp->p.num_peers,
           mlp->p.num_addresses, time.abs_value_us);
-      LOG(GNUNET_ERROR_TYPE_ERROR, "DUMP: %s \n", filename);
-      glp_write_lp(mlp->p.prob, NULL, filename);
-      GNUNET_free(filename);
-    }
-  if (GNUNET_YES == mlp->write_mip_sol)
-    {
-      /* Write solution to disk */
-      GNUNET_asprintf(&filename, "problem_p_%u_a%u_%llu.sol", mlp->p.num_peers,
-          mlp->p.num_addresses, time.abs_value_us);
-      glp_print_mip(mlp->p.prob, filename);
-      LOG(GNUNET_ERROR_TYPE_ERROR, "DUMP: %s \n", filename);
+      LOG(GNUNET_ERROR_TYPE_ERROR, "Dumped problem to file: `%s' \n", filename);
+      glp_write_lp (mlp->p.prob, NULL, filename);
       GNUNET_free(filename);
     }
+  if ( (mlp->opt_dump_solution_all) ||
+      (mlp->opt_dump_solution_on_fail && ((GNUNET_OK != res_lp) || (GNUNET_OK != res_mip))) )
+  {
+    /* Write solution to disk */
+    GNUNET_asprintf(&filename, "problem_p_%u_a%u_%llu.sol", mlp->p.num_peers,
+        mlp->p.num_addresses, time.abs_value_us);
+    glp_print_mip(mlp->p.prob, filename);
+    LOG(GNUNET_ERROR_TYPE_ERROR, "Dumped solution to file: `%s' \n", filename);
+    GNUNET_free(filename);
+  }
 
   /* Reset change and update marker */
   mlp->control_param_lp.presolve = GLP_NO;
-  mlp->mlp_prob_updated = GNUNET_NO;
-  mlp->mlp_prob_changed = GNUNET_NO;
+  mlp->stat_mlp_prob_updated = GNUNET_NO;
+  mlp->stat_mlp_prob_changed = GNUNET_NO;
 
   if ((GNUNET_OK == res_lp) && (GNUNET_OK == res_mip))
     return GNUNET_OK;
@@ -1291,8 +1339,8 @@ GAS_mlp_address_add (void *solver,
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding address for peer `%s' with address request \n", GNUNET_i2s(&address->peer));
   /* Problem size changed: new address for peer with pending request */
-  mlp->mlp_prob_changed = GNUNET_YES;
-  if (GNUNET_YES == mlp->mlp_auto_solve)
+  mlp->stat_mlp_prob_changed = GNUNET_YES;
+  if (GNUNET_YES == mlp->opt_mlp_auto_solve)
     GAS_mlp_solve_problem (solver);
 }
 
@@ -1363,8 +1411,8 @@ GAS_mlp_address_property_changed (void *solver,
   if (GNUNET_YES == mlp_create_problem_update_value (&mlp->p,
       mlp->p.r_q[type_index], mlpi->c_b, rel_value, __LINE__))
   {
-    mlp->mlp_prob_updated = GNUNET_YES;
-    if (GNUNET_YES == mlp->mlp_auto_solve)
+    mlp->stat_mlp_prob_updated = GNUNET_YES;
+    if (GNUNET_YES == mlp->opt_mlp_auto_solve)
       GAS_mlp_solve_problem (solver);
   }
 }
@@ -1510,7 +1558,7 @@ GAS_mlp_address_change_network (void *solver,
     }
   }
 
-  mlp->mlp_prob_changed = GNUNET_YES;
+  mlp->stat_mlp_prob_changed = GNUNET_YES;
 }
 
 
@@ -1552,7 +1600,7 @@ GAS_mlp_address_delete (void *solver,
   if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers,
                                                      &address->peer)))
   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "Deleting %s for peer `%s' without address request \n",
+    LOG (GNUNET_ERROR_TYPE_INFO, "Deleting %s for peer `%s' without address request \n",
         (session_only == GNUNET_YES) ? "session" : "address",
         GNUNET_i2s(&address->peer));
     return;
@@ -1562,8 +1610,8 @@ GAS_mlp_address_delete (void *solver,
       GNUNET_i2s(&address->peer));
 
   /* Problem size changed: new address for peer with pending request */
-  mlp->mlp_prob_changed = GNUNET_YES;
-  if (GNUNET_YES == mlp->mlp_auto_solve)
+  mlp->stat_mlp_prob_changed = GNUNET_YES;
+  if (GNUNET_YES == mlp->opt_mlp_auto_solve)
   {
     GAS_mlp_solve_problem (solver);
   }
@@ -1680,9 +1728,9 @@ GAS_mlp_get_preferred_address (void *solver,
                                         GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
 
       /* Added new peer, we have to rebuild problem before solving */
-      mlp->mlp_prob_changed = GNUNET_YES;
+      mlp->stat_mlp_prob_changed = GNUNET_YES;
 
-      if ((GNUNET_YES == mlp->mlp_auto_solve)&&
+      if ((GNUNET_YES == mlp->opt_mlp_auto_solve)&&
           (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains(mlp->addresses,
                                                                peer)))
       {
@@ -1712,7 +1760,7 @@ GAS_mlp_bulk_start (void *solver)
 
   GNUNET_assert (NULL != solver);
 
-  s->bulk_lock ++;
+  s->stat_bulk_lock ++;
 }
 
 void
@@ -1723,17 +1771,17 @@ GAS_mlp_bulk_stop (void *solver)
   struct GAS_MLP_Handle *s = (struct GAS_MLP_Handle *) solver;
   GNUNET_assert (NULL != solver);
 
-  if (s->bulk_lock < 1)
+  if (s->stat_bulk_lock < 1)
   {
     GNUNET_break (0);
     return;
   }
-  s->bulk_lock --;
+  s->stat_bulk_lock --;
 
-  if (0 < s->bulk_request)
+  if (0 < s->stat_bulk_requests)
   {
     GAS_mlp_solve_problem (solver);
-    s->bulk_request= 0;
+    s->stat_bulk_requests= 0;
   }
 }
 
@@ -1759,8 +1807,8 @@ GAS_mlp_stop_get_preferred_address (void *solver,
     GNUNET_CONTAINER_multipeermap_remove (mlp->requested_peers, peer, p);
     GNUNET_free (p);
 
-    mlp->mlp_prob_changed = GNUNET_YES;
-    if (GNUNET_YES == mlp->mlp_auto_solve)
+    mlp->stat_mlp_prob_changed = GNUNET_YES;
+    if (GNUNET_YES == mlp->opt_mlp_auto_solve)
     {
       GAS_mlp_solve_problem (solver);
     }
@@ -1806,8 +1854,8 @@ GAS_mlp_address_change_preference (void *solver,
   mlp_create_problem_update_value (&mlp->p, p->r_c9, mlp->p.c_r, -p->f, __LINE__);
 
   /* Problem size changed: new address for peer with pending request */
-  mlp->mlp_prob_updated = GNUNET_YES;
-  if (GNUNET_YES == mlp->mlp_auto_solve)
+  mlp->stat_mlp_prob_updated = GNUNET_YES;
+  if (GNUNET_YES == mlp->opt_mlp_auto_solve)
     GAS_mlp_solve_problem (solver);
   return;
 }
@@ -1936,49 +1984,64 @@ libgnunet_plugin_ats_mlp_init (void *cls)
       break;
   }
 
-   mlp->write_mip_mps = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "ats",
-          "DUMP_MLP");
-   if (GNUNET_SYSERR == mlp->write_mip_mps)
-     mlp->write_mip_mps = GNUNET_NO;
-   mlp->write_mip_sol = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "ats",
-          "DUMP_SOLUTION");
-   if (GNUNET_SYSERR == mlp->write_mip_sol)
-     mlp->write_mip_sol = GNUNET_NO;
+  mlp->opt_dump_problem_all = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+     "ats", "MLP_DUMP_PROBLEM_ALL");
+  if (GNUNET_SYSERR == mlp->opt_dump_problem_all)
+   mlp->opt_dump_problem_all = GNUNET_NO;
+
+  mlp->opt_dump_solution_all = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+     "ats", "MLP_DUMP_SOLUTION_ALL");
+  if (GNUNET_SYSERR == mlp->opt_dump_solution_all)
+   mlp->opt_dump_solution_all = GNUNET_NO;
+
+  mlp->opt_dump_problem_on_fail = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+     "ats", "MLP_DUMP_PROBLEM_ON_FAIL");
+  if (GNUNET_SYSERR == mlp->opt_dump_problem_on_fail)
+   mlp->opt_dump_problem_on_fail = GNUNET_NO;
+
+  mlp->opt_dump_solution_on_fail = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+     "ats", "MLP_DUMP_SOLUTION_ON_FAIL");
+  if (GNUNET_SYSERR == mlp->opt_dump_solution_on_fail)
+   mlp->opt_dump_solution_on_fail = GNUNET_NO;
+
+  mlp->opt_glpk_verbose = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+     "ats", "MLP_GLPK_VERBOSE");
+  if (GNUNET_SYSERR == mlp->opt_glpk_verbose)
+   mlp->opt_glpk_verbose = GNUNET_NO;
 
   mlp->pv.BIG_M = (double) BIG_M_VALUE;
 
   /* Get timeout for iterations */
-  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time(env->cfg, "ats", "MLP_MAX_DURATION", &max_duration))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time(env->cfg, "ats",
+      "MLP_MAX_DURATION", &max_duration))
   {
     max_duration = MLP_MAX_EXEC_DURATION;
   }
 
   /* Get maximum number of iterations */
-  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_size(env->cfg, "ats", "MLP_MAX_ITERATIONS", &max_iterations))
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_size(env->cfg, "ats",
+      "MLP_MAX_ITERATIONS", &max_iterations))
   {
     max_iterations = MLP_MAX_ITERATIONS;
   }
 
   /* Get diversity coefficient from configuration */
-  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (env->cfg, "ats",
-                                                      "MLP_COEFFICIENT_D",
-                                                      &tmp))
+  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (env->cfg,
+      "ats", "MLP_COEFFICIENT_D", &tmp))
     D = (double) tmp / 100;
   else
     D = DEFAULT_D;
 
   /* Get proportionality coefficient from configuration */
-  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (env->cfg, "ats",
-                                                      "MLP_COEFFICIENT_R",
-                                                      &tmp))
+  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (env->cfg,
+      "ats", "MLP_COEFFICIENT_R", &tmp))
     R = (double) tmp / 100;
   else
     R = DEFAULT_R;
 
   /* Get utilization coefficient from configuration */
-  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (env->cfg, "ats",
-                                                      "MLP_COEFFICIENT_U",
-                                                      &tmp))
+  if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (env->cfg,
+      "ats", "MLP_COEFFICIENT_U", &tmp))
     U = (double) tmp / 100;
   else
     U = DEFAULT_U;
@@ -1999,17 +2062,16 @@ libgnunet_plugin_ats_mlp_init (void *cls)
       i_distance = c;
   }
 
-  if ((i_delay != MLP_NaN) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (env->cfg, "ats",
-                                                      "MLP_COEFFICIENT_QUALITY_DELAY",
-                                                      &tmp)))
-
+  if ( (i_delay != MLP_NaN) &&
+       (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (env->cfg, "ats",
+          "MLP_COEFFICIENT_QUALITY_DELAY", &tmp)) )
     mlp->pv.co_Q[i_delay] = (double) tmp / 100;
   else
     mlp->pv.co_Q[i_delay] = DEFAULT_QUALITY;
 
-  if ((i_distance != MLP_NaN) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (env->cfg, "ats",
-                                                      "MLP_COEFFICIENT_QUALITY_DISTANCE",
-                                                      &tmp)))
+  if ( (i_distance != MLP_NaN) &&
+        (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (env->cfg, "ats",
+          "MLP_COEFFICIENT_QUALITY_DISTANCE", &tmp)) )
     mlp->pv.co_Q[i_distance] = (double) tmp / 100;
   else
     mlp->pv.co_Q[i_distance] = DEFAULT_QUALITY;
@@ -2045,10 +2107,11 @@ libgnunet_plugin_ats_mlp_init (void *cls)
               mlp->pv.quota_out[c] = env->out_quota[c2];
               mlp->pv.quota_in[c] = env->in_quota[c2];
               found = GNUNET_YES;
-              LOG (GNUNET_ERROR_TYPE_DEBUG, "Quota for network `%s' (in/out) %llu/%llu\n",
-                          GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
-                          mlp->pv.quota_out[c],
-                          mlp->pv.quota_in[c]);
+              LOG (GNUNET_ERROR_TYPE_DEBUG,
+                  "Quota for network `%s' (in/out) %llu/%llu\n",
+                  GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
+                  mlp->pv.quota_out[c],
+                  mlp->pv.quota_in[c]);
               break;
           }
       }
@@ -2056,7 +2119,8 @@ libgnunet_plugin_ats_mlp_init (void *cls)
       /* Check if defined quota could make problem unsolvable */
       if ((n_min * b_min) > mlp->pv.quota_out[c])
       {
-        LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inconsistent outbound quota configuration for network `%s', is %llu must be at least %llu\n"),
+        LOG (GNUNET_ERROR_TYPE_INFO,
+            _("Adjusting inconsistent outbound quota configuration for network `%s', is %llu must be at least %llu\n"),
             GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
             mlp->pv.quota_out[c],
             (n_min * b_min));
@@ -2064,7 +2128,8 @@ libgnunet_plugin_ats_mlp_init (void *cls)
       }
       if ((n_min * b_min) > mlp->pv.quota_in[c])
       {
-        LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inconsistent inbound quota configuration for network `%s', is %llu must be at least %llu\n"),
+        LOG (GNUNET_ERROR_TYPE_INFO,
+            _("Adjusting inconsistent inbound quota configuration for network `%s', is %llu must be at least %llu\n"),
             GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
             mlp->pv.quota_in[c],
             (n_min * b_min));
@@ -2074,7 +2139,8 @@ libgnunet_plugin_ats_mlp_init (void *cls)
       /* Check if bandwidth is too big to make problem solvable */
       if (mlp->pv.BIG_M < mlp->pv.quota_out[c])
       {
-        LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting outbound quota configuration for network `%s'from %llu to %.0f\n"),
+        LOG (GNUNET_ERROR_TYPE_INFO,
+            _("Adjusting outbound quota configuration for network `%s'from %llu to %.0f\n"),
             GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
             mlp->pv.quota_out[c],
             mlp->pv.BIG_M);
@@ -2131,12 +2197,12 @@ libgnunet_plugin_ats_mlp_init (void *cls)
   mlp->pv.b_min = b_min;
   mlp->pv.n_min = n_min;
   mlp->pv.m_q = GNUNET_ATS_QualityPropertiesCount;
-  mlp->mlp_prob_changed = GNUNET_NO;
-  mlp->mlp_prob_updated = GNUNET_NO;
-  mlp->mlp_auto_solve = GNUNET_YES;
+  mlp->stat_mlp_prob_changed = GNUNET_NO;
+  mlp->stat_mlp_prob_updated = GNUNET_NO;
+  mlp->opt_mlp_auto_solve = GNUNET_YES;
   mlp->requested_peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
-  mlp->bulk_request = 0;
-  mlp->bulk_lock = 0;
+  mlp->stat_bulk_requests = 0;
+  mlp->stat_bulk_lock = 0;
 
   /* Setup GLPK */
   /* Redirect GLPK output to GNUnet logging */
@@ -2145,18 +2211,17 @@ libgnunet_plugin_ats_mlp_init (void *cls)
   /* Init LP solving parameters */
   glp_init_smcp(&mlp->control_param_lp);
   mlp->control_param_lp.msg_lev = GLP_MSG_OFF;
-#if VERBOSE_GLPK
-  mlp->control_param_lp.msg_lev = GLP_MSG_ALL;
-#endif
+  if (GNUNET_YES == mlp->opt_glpk_verbose)
+    mlp->control_param_lp.msg_lev = GLP_MSG_ALL;
+
   mlp->control_param_lp.it_lim = max_iterations;
   mlp->control_param_lp.tm_lim = max_duration.rel_value_us / 1000LL;
 
   /* Init MLP solving parameters */
   glp_init_iocp(&mlp->control_param_mlp);
   mlp->control_param_mlp.msg_lev = GLP_MSG_OFF;
-#if VERBOSE_GLPK
-  mlp->control_param_mlp.msg_lev = GLP_MSG_ALL;
-#endif
+  if (GNUNET_YES == mlp->opt_glpk_verbose)
+    mlp->control_param_mlp.msg_lev = GLP_MSG_ALL;
   mlp->control_param_mlp.tm_lim = max_duration.rel_value_us / 1000LL;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "solver ready\n");