diff options
author | Fabian Oehlmann <oehlmann@in.tum.de> | 2013-11-19 17:03:44 +0000 |
---|---|---|
committer | Fabian Oehlmann <oehlmann@in.tum.de> | 2013-11-19 17:03:44 +0000 |
commit | 0f14ef81c789128be63bc3654bff1a6cb7df2953 (patch) | |
tree | 0c703bd06209b3b94c342c3681179078b65b594f /src/ats | |
parent | 94a6bb6f521b4d57a10035ad294b4c8ef58f01ff (diff) | |
download | gnunet-0f14ef81c789128be63bc3654bff1a6cb7df2953.tar.gz gnunet-0f14ef81c789128be63bc3654bff1a6cb7df2953.zip |
better experience initialization
Diffstat (limited to 'src/ats')
-rwxr-xr-x | src/ats/libgnunet_plugin_ats_ril.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/ats/libgnunet_plugin_ats_ril.c b/src/ats/libgnunet_plugin_ats_ril.c index bee3c846b..599241e34 100755 --- a/src/ats/libgnunet_plugin_ats_ril.c +++ b/src/ats/libgnunet_plugin_ats_ril.c | |||
@@ -1321,6 +1321,44 @@ ril_step (struct GAS_RIL_Handle *solver) | |||
1321 | return GNUNET_YES; | 1321 | return GNUNET_YES; |
1322 | } | 1322 | } |
1323 | 1323 | ||
1324 | static int | ||
1325 | ril_count_agents (struct GAS_RIL_Handle *solver) | ||
1326 | { | ||
1327 | int c = 0; | ||
1328 | struct RIL_Peer_Agent *cur_agent; | ||
1329 | |||
1330 | for (cur_agent = solver->agents_head; NULL != cur_agent; cur_agent = cur_agent->next) | ||
1331 | { | ||
1332 | c++; | ||
1333 | } | ||
1334 | return c; | ||
1335 | } | ||
1336 | |||
1337 | static void | ||
1338 | agent_w_start (struct RIL_Peer_Agent *agent) | ||
1339 | { | ||
1340 | int count; | ||
1341 | struct RIL_Peer_Agent *other; | ||
1342 | int i; | ||
1343 | int k; | ||
1344 | |||
1345 | count = ril_count_agents(agent->envi); | ||
1346 | |||
1347 | if (0 == count) | ||
1348 | return; | ||
1349 | |||
1350 | for (other = agent->envi->agents_head; NULL != other; other = other->next) | ||
1351 | { | ||
1352 | for (i = 0; i < agent->n; i++) | ||
1353 | { | ||
1354 | for (k = 0; k < agent->m; k++) | ||
1355 | { | ||
1356 | agent->W[i][k] += (other->W[i][k] / (double) count); | ||
1357 | } | ||
1358 | } | ||
1359 | } | ||
1360 | } | ||
1361 | |||
1324 | /** | 1362 | /** |
1325 | * Initialize an agent without addresses and its knowledge base | 1363 | * Initialize an agent without addresses and its knowledge base |
1326 | * | 1364 | * |
@@ -1349,6 +1387,7 @@ agent_init (void *s, const struct GNUNET_PeerIdentity *peer) | |||
1349 | { | 1387 | { |
1350 | agent->W[i] = (double *) GNUNET_malloc (sizeof (double) * agent->m); | 1388 | agent->W[i] = (double *) GNUNET_malloc (sizeof (double) * agent->m); |
1351 | } | 1389 | } |
1390 | agent_w_start(agent); | ||
1352 | agent->a_old = RIL_ACTION_INVALID; | 1391 | agent->a_old = RIL_ACTION_INVALID; |
1353 | agent->s_old = envi_get_state (solver, agent); | 1392 | agent->s_old = envi_get_state (solver, agent); |
1354 | agent->e = (double *) GNUNET_malloc (sizeof (double) * agent->m); | 1393 | agent->e = (double *) GNUNET_malloc (sizeof (double) * agent->m); |