gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r26191 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r26191 - gnunet/src/ats
Date: Fri, 22 Feb 2013 15:37:06 +0100

Author: wachs
Date: 2013-02-22 15:37:06 +0100 (Fri, 22 Feb 2013)
New Revision: 26191

Modified:
   gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
Log:
 changes


Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.c   2013-02-22 14:28:56 UTC 
(rev 26190)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.c   2013-02-22 14:37:06 UTC 
(rev 26191)
@@ -1074,27 +1074,7 @@
 }
 
 
-/**
- * Create the
- * - address columns b and n
- * - address dependent constraint rows c1, c3
- * - peer dependent rows c2 and c9
- * - Set address dependent entries in problem matrix as well
- */
-static void
-mlp_create_problem_add_address_information (struct GAS_MLP_Handle *mlp, struct 
MLP_Problem *p)
-{
-       /* Add peer dependent constraints */
-       /* Add constraint c2 */
-       /* Add constraint c9 */
 
-       /* Add address dependent constraints */
-       /* Add constraint c1 */
-       /* Add constraint c3 */
-
-
-}
-
 static void
 mlp_create_problem_set_value (struct MLP_Problem *p, int row, int col, double 
val)
 {
@@ -1114,6 +1094,86 @@
 }
 
 /**
+ * Create the
+ * - address columns b and n
+ * - address dependent constraint rows c1, c3
+ * - peer dependent rows c2 and c9
+ * - Set address dependent entries in problem matrix as well
+ */
+static int
+mlp_create_problem_add_address_information (void *cls, const struct 
GNUNET_HashCode *key, void *value)
+{
+  struct GAS_MLP_Handle *mlp = cls;
+  struct MLP_Problem *p = &mlp->p;
+  struct ATS_Address *address = value;
+  struct ATS_Peer *peer;
+  struct MLP_information *mlpi;
+  unsigned int col;
+  char *name;
+
+  /* Check if we have to add this peer due to a pending request */
+  if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(mlp->peers, key))
+       return GNUNET_OK;
+
+  /* Prepare solver information */
+  if (NULL != address->solver_information)
+  {
+       GNUNET_free (address->solver_information);
+               address->solver_information = NULL;
+  }
+  mlpi = GNUNET_malloc (sizeof (struct MLP_information));
+  address->solver_information = mlpi;
+
+  /* Add bandwidth column */
+  col = glp_add_cols (p->prob, 2);
+  mlpi->c_b = col;
+  mlpi->c_n = col + 1;
+  GNUNET_asprintf (&name, "b_%s_%s", GNUNET_i2s (&address->peer), 
address->plugin);
+  glp_set_col_name (p->prob, mlpi->c_b , name);
+  /* Lower bound == 0 */
+  glp_set_col_bnds (p->prob, mlpi->c_b , GLP_LO, 0.0, 0.0);
+  /* Continuous value*/
+  glp_set_col_kind (p->prob, mlpi->c_b , GLP_CV);
+  /* Objective function coefficient == 0 */
+  glp_set_obj_coef (p->prob, mlpi->c_b , 0);
+#if  DEBUG_MLP_PROBLEM_CREATION
+       LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%u] `%s': `%s' 
address %p\n",
+                       mlpi->c_b, name, GNUNET_i2s(&address->peer), address);
+#endif
+  GNUNET_free (name);
+
+  /* Add usage column */
+  GNUNET_asprintf (&name, "n_%s_%s", GNUNET_i2s (&address->peer), 
address->plugin);
+  glp_set_col_name (p->prob, mlpi->c_n, name);
+  /* Limit value : 0 <= value <= 1 */
+  glp_set_col_bnds (p->prob, mlpi->c_n, GLP_DB, 0.0, 1.0);
+  /* Integer value*/
+  glp_set_col_kind (p->prob, mlpi->c_n, GLP_IV);
+  /* Objective function coefficient == 0 */
+  glp_set_obj_coef (p->prob, mlpi->c_n, 0);
+#if  DEBUG_MLP_PROBLEM_CREATION
+       LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%u] `%s': `%s' 
address %p\n",
+                       mlpi->c_n, name, GNUNET_i2s(&address->peer), address);
+#endif
+  GNUNET_free (name);
+
+  /* Get peer */
+  peer = GNUNET_CONTAINER_multihashmap_get (mlp->peers, key);
+  peer->processed = GNUNET_NO;
+
+
+       /* Add peer dependent constraints */
+       /* Add constraint c2 */
+       /* Add constraint c9 */
+
+       /* Add address dependent constraints */
+       /* Add constraint c1 */
+       /* Add constraint c3 */
+
+  return GNUNET_OK;
+}
+
+/**
  * Create the invariant columns c4, c6, c10, c8, c7
  */
 static void
@@ -1324,7 +1384,7 @@
   mlp_create_problem_add_invariant_rows (mlp, p);
 
   /* Adding address independent constraint rows */
-  mlp_create_problem_add_address_information (mlp, p);
+  GNUNET_CONTAINER_multihashmap_iterate (addresses, 
&mlp_create_problem_add_address_information, mlp);
 
 #if 0
   /* Add columns for addresses */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]