diff options
author | Fabian Oehlmann <oehlmann@in.tum.de> | 2013-12-16 11:10:25 +0000 |
---|---|---|
committer | Fabian Oehlmann <oehlmann@in.tum.de> | 2013-12-16 11:10:25 +0000 |
commit | 2f8be33175a8a018363e512a8f1dac9d9065a41d (patch) | |
tree | c01cc37c90f57caf44bb3a23a5fa02bd3204b8b2 /src/ats | |
parent | db44a89fcb29d88b309436b61f330149c923e1a9 (diff) | |
download | gnunet-2f8be33175a8a018363e512a8f1dac9d9065a41d.tar.gz gnunet-2f8be33175a8a018363e512a8f1dac9d9065a41d.zip |
fix matrix init
Diffstat (limited to 'src/ats')
-rwxr-xr-x | src/ats/plugin_ats_ril.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c index 46ce3491d..a1ea939f1 100755 --- a/src/ats/plugin_ats_ril.c +++ b/src/ats/plugin_ats_ril.c | |||
@@ -404,7 +404,7 @@ agent_estimate_q (struct RIL_Peer_Agent *agent, double *state, int action) | |||
404 | 404 | ||
405 | if (isinf(result)) | 405 | if (isinf(result)) |
406 | { | 406 | { |
407 | return isinf(result) * UINT32_MAX; //TODO! fix | 407 | return isinf(result) * UINT32_MAX; //TODO! prevent crash when learning diverges |
408 | } | 408 | } |
409 | return result; | 409 | return result; |
410 | } | 410 | } |
@@ -541,14 +541,14 @@ agent_update_weights (struct RIL_Peer_Agent *agent, double reward, double *s_nex | |||
541 | delta += agent->envi->global_discount_variable * agent_estimate_q (agent, s_next, a_prime); //discounted future value | 541 | delta += agent->envi->global_discount_variable * agent_estimate_q (agent, s_next, a_prime); //discounted future value |
542 | delta -= agent_estimate_q (agent, agent->s_old, agent->a_old); //one step | 542 | delta -= agent_estimate_q (agent, agent->s_old, agent->a_old); //one step |
543 | 543 | ||
544 | LOG(GNUNET_ERROR_TYPE_INFO, "update() Step# %llu Q(s,a): %f a: %f r: %f y: %f Q(s+1,a+1) = %f delta: %f\n", | 544 | // LOG(GNUNET_ERROR_TYPE_INFO, "update() Step# %llu Q(s,a): %f a: %f r: %f y: %f Q(s+1,a+1) = %f delta: %f\n", |
545 | agent->step_count, | 545 | // agent->step_count, |
546 | agent_estimate_q (agent, agent->s_old, agent->a_old), | 546 | // agent_estimate_q (agent, agent->s_old, agent->a_old), |
547 | agent->envi->parameters.alpha, | 547 | // agent->envi->parameters.alpha, |
548 | reward, | 548 | // reward, |
549 | agent->envi->global_discount_variable, | 549 | // agent->envi->global_discount_variable, |
550 | agent_estimate_q (agent, s_next, a_prime), | 550 | // agent_estimate_q (agent, s_next, a_prime), |
551 | delta); | 551 | // delta); |
552 | 552 | ||
553 | for (i = 0; i < agent->m; i++) | 553 | for (i = 0; i < agent->m; i++) |
554 | { | 554 | { |
@@ -782,11 +782,11 @@ envi_get_state (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) | |||
782 | { | 782 | { |
783 | state[1] = 0; | 783 | state[1] = 0; |
784 | } | 784 | } |
785 | LOG(GNUNET_ERROR_TYPE_INFO, "get_state() state[0] = %f\n", state[0]); | 785 | // LOG(GNUNET_ERROR_TYPE_INFO, "get_state() state[0] = %f\n", state[0]); |
786 | LOG(GNUNET_ERROR_TYPE_INFO, "get_state() state[1] = %f\n", state[1]); | 786 | // LOG(GNUNET_ERROR_TYPE_INFO, "get_state() state[1] = %f\n", state[1]); |
787 | 787 | // | |
788 | LOG(GNUNET_ERROR_TYPE_INFO, "get_state() W / %08.3f %08.3f \\ \n", agent->W[0][0], agent->W[1][0]); | 788 | // LOG(GNUNET_ERROR_TYPE_INFO, "get_state() W / %08.3f %08.3f \\ \n", agent->W[0][0], agent->W[1][0]); |
789 | LOG(GNUNET_ERROR_TYPE_INFO, "get_state() W \\ %08.3f %08.3f / \n", agent->W[0][1], agent->W[1][1]); | 789 | // LOG(GNUNET_ERROR_TYPE_INFO, "get_state() W \\ %08.3f %08.3f / \n", agent->W[0][1], agent->W[1][1]); |
790 | 790 | ||
791 | 791 | ||
792 | //get peer features | 792 | //get peer features |
@@ -1287,12 +1287,12 @@ agent_step (struct RIL_Peer_Agent *agent) | |||
1287 | 1287 | ||
1288 | agent_modify_eligibility (agent, RIL_E_ACCUMULATE, s_next); | 1288 | agent_modify_eligibility (agent, RIL_E_ACCUMULATE, s_next); |
1289 | 1289 | ||
1290 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "step() Step# %llu R: %f IN %llu OUT %llu A: %d\n", | 1290 | // GNUNET_log (GNUNET_ERROR_TYPE_INFO, "step() Step# %llu R: %f IN %llu OUT %llu A: %d\n", |
1291 | agent->step_count, | 1291 | // agent->step_count, |
1292 | reward, | 1292 | // reward, |
1293 | agent->bw_in/1024, | 1293 | // agent->bw_in/1024, |
1294 | agent->bw_out/1024, | 1294 | // agent->bw_out/1024, |
1295 | a_next); | 1295 | // a_next); |
1296 | 1296 | ||
1297 | envi_do_action (agent->envi, agent, a_next); | 1297 | envi_do_action (agent->envi, agent, a_next); |
1298 | 1298 | ||
@@ -1598,7 +1598,7 @@ agent_w_start (struct RIL_Peer_Agent *agent) | |||
1598 | for (k = 0; k < agent->m; k++) | 1598 | for (k = 0; k < agent->m; k++) |
1599 | { | 1599 | { |
1600 | if (0 == count) { | 1600 | if (0 == count) { |
1601 | agent->W[i][k] = 1;//.1 - ((double) GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX/5)/(double)UINT32_MAX); | 1601 | agent->W[i][k] = agent->envi->parameters.alpha * (1.0 - 2.0*((double) GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX)/(double)UINT32_MAX)); |
1602 | } | 1602 | } |
1603 | else { | 1603 | else { |
1604 | for (other = agent->envi->agents_head; NULL != other; other = other->next) | 1604 | for (other = agent->envi->agents_head; NULL != other; other = other->next) |