From 03f90c3e7c5d6e4bcabef18de9f6b4e5d7e77e45 Mon Sep 17 00:00:00 2001 From: Fabian Oehlmann Date: Thu, 9 Jan 2014 17:56:41 +0000 Subject: [PATCH] keep addresses inuse --- src/ats/plugin_ats_ril.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c index e452ca30a..da974dd72 100755 --- a/src/ats/plugin_ats_ril.c +++ b/src/ats/plugin_ats_ril.c @@ -495,11 +495,14 @@ static int agent_get_action_max (struct RIL_Peer_Agent *agent, double *state) { int i; + int num_actions; int max_i = RIL_ACTION_INVALID; double cur_q; double max_q = -DBL_MAX; - for (i = 0; i < agent->n; i++) + num_actions = agent->address_inuse->used ? RIL_ACTION_TYPE_NUM : agent->n; + + for (i = 0; i < num_actions; i++) { cur_q = agent_estimate_q (agent, state, i); if (cur_q > max_q) @@ -1170,19 +1173,22 @@ static int agent_select_egreedy (struct RIL_Peer_Agent *agent, double *state) { int action; + int num_actions; double r = (double) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX) / (double) UINT32_MAX; - if (r < agent->envi->parameters.explore_ratio) + num_actions = agent->address_inuse->used ? RIL_ACTION_TYPE_NUM : agent->n; + + if (r < agent->envi->parameters.explore_ratio) //explore { - action = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, agent->n); + action = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_actions); if (RIL_ALGO_Q == agent->envi->parameters.algorithm) { agent_modify_eligibility(agent, RIL_E_ZERO, NULL, action); } return action; } - else + else //exploit { action = agent_get_action_max(agent, state); if (RIL_ALGO_Q == agent->envi->parameters.algorithm) @@ -1208,26 +1214,29 @@ agent_select_softmax (struct RIL_Peer_Agent *agent, double *state) { int i; int a_max; + int num_actions; double eqt[agent->n]; double p[agent->n]; double sum = 0; double r; + num_actions = agent->address_inuse->used ? RIL_ACTION_TYPE_NUM : agent->n; + a_max = agent_get_action_max(agent, state); - for (i=0; in; i++) + for (i=0; ienvi->parameters.temperature); sum += eqt[i]; } - for (i=0; in; i++) + for (i=0; in; i++) + for (i=0; i r) { @@ -2292,9 +2301,6 @@ GAS_ril_address_session_changed (void *solver, uint32_t cur_session, uint32_t new_session) { - /* - * TODO? Future Work: Potentially add session activity as a feature in state vector - */ LOG(GNUNET_ERROR_TYPE_DEBUG, "API_address_session_changed()\n"); } @@ -2311,9 +2317,6 @@ GAS_ril_address_session_changed (void *solver, void GAS_ril_address_inuse_changed (void *solver, struct ATS_Address *address, int in_use) { - /* - * TODO? Future Work: Potentially add usage variable to state vector - */ LOG(GNUNET_ERROR_TYPE_DEBUG, "API_address_inuse_changed() Usage for %s address of peer '%s' changed to %s\n", address->plugin, GNUNET_i2s (&address->peer), (GNUNET_YES == in_use) ? "USED" : "UNUSED"); -- 2.25.1