gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r19251 - gnunet/src/ats
Date: Thu, 19 Jan 2012 10:46:33 +0100

Author: wachs
Date: 2012-01-19 10:46:32 +0100 (Thu, 19 Jan 2012)
New Revision: 19251

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


Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c       2012-01-18 22:10:08 UTC 
(rev 19250)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c       2012-01-19 09:46:32 UTC 
(rev 19251)
@@ -523,7 +523,10 @@
                                  enum GNUNET_ATS_PreferenceKind kind,
                                  float score)
 {
-  // do nothing for now...
+#if HAVE_LIBGLPK
+  if (ats_mode == MLP)
+    GAS_mlp_address_change_preference (mlp, peer, kind, score);
+#endif
 }
 
 

Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.c   2012-01-18 22:10:08 UTC 
(rev 19250)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.c   2012-01-19 09:46:32 UTC 
(rev 19251)
@@ -151,6 +151,24 @@
 }
 
 /**
+ * Find a peer in the DLL
+ * @param the peer to find
+ * @return the peer struct
+ */
+static struct ATS_Peer *
+mlp_find_peer (struct GAS_MLP_Handle *mlp, const struct GNUNET_PeerIdentity 
*peer)
+{
+  struct ATS_Peer *res = mlp->peer_head;
+  while (res != NULL)
+  {
+    if (0 == memcmp (peer, &res->id, sizeof (struct GNUNET_PeerIdentity)))
+      break;
+    res = res->next;
+  }
+  return res;
+}
+
+/**
  * Intercept GLPK terminal output
  * @param info the mlp handle
  * @param s the string to print
@@ -492,8 +510,8 @@
   glp_set_col_bnds (mlp->prob, col, GLP_LO, 0.0, 0.0);
 
   /* Quality metric columns */
-  col = glp_add_cols(mlp->prob, mlp->m);
-  for (c = 0; c < mlp->m; c++)
+  col = glp_add_cols(mlp->prob, mlp->m_q);
+  for (c = 0; c < mlp->m_q; c++)
   {
     mlp->c_q[c] = col + c;
     GNUNET_asprintf (&name, "q_%u", mlp->q[c]);
@@ -869,7 +887,7 @@
   mlp->co_U = U;
   mlp->b_min = b_min;
   mlp->n_min = n_min;
-  mlp->m = GNUNET_ATS_QualityPropertiesCount;
+  mlp->m_q = GNUNET_ATS_QualityPropertiesCount;
 
   return mlp;
 }
@@ -893,6 +911,7 @@
 {
   int new;
   struct MLP_information *mlpi;
+  int c;
 
   GNUNET_STATISTICS_update (mlp->stats,"# LP address updates", 1, GNUNET_NO);
 
@@ -910,13 +929,7 @@
     mlp->addr_in_problem ++;
 
     /* Check for and add peer */
-    struct ATS_Peer *peer = mlp->peer_head;
-    while (peer != NULL)
-    {
-      if (0 == memcmp (&address->peer, &peer->id, sizeof (struct 
GNUNET_PeerIdentity)))
-        break;
-      peer = peer->next;
-    }
+    struct ATS_Peer *peer = mlp_find_peer (mlp, &address->peer);
     if (peer == NULL)
     {
 #if DEBUG_ATS
@@ -925,6 +938,12 @@
       peer = GNUNET_malloc (sizeof (struct ATS_Peer));
       peer->head = NULL;
       peer->tail = NULL;
+
+      for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
+      {
+        peer->f_q[c] = 1.0;
+      }
+
       memcpy (&peer->id, &address->peer, sizeof (struct GNUNET_PeerIdentity));
       GNUNET_assert(address->prev == NULL);
       GNUNET_assert(address->next == NULL);
@@ -978,13 +997,7 @@
   }
 
   /* Remove from peer list */
-  struct ATS_Peer *head = mlp->peer_head;
-  while (head != NULL)
-  {
-    if (0 == memcmp (&address->peer, &head->id, sizeof (struct 
GNUNET_PeerIdentity)))
-      break;
-    head = head->next;
-  }
+  struct ATS_Peer *head = mlp_find_peer (mlp, &address->peer);
   GNUNET_assert (head != NULL);
 #if DEBUG_ATS
   GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Deleting address for `%s'\n", 
GNUNET_i2s (&address->peer));
@@ -1017,16 +1030,24 @@
 }
 
 /**
- * Deletes a single address in the MLP problem
+ * Changes the preferences for a peer in the MLP problem
  *
  * @param mlp the MLP Handle
- * @param addresses the address hashmap
- * @param address the address to change the preference
+ * @param peer the peer
+ * @param kind the kind to change the preference
+ * @param float the score
  */
 void
-GAS_mlp_address_change_preference (struct GAS_MLP_Handle *mlp, struct 
GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address)
+GAS_mlp_address_change_preference (struct GAS_MLP_Handle *mlp,
+                                   const struct GNUNET_PeerIdentity *peer,
+                                   enum GNUNET_ATS_PreferenceKind kind,
+                                   float score)
 {
   GNUNET_STATISTICS_update (mlp->stats,"# LP address preference changes", 1, 
GNUNET_NO);
+
+  struct ATS_Peer *p = mlp_find_peer (mlp, peer);
+  p = p;
+  /* Here we have to do the matching */
 }
 
 /**

Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.h   2012-01-18 22:10:08 UTC 
(rev 19250)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.h   2012-01-19 09:46:32 UTC 
(rev 19251)
@@ -47,6 +47,9 @@
 
   struct GNUNET_PeerIdentity id;
 
+  /* Array of quality preferences */
+  double f_q[GNUNET_ATS_QualityPropertiesCount];
+
   struct ATS_Address *head;
   struct ATS_Address *tail;
 };
@@ -179,6 +182,7 @@
   double co_R;
 
   /* ATS Quality metrics
+   *
    * array with GNUNET_ATS_QualityPropertiesCount elements
    * contains mapping to GNUNET_ATS_Property*/
   int q[GNUNET_ATS_QualityPropertiesCount];
@@ -190,8 +194,23 @@
   double co_Q[GNUNET_ATS_QualityPropertiesCount];
 
   /* number of quality metrics */
-  int m;
+  int m_q;
 
+  /* ATS ressource costs
+   *
+   * array with GNUNET_ATS_QualityPropertiesCount elements
+   * contains mapping to GNUNET_ATS_Property*/
+  int rc[GNUNET_ATS_QualityPropertiesCount];
+
+  /* column index ressource costs  */
+  int c_rc[GNUNET_ATS_QualityPropertiesCount];
+
+  /* ressource costs coefficients*/
+  double co_RC[GNUNET_ATS_QualityPropertiesCount];
+
+  /* number of quality metrics */
+  int m_rc;
+
   /* minimum bandwidth assigned to an address */
   unsigned int b_min;
 
@@ -270,14 +289,18 @@
 
 
 /**
- * Deletes a single address in the MLP problem
+ * Changes the preferences for a peer in the MLP problem
  *
  * @param mlp the MLP Handle
- * @param addresses the address hashmap
- * @param address the address to change the preference
+ * @param peer the peer
+ * @param kind the kind to change the preference
+ * @param float the score
  */
 void
-GAS_mlp_address_change_preference (struct GAS_MLP_Handle *mlp, struct 
GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address);
+GAS_mlp_address_change_preference (struct GAS_MLP_Handle *mlp,
+                                   const struct GNUNET_PeerIdentity *peer,
+                                   enum GNUNET_ATS_PreferenceKind kind,
+                                   float score);
 
 
 /**




reply via email to

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