fix for 0002392
[oweals/gnunet.git] / src / ats / gnunet-service-ats_addresses_mlp.c
index 512d5fb3959d9a7e9ff26ed64b0598d9496683fc..8bfa010caaa86914b06e406416ac824e053065cd 100644 (file)
@@ -505,7 +505,9 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
    * c 10) obey network specific quota
    */
 
+  /* Row for c4) minimum connection */
   int min = mlp->n_min;
+  /* Number of minimum connections is min(|Peers|, n_min) */
   if (mlp->n_min > mlp->c_p)
     min = mlp->c_p;
 
@@ -565,6 +567,7 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
   mlp->ci++;
 
   struct ATS_Peer * peer = mlp->peer_head;
+  /* For all peers */
   while (peer != NULL)
   {
     struct ATS_Address *addr = peer->head;
@@ -590,16 +593,15 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
     /* Set -r */
     ia[mlp->ci] = peer->r_c9;
     ja[mlp->ci] = mlp->c_r;
-    ar[mlp->ci] = -1;
+    ar[mlp->ci] = -peer->f;
     mlp->ci++;
 #endif
-
+    /* For all addresses of this peer */
     while (addr != NULL)
     {
       mlpi = (struct MLP_information *) addr->mlp_information;
 
       /* coefficient for c 2) */
-
       ia[mlp->ci] = peer->r_c2;
       ja[mlp->ci] = mlpi->c_n;
       ar[mlp->ci] = 1;
@@ -625,8 +627,6 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
   }
 
   /* c 7) For all quality metrics */
-
-
   for (c = 0; c < mlp->m_q; c++)
   {
     struct ATS_Peer *tp;
@@ -640,7 +640,7 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
     glp_set_row_name (mlp->prob, mlp->r_q[c], name);
     GNUNET_free (name);
     /* Set row bound == 0 */
-    glp_set_row_bnds (mlp->prob, mlp->r_q[c], GLP_LO, 0.0, 0.0);
+    glp_set_row_bnds (mlp->prob, mlp->r_q[c], GLP_FX, 0.0, 0.0);
 
     ia[mlp->ci] = mlp->r_q[c];
     ja[mlp->ci] = mlp->c_q[c];
@@ -657,7 +657,7 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
 
           ia[mlp->ci] = mlp->r_q[c];
           ja[mlp->ci] = mlpi->c_b;
-          ar[mlp->ci] = tp->f * value;
+          ar[mlp->ci] = tp->f_q[c] * value;
           mlp->ci++;
         }
   }
@@ -747,7 +747,6 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas
   /* Adding invariant columns */
 
   /* Diversity d column  */
-
   col = glp_add_cols (mlp->prob, 1);
   mlp->c_d = col;
   /* Column name */
@@ -758,7 +757,6 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas
   glp_set_col_bnds (mlp->prob, col, GLP_LO, 0.0, 0.0);
 
   /* Utilization u column  */
-
   col = glp_add_cols (mlp->prob, 1);
   mlp->c_u = col;
   /* Column name */
@@ -999,6 +997,7 @@ mlp_scheduler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
  * Solves the MLP problem
  *
  * @param mlp the MLP Handle
+ * @param ctx solution context
  * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
  */
 int
@@ -1022,8 +1021,8 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContex
 
   ctx->lp_result = GNUNET_SYSERR;
   ctx->mlp_result = GNUNET_SYSERR;
-  ctx->lp_duration = GNUNET_TIME_relative_get_forever();
-  ctx->mlp_duration = GNUNET_TIME_relative_get_forever();
+  ctx->lp_duration = GNUNET_TIME_UNIT_FOREVER_REL;
+  ctx->mlp_duration = GNUNET_TIME_UNIT_FOREVER_REL;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve LP problem\n");
 #if WRITE_MLP
@@ -1127,7 +1126,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
   double D;
   double R;
   double U;
-  long long unsigned int tmp;
+  unsigned long long tmp;
   unsigned int b_min;
   unsigned int n_min;
   struct GNUNET_TIME_Relative i_exec;
@@ -1318,8 +1317,8 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
     /* Check if defined quota could make problem unsolvable */
     if (((n_min * b_min) > quota_out) && (GNUNET_ATS_NET_UNSPECIFIED != quotas[c]))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Inconsistent quota configuration value `%s': " \
-          "outbound quota (%u Bps) too small for combination of minimum connections and minimum bandwidth per peer (%u * %u Bps = %u)\n", entry_out, quota_out, n_min, b_min, n_min * b_min);
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Inconsistent quota configuration value `%s': " 
+                 "outbound quota (%u Bps) too small for combination of minimum connections and minimum bandwidth per peer (%u * %u Bps = %u)\n", entry_out, quota_out, n_min, b_min, n_min * b_min);
 
       GAS_mlp_done(mlp);
       mlp = NULL;
@@ -1370,7 +1369,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
 #endif
   mlp->control_param_mlp.tm_lim = max_duration.rel_value;
 
-  mlp->last_execution = GNUNET_TIME_absolute_get_forever();
+  mlp->last_execution = GNUNET_TIME_UNIT_FOREVER_ABS;
 
   mlp->co_D = D;
   mlp->co_R = R;