[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r27467 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r27467 - gnunet/src/ats |
Date: |
Tue, 18 Jun 2013 10:02:14 +0200 |
Author: wachs
Date: 2013-06-18 10:02:14 +0200 (Tue, 18 Jun 2013)
New Revision: 27467
Modified:
gnunet/src/ats/Makefile.am
gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
gnunet/src/ats/gnunet-service-ats_normalization.c
gnunet/src/ats/test_ats_mlp.c
Log:
changes
Modified: gnunet/src/ats/Makefile.am
===================================================================
--- gnunet/src/ats/Makefile.am 2013-06-18 07:28:42 UTC (rev 27466)
+++ gnunet/src/ats/Makefile.am 2013-06-18 08:02:14 UTC (rev 27467)
@@ -17,7 +17,7 @@
if HAVE_LIBGLPK
GN_LIBGLPK = -lglpk
- GN_MLP_SRC = gnunet-service-ats_addresses_mlp.c
gnunet-service-ats_addresses_mlp.h
+ GN_MLP_SRC = gnunet-service-ats_addresses_mlp.c
gnunet-service-ats_addresses_mlp.h gnunet-service-ats_normalization.c
gnunet-service-ats_normalization.h
GN_MLP_TEST = test_ats_mlp
GN_MLP_TEST_UPDATE = test_ats_mlp_update
GN_MLP_TEST_AVG = test_ats_mlp_averaging
Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2013-06-18 07:28:42 UTC
(rev 27466)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2013-06-18 08:02:14 UTC
(rev 27467)
@@ -27,6 +27,7 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet-service-ats_addresses.h"
+#include "gnunet-service-ats_normalization.h"
#include "gnunet-service-ats_addresses_mlp.h"
#include "gnunet_statistics_service.h"
#include "glpk.h"
@@ -1437,6 +1438,27 @@
}
+static double get_peer_pref_value (const struct GNUNET_PeerIdentity *peer)
+{
+ double res;
+ const double *preferences = NULL;
+ int c;
+ preferences = GAS_normalization_get_preferences ((struct GNUNET_PeerIdentity
*) peer);
+
+ res = 0.0;
+ for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
+ {
+ if (c != GNUNET_ATS_PREFERENCE_END)
+ {
+ //fprintf (stderr, "VALUE[%u] %s %.3f \n", c,
GNUNET_i2s (&cur->addr->peer), t[c]);
+ res += preferences[c];
+ }
+ }
+ res /= (GNUNET_ATS_PreferenceCount -1);
+ return res;
+}
+
+
/**
* Get the preferred address for a specific peer
*
@@ -1469,7 +1491,7 @@
p = GNUNET_malloc (sizeof (struct ATS_Peer));
p->id = (*peer);
- p->f = DEFAULT_PEER_PREFERENCE;
+ p->f = get_peer_pref_value (peer);;
GNUNET_CONTAINER_multihashmap_put (mlp->peers, &peer->hashPubKey, p,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
/* Added new peer, we have to rebuild problem before solving */
@@ -1530,16 +1552,28 @@
double pref_rel)
{
struct GAS_MLP_Handle *mlp = solver;
+ struct ATS_Peer *p = NULL;
+
LOG (GNUNET_ERROR_TYPE_DEBUG, "Changing preference for address for peer
`%s'\n",
GNUNET_i2s(peer));
GNUNET_STATISTICS_update (mlp->stats,"# LP address preference changes", 1,
GNUNET_NO);
/* Update the constraints with changed preferences */
+
+
/* Update quality constraint c7 */
- /* Update relativity constraint c8 */
+ /* Update relativity constraint c9 */
+ if (NULL == (p = GNUNET_CONTAINER_multihashmap_get (mlp->peers,
&peer->hashPubKey)))
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Updating preference for unknown peer `%s'
\n", GNUNET_i2s(peer));
+ return;
+ }
+ p->f = get_peer_pref_value (peer);
+ mlp_create_problem_set_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)
Modified: gnunet/src/ats/gnunet-service-ats_normalization.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_normalization.c 2013-06-18 07:28:42 UTC
(rev 27466)
+++ gnunet/src/ats/gnunet-service-ats_normalization.c 2013-06-18 08:02:14 UTC
(rev 27467)
@@ -422,6 +422,9 @@
const double *
GAS_normalization_get_preferences (struct GNUNET_PeerIdentity *id)
{
+ GNUNET_assert (NULL != peers);
+ GNUNET_assert (NULL != id);
+
struct PeerRelative *rp;
if (NULL == (rp = GNUNET_CONTAINER_multihashmap_get (peers,
&id->hashPubKey)))
{
Modified: gnunet/src/ats/test_ats_mlp.c
===================================================================
--- gnunet/src/ats/test_ats_mlp.c 2013-06-18 07:28:42 UTC (rev 27466)
+++ gnunet/src/ats/test_ats_mlp.c 2013-06-18 08:02:14 UTC (rev 27467)
@@ -104,6 +104,7 @@
GAS_mlp_done (mlp);
mlp = NULL;
}
+ GAS_normalization_stop ();
ret = res;
}
@@ -191,7 +192,7 @@
end_now (1);
return;
}
-
+ GAS_normalization_start (NULL, NULL);
/* Setup address hashmap */
addresses = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r27467 - gnunet/src/ats,
gnunet <=