#define LOG(kind,...) GNUNET_log_from (kind, "ats-ril",__VA_ARGS__)
-#define RIL_MIN_BW ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__)
-#define RIL_MAX_BW 1024 * 1000//GNUNET_ATS_MaxBandwidth TODO! revert
+#define RIL_MIN_BW (5 * ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__))
+#define RIL_MAX_BW GNUNET_ATS_MaxBandwidth
#define RIL_ACTION_INVALID -1
#define RIL_INTERVAL_EXPONENT 10
-#define RIL_UTILITY_DELAY_MAX 100
-
-#define RIL_DEFAULT_STEP_TIME_MIN GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500)
-#define RIL_DEFAULT_STEP_TIME_MAX GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 3000)
-#define RIL_DEFAULT_ALGORITHM RIL_ALGO_Q
-#define RIL_DEFAULT_SELECT RIL_SELECT_EGREEDY
-#define RIL_DEFAULT_WELFARE RIL_WELFARE_EGALITARIAN
-#define RIL_DEFAULT_DISCOUNT_BETA 1.0
+#define RIL_UTILITY_DELAY_MAX 1000
+
+#define RIL_DEFAULT_STEP_TIME_MIN GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 200)
+#define RIL_DEFAULT_STEP_TIME_MAX GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 2000)
+#define RIL_DEFAULT_ALGORITHM RIL_ALGO_SARSA
+#define RIL_DEFAULT_SELECT RIL_SELECT_SOFTMAX
+#define RIL_DEFAULT_WELFARE RIL_WELFARE_NASH
+#define RIL_DEFAULT_DISCOUNT_BETA 0.6
#define RIL_DEFAULT_DISCOUNT_GAMMA 0.5
-#define RIL_DEFAULT_GRADIENT_STEP_SIZE 0.1
+#define RIL_DEFAULT_GRADIENT_STEP_SIZE 0.01
#define RIL_DEFAULT_TRACE_DECAY 0.5
-#define RIL_DEFAULT_EXPLORE_RATIO 0.1
-#define RIL_DEFAULT_RBF_DIVISOR 10
-#define RIL_DEFAULT_GLOBAL_REWARD_SHARE 0.5
-#define RIL_DEFAULT_TEMPERATURE 1.0
+#define RIL_DEFAULT_EXPLORE_RATIO 1
+#define RIL_DEFAULT_EXPLORE_DECAY 0.95
+#define RIL_DEFAULT_RBF_DIVISOR 50
+#define RIL_DEFAULT_TEMPERATURE 0.1
+#define RIL_DEFAULT_TEMPERATURE_DECAY 1
#define RIL_INC_DEC_STEP_SIZE 1
-#define RIL_NOP_BONUS 0.5
+#define RIL_NOP_DECAY 0.5
/**
* ATS reinforcement learning solver
enum RIL_Action_Type
{
RIL_ACTION_NOTHING = 0,
- RIL_ACTION_BW_IN_DBL = -2, //TODO! put actions back
+ RIL_ACTION_BW_IN_DBL = -2, //TODO? Potentially add more actions
RIL_ACTION_BW_IN_HLV = -3,
RIL_ACTION_BW_IN_INC = 1,
RIL_ACTION_BW_IN_DEC = 2,
enum RIL_E_Modification
{
- RIL_E_DISCOUNT,
+ RIL_E_DECAY,
RIL_E_ZERO,
RIL_E_ACCUMULATE,
RIL_E_REPLACE
*/
enum RIL_E_Modification eligibility_trace_mode;
+ /**
+ * Initial softmax action-selection temperature
+ */
+ double temperature_init;
+
/**
* Softmax action-selection temperature
*/
double temperature;
+ /**
+ * Decay factor of the temperature value
+ */
+ double temperature_decay;
+
/**
* Which measure of social welfare should be used
*/
*/
enum RIL_Select select;
+ /**
+ * Initial exploration ratio value
+ */
+ double epsilon_init;
+
/**
* Ratio, with what probability an agent should explore in the e-greed policy
*/
- double explore_ratio;
+ double epsilon;
/**
- * How big the share of the global part of the reward signal is
+ * Decay factor of the explore ratio
*/
- double reward_global_share;
+ double epsilon_decay;
/**
* Minimal interval time between steps in milliseconds
* The address
*/
struct ATS_Address *address_naked;
-
- /**
- * Last inbound bandwidth used
- */
- unsigned long long bw_in;
-
- /**
- * Last outbound bandwidth used
- */
- unsigned long long bw_out;
-
};
struct RIL_Peer_Agent
/**
* Number of active agents in scope
*/
- unsigned int agent_count;
+ unsigned int active_agent_count;
/**
* The social welfare achieved in the scope
break;
case RIL_ACTION_BW_IN_DEC:
case RIL_ACTION_BW_IN_HLV:
- if (agent->bw_in <= RIL_MIN_BW)
+ if (agent->bw_in <= 0)
return GNUNET_NO;
else
return GNUNET_YES;
break;
case RIL_ACTION_BW_OUT_DEC:
case RIL_ACTION_BW_OUT_HLV:
- if (agent->bw_out <= RIL_MIN_BW)
+ if (agent->bw_out <= 0)
return GNUNET_NO;
else
return GNUNET_YES;
}
GNUNET_assert(GNUNET_NO);
+ return RIL_ACTION_INVALID;
}
* Changes the eligibility trace vector e in various manners:
* #RIL_E_ACCUMULATE - adds @a feature to each component as in accumulating eligibility traces
* #RIL_E_REPLACE - resets each component to @a feature as in replacing traces
- * #RIL_E_DISCOUNT - multiplies e with discount factor and lambda as in the update rule
+ * #RIL_E_DECAY - multiplies e with discount factor and lambda as in the update rule
* #RIL_E_ZERO - sets e to 0 as in Watkin's Q-learning algorithm when exploring and when initializing
*
* @param agent the agent handle
* @param mod the kind of modification
* @param feature the feature vector
+ * @param action the action to take
*/
static void
agent_modify_eligibility (struct RIL_Peer_Agent *agent,
case RIL_E_REPLACE:
agent->E[action][i] = agent->E[action][i] > feature[i] ? agent->E[action][i] : feature[i];
break;
- case RIL_E_DISCOUNT:
+ case RIL_E_DECAY:
for (k = 0; k < agent->n; k++)
{
agent->E[k][i] *= agent->envi->global_discount_variable * agent->envi->parameters.lambda;
solver->plugin_envi->info_cb (solver->plugin_envi->info_cb_cls, op, stat, GAS_INFO_NONE);
}
+/**
+ * Calculates the maximum bandwidth an agent can assign in a network scope
+ *
+ * @param net
+ */
+static unsigned long long
+ril_get_max_bw (struct RIL_Scope *net)
+{
+ return GNUNET_MIN(2 * GNUNET_MAX(net->bw_in_available, net->bw_out_available), GNUNET_ATS_MaxBandwidth);
+}
/**
* Changes the active assignment suggestion of the handler and invokes the bw_changed callback to
state = GNUNET_malloc (sizeof(double) * agent->m);
- max_bw = RIL_MAX_BW;
+ max_bw = ril_get_max_bw((struct RIL_Scope *) agent->address_inuse->solver_information);
y[0] = (double) agent->bw_out;
y[1] = (double) agent->bw_in;
delay_atsi = (double) ril_get_atsi (agent->address_inuse, GNUNET_ATS_QUALITY_NET_DELAY);
delay_norm = RIL_UTILITY_DELAY_MAX*exp(-delay_atsi*0.00001);
- pref_match = (preferences[GNUNET_ATS_PREFERENCE_LATENCY] * delay_norm);
- pref_match += (preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] * (double) (agent->bw_in/RIL_MIN_BW));
- pref_match += (preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] * (double) (agent->bw_out/RIL_MIN_BW));
+ pref_match = preferences[GNUNET_ATS_PREFERENCE_LATENCY] * delay_norm;
+ pref_match += preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] *
+ sqrt((double) (agent->bw_in/RIL_MIN_BW) * (double) (agent->bw_out/RIL_MIN_BW));
+// sqrt((double) (ril_get_atsi (agent->address_inuse, GNUNET_ATS_UTILIZATION_IN)/RIL_MIN_BW) * (double) (ril_get_atsi (agent->address_inuse, GNUNET_ATS_UTILIZATION_OUT)/RIL_MIN_BW));
// return (double) (agent->bw_in/RIL_MIN_BW);
// return sqrt((double) (agent->bw_in/RIL_MIN_BW) * (double) (agent->bw_out/RIL_MIN_BW));
{
if (cur->is_active && cur->address_inuse && (cur->address_inuse->solver_information == scope))
{
- result *= pow(agent_get_utility(cur), 1.0 / (double) scope->agent_count);
+ result *= pow(agent_get_utility(cur), 1.0 / (double) scope->active_agent_count);
}
}
return result;
return 1;
}
-//static double
-//envi_penalty_share (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent)
-//{
-// struct RIL_Scope *net;
-// double util_ratio_in;
-// double util_ratio_out;
-// double util_ratio_max;
-// double sigmoid_x;
-//
-// net = agent->address_inuse->solver_information;
-//
-// util_ratio_in = (double) net->bw_in_utilized / (double) net->bw_in_available;
-// util_ratio_out = (double) net->bw_out_utilized / (double) net->bw_out_available;
-// util_ratio_max = GNUNET_MAX (util_ratio_in, util_ratio_out);
-// sigmoid_x = util_ratio_max - 1;
-// return 1 - (1 / (1 + exp(5 * sigmoid_x)));
-//}
-
static double
envi_get_penalty (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent)
{
over_out *= 2;
}
}
- over_max = GNUNET_MAX (over_in , over_out) / RIL_MIN_BW;
+ over_max = (over_in + over_out) / RIL_MIN_BW;
return -1.0 * (double) over_max;
}
double objective;
double delta;
double steady;
- double pen_share;
double penalty;
double reward;
net = agent->address_inuse->solver_information;
+ penalty = envi_get_penalty(solver, agent);
objective = (agent_get_utility (agent) + net->social_welfare) / 2;
delta = objective - agent->objective_old;
agent->objective_old = objective;
- if (delta != 0)
+ if (delta != 0 && penalty == 0)
+ {
+ agent->nop_bonus = delta * RIL_NOP_DECAY;
+ }
+ else
{
- agent->nop_bonus = delta * 0.5;
+ agent->nop_bonus *= RIL_NOP_DECAY;
}
steady = (RIL_ACTION_NOTHING == agent->a_old) ? agent->nop_bonus : 0;
- //pen_share = envi_penalty_share(solver, agent); TODO revert
- pen_share = 0.5;
- penalty = envi_get_penalty(solver, agent);
-
reward = delta + steady;
- return ((1 - pen_share) * reward) + (pen_share * penalty);
+ return reward + penalty;
}
/**
int direction_in)
{
unsigned long long new_bw;
+ unsigned long long max_bw;
+
+ max_bw = ril_get_max_bw((struct RIL_Scope *) agent->address_inuse->solver_information);
if (direction_in)
{
new_bw = agent->bw_in * 2;
- if (new_bw < agent->bw_in || new_bw > RIL_MAX_BW)
- new_bw = RIL_MAX_BW;
+ if (new_bw < agent->bw_in || new_bw > max_bw)
+ new_bw = max_bw;
envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw,
agent->bw_out, GNUNET_NO);
}
else
{
new_bw = agent->bw_out * 2;
- if (new_bw < agent->bw_out || new_bw > RIL_MAX_BW)
- new_bw = RIL_MAX_BW;
+ if (new_bw < agent->bw_out || new_bw > max_bw)
+ new_bw = max_bw;
envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in,
new_bw, GNUNET_NO);
}
if (direction_in)
{
new_bw = agent->bw_in / 2;
- if (new_bw < RIL_MIN_BW || new_bw > agent->bw_in)
- new_bw = RIL_MIN_BW;
+ if (new_bw <= 0 || new_bw > agent->bw_in)
+ new_bw = 0;
envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw, agent->bw_out,
GNUNET_NO);
}
else
{
new_bw = agent->bw_out / 2;
- if (new_bw < RIL_MIN_BW || new_bw > agent->bw_out)
- new_bw = RIL_MIN_BW;
+ if (new_bw <= 0 || new_bw > agent->bw_out)
+ new_bw = 0;
envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in, new_bw,
GNUNET_NO);
}
envi_action_bw_inc (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent, int direction_in)
{
unsigned long long new_bw;
+ unsigned long long max_bw;
+
+ max_bw = ril_get_max_bw((struct RIL_Scope *) agent->address_inuse->solver_information);
if (direction_in)
{
new_bw = agent->bw_in + (RIL_INC_DEC_STEP_SIZE * RIL_MIN_BW);
- if (new_bw < agent->bw_in || new_bw > RIL_MAX_BW)
- new_bw = RIL_MAX_BW;
+ if (new_bw < agent->bw_in || new_bw > max_bw)
+ new_bw = max_bw;
envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw,
agent->bw_out, GNUNET_NO);
}
else
{
new_bw = agent->bw_out + (RIL_INC_DEC_STEP_SIZE * RIL_MIN_BW);
- if (new_bw < agent->bw_out || new_bw > RIL_MAX_BW)
- new_bw = RIL_MAX_BW;
+ if (new_bw < agent->bw_out || new_bw > max_bw)
+ new_bw = max_bw;
envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in,
new_bw, GNUNET_NO);
}
if (direction_in)
{
new_bw = agent->bw_in - (RIL_INC_DEC_STEP_SIZE * RIL_MIN_BW);
- if (new_bw < RIL_MIN_BW || new_bw > agent->bw_in)
- new_bw = RIL_MIN_BW;
+ if (new_bw <= 0 || new_bw > agent->bw_in)
+ new_bw = 0;
envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw, agent->bw_out,
GNUNET_NO);
}
else
{
new_bw = agent->bw_out - (RIL_INC_DEC_STEP_SIZE * RIL_MIN_BW);
- if (new_bw < RIL_MIN_BW || new_bw > agent->bw_out)
- new_bw = RIL_MIN_BW;
+ if (new_bw <= 0 || new_bw > agent->bw_out)
+ new_bw = 0;
envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in, new_bw,
GNUNET_NO);
}
int i = 0;
cur = agent_address_get_wrapped(agent, agent->address_inuse);
- cur->bw_in = agent->bw_in;
- cur->bw_out = agent->bw_out;
for (cur = agent->addresses_head; NULL != cur; cur = cur->next)
{
if (i == address_index)
{
- envi_set_active_suggestion (solver, agent, cur->address_naked, cur->bw_in, cur->bw_out,
+ envi_set_active_suggestion (solver, agent, cur->address_naked, agent->bw_in, agent->bw_out,
GNUNET_NO);
return;
}
double r = (double) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
UINT32_MAX) / (double) UINT32_MAX;
- if (r < agent->envi->parameters.explore_ratio) //explore
+ if (r < agent->envi->parameters.epsilon) //explore
{
action = agent_get_action_random(agent);
if (RIL_ALGO_Q == agent->envi->parameters.algorithm)
{
agent->eligibility_reset = GNUNET_YES;
}
+ agent->envi->parameters.epsilon *= agent->envi->parameters.epsilon_decay;
return action;
}
else //exploit
{
if (sum + p[i] > r)
{
- if (RIL_ALGO_Q == agent->envi->parameters.algorithm)
+ if (i != a_max)
{
- if (i != a_max)
+ if (RIL_ALGO_Q == agent->envi->parameters.algorithm)
agent->eligibility_reset = GNUNET_YES;
+ agent->envi->parameters.temperature *= agent->envi->parameters.temperature_decay;
}
return i;
}
sum += p[i];
}
GNUNET_assert(GNUNET_NO);
+ return RIL_ACTION_INVALID;
}
/**
}
else
{
- agent_modify_eligibility (agent, RIL_E_DISCOUNT, NULL, -1);
+ agent_modify_eligibility (agent, RIL_E_DECAY, NULL, -1);
}
if (RIL_ACTION_INVALID != agent->a_old)
{
net = solver->network_entries[i];
if (net.bw_in_assigned > 0) //only consider scopes where an address is actually active
{
- sum_assigned += net.bw_in_assigned;
- sum_assigned += net.bw_out_assigned;
+ sum_assigned += net.bw_in_utilized;
+ sum_assigned += net.bw_out_utilized;
sum_available += net.bw_in_available;
sum_available += net.bw_out_available;
}
ratio = 0;
}
- return ratio > 1 ? 1 : ratio; //overassignment is possible, cap at 1
+ return ratio > 1 ? 1 : ratio; //overutilization is possible, cap at 1
}
/**
{
struct RIL_Address_Wrapped *addr_wrap;
struct RIL_Scope *net;
+ unsigned long long start_in;
+ unsigned long long start_out;
for (addr_wrap = agent->addresses_head; NULL != addr_wrap; addr_wrap = addr_wrap->next)
{
if (ril_network_is_not_full(solver, net->type))
{
if (NULL == agent->address_inuse)
- envi_set_active_suggestion (solver, agent, addr_wrap->address_naked, RIL_MIN_BW, RIL_MIN_BW, silent);
+ {
+ start_in = net->bw_in_available < net->bw_in_utilized ? (net->bw_in_available - net->bw_in_utilized) / 2 : RIL_MIN_BW;
+ start_out = net->bw_out_available < net->bw_out_utilized ? (net->bw_out_available - net->bw_out_utilized) / 2 : RIL_MIN_BW;
+ envi_set_active_suggestion (solver, agent, addr_wrap->address_naked, start_in, start_out, silent);
+ }
return;
}
}
struct GNUNET_TIME_Relative time_delta;
double tau;
- // MDP case - TODO remove when debugged
+ // MDP case only for debugging purposes
if (solver->simulate)
{
solver->global_discount_variable = solver->parameters.gamma;
net->bw_in_utilized = ril_network_get_utilized(solver, net->type, GNUNET_YES);
net->bw_out_assigned = ril_network_get_assigned(solver, net->type, GNUNET_NO);
net->bw_out_utilized = ril_network_get_utilized(solver, net->type, GNUNET_NO);
- net->agent_count = ril_network_count_active_agents(solver, net);
+ net->active_agent_count = ril_network_count_active_agents(solver, net);
net->social_welfare = ril_network_get_social_welfare(solver, net);
}
}
time_next = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS, (unsigned long long) y);
- LOG (GNUNET_ERROR_TYPE_INFO, "ratio: %f, factor: %f, offset: %f, y: %f\n",
- used_ratio,
- factor,
- offset,
- y);
+// LOG (GNUNET_ERROR_TYPE_INFO, "ratio: %f, factor: %f, offset: %f, y: %f\n",
+// used_ratio,
+// factor,
+// offset,
+// y);
if (solver->simulate)
{
"API_address_change_preference() Preference '%s' for peer '%s' changed to %.2f \n",
GNUNET_ATS_print_preference_type (kind), GNUNET_i2s (peer), pref_rel);
- ril_step (solver);
+ struct GAS_RIL_Handle *s = solver;
+
+ s->parameters.temperature = s->parameters.temperature_init;
+ s->parameters.epsilon = s->parameters.epsilon_init;
+ ril_step (s);
}
/**
{
solver->parameters.rbf_divisor = RIL_DEFAULT_RBF_DIVISOR;
}
+
if (GNUNET_OK
!= GNUNET_CONFIGURATION_get_value_time (env->cfg, "ats", "RIL_STEP_TIME_MIN",
&solver->parameters.step_time_min))
{
solver->parameters.step_time_min = RIL_DEFAULT_STEP_TIME_MIN;
}
+
if (GNUNET_OK
!= GNUNET_CONFIGURATION_get_value_time (env->cfg, "ats", "RIL_STEP_TIME_MAX",
&solver->parameters.step_time_max))
{
solver->parameters.step_time_max = RIL_DEFAULT_STEP_TIME_MAX;
}
+
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_ALGORITHM", &string))
{
solver->parameters.algorithm = !strcmp (string, "SARSA") ? RIL_ALGO_SARSA : RIL_ALGO_Q;
{
solver->parameters.algorithm = RIL_DEFAULT_ALGORITHM;
}
+
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_SELECT", &string))
{
solver->parameters.select = !strcmp (string, "EGREEDY") ? RIL_SELECT_EGREEDY : RIL_SELECT_SOFTMAX;
{
solver->parameters.select = RIL_DEFAULT_SELECT;
}
+
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_DISCOUNT_BETA", &string))
{
solver->parameters.beta = strtod (string, NULL);
{
solver->parameters.beta = RIL_DEFAULT_DISCOUNT_BETA;
}
+
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_DISCOUNT_GAMMA", &string))
{
solver->parameters.gamma = strtod (string, NULL);
{
solver->parameters.gamma = RIL_DEFAULT_DISCOUNT_GAMMA;
}
+
if (GNUNET_OK
== GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_GRADIENT_STEP_SIZE", &string))
{
{
solver->parameters.alpha = RIL_DEFAULT_GRADIENT_STEP_SIZE;
}
+
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_TRACE_DECAY", &string))
{
solver->parameters.lambda = strtod (string, NULL);
{
solver->parameters.lambda = RIL_DEFAULT_TRACE_DECAY;
}
+
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_EXPLORE_RATIO", &string))
{
- solver->parameters.explore_ratio = strtod (string, NULL);
+ solver->parameters.epsilon_init = strtod (string, NULL);
GNUNET_free (string);
- if (solver->parameters.explore_ratio < 0 || solver->parameters.explore_ratio > 1)
+ if (solver->parameters.epsilon_init < 0 || solver->parameters.epsilon_init > 1)
{
LOG (GNUNET_ERROR_TYPE_WARNING, "RIL_EXPLORE_RATIO not configured in range [0,1]. Set to default value of %f instead.\n", RIL_DEFAULT_EXPLORE_RATIO);
- solver->parameters.explore_ratio = RIL_DEFAULT_EXPLORE_RATIO;
+ solver->parameters.epsilon_init = RIL_DEFAULT_EXPLORE_RATIO;
}
}
else
{
- solver->parameters.explore_ratio = RIL_DEFAULT_EXPLORE_RATIO;
+ solver->parameters.epsilon_init = RIL_DEFAULT_EXPLORE_RATIO;
}
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_GLOBAL_REWARD_SHARE", &string))
+
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_EXPLORE_DECAY", &string))
{
- solver->parameters.reward_global_share = strtod (string, NULL);
+ solver->parameters.epsilon_decay = strtod (string, NULL);
GNUNET_free (string);
- if (solver->parameters.reward_global_share < 0 || solver->parameters.reward_global_share > 1)
+ if (solver->parameters.epsilon_decay < 0 || solver->parameters.epsilon_decay > 1)
{
- LOG (GNUNET_ERROR_TYPE_WARNING, "RIL_GLOBAL_REWARD_SHARE not configured in range [0,1]. Set to default value of %f instead.\n", RIL_DEFAULT_GLOBAL_REWARD_SHARE);
- solver->parameters.reward_global_share = RIL_DEFAULT_GLOBAL_REWARD_SHARE;
+ LOG (GNUNET_ERROR_TYPE_WARNING, "RIL_EXPLORE_RATIO not configured in range [0,1]. Set to default value of %f instead.\n", RIL_DEFAULT_EXPLORE_DECAY);
+ solver->parameters.epsilon_decay = RIL_DEFAULT_EXPLORE_DECAY;
}
}
else
{
- solver->parameters.reward_global_share = RIL_DEFAULT_GLOBAL_REWARD_SHARE;
+ solver->parameters.epsilon_decay = RIL_DEFAULT_EXPLORE_DECAY;
}
+
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_TEMPERATURE", &string))
{
- solver->parameters.temperature = strtod (string, NULL);
+ solver->parameters.temperature_init = strtod (string, NULL);
GNUNET_free (string);
- if (solver->parameters.temperature <= 0)
+ if (solver->parameters.temperature_init <= 0)
{
LOG (GNUNET_ERROR_TYPE_WARNING, "RIL_TEMPERATURE not positive. Set to default value of %f instead.\n", RIL_DEFAULT_TEMPERATURE);
- solver->parameters.temperature = RIL_DEFAULT_TEMPERATURE;
+ solver->parameters.temperature_init = RIL_DEFAULT_TEMPERATURE;
+ }
+ }
+ else
+ {
+ solver->parameters.temperature_init = RIL_DEFAULT_TEMPERATURE;
+ }
+
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_TEMPERATURE_DECAY", &string))
+ {
+ solver->parameters.temperature_decay = strtod (string, NULL);
+ GNUNET_free (string);
+ if (solver->parameters.temperature_decay <= 0 || solver->parameters.temperature_decay > 1)
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING, "RIL_TEMPERATURE_DECAY not in range [0,1]. Set to default value of %f instead.\n", RIL_DEFAULT_TEMPERATURE_DECAY);
+ solver->parameters.temperature_decay = RIL_DEFAULT_TEMPERATURE_DECAY;
}
}
else
{
- solver->parameters.temperature = RIL_DEFAULT_TEMPERATURE;
+ solver->parameters.temperature_decay = RIL_DEFAULT_TEMPERATURE_DECAY;
}
+
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg, "ats", "RIL_SIMULATE", &solver->simulate))
{
solver->simulate = GNUNET_NO;
}
+
if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(env->cfg, "ats", "RIL_REPLACE_TRACES"))
{
solver->parameters.eligibility_trace_mode = RIL_E_REPLACE;
{
solver->parameters.eligibility_trace_mode = RIL_E_ACCUMULATE;
}
+
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_SOCIAL_WELFARE", &string))
{
solver->parameters.social_welfare = !strcmp (string, "NASH") ? RIL_WELFARE_NASH : RIL_WELFARE_EGALITARIAN;
solver->parameters.alpha,
solver->parameters.beta,
solver->parameters.lambda);
- LOG(GNUNET_ERROR_TYPE_DEBUG, "init() exploration_ratio = %f, temperature = %f, ActionSelection = %s, global_share = %f\n",
- solver->parameters.explore_ratio,
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "init() exploration_ratio = %f, temperature = %f, ActionSelection = %s\n",
+ solver->parameters.epsilon,
solver->parameters.temperature,
- solver->parameters.select ? "EGREEDY" : "SOFTMAX",
- solver->parameters.reward_global_share);
+ solver->parameters.select ? "EGREEDY" : "SOFTMAX");
LOG(GNUNET_ERROR_TYPE_DEBUG, "init() RBF_DIVISOR = %llu\n",
solver->parameters.rbf_divisor);
return;
}
+ s->parameters.temperature = s->parameters.temperature_init;
+ s->parameters.epsilon = s->parameters.epsilon_init;
+
agent = ril_get_agent (s, &address->peer, GNUNET_YES);
//add address
address_wrapped = GNUNET_new (struct RIL_Address_Wrapped);
address_wrapped->address_naked = address;
- address_wrapped->bw_in = RIL_MIN_BW;
- address_wrapped->bw_out = RIL_MIN_BW;
GNUNET_CONTAINER_DLL_insert_tail(agent->addresses_head, agent->addresses_tail, address_wrapped);
//increase size of W
return;
}
+ s->parameters.temperature = s->parameters.temperature_init;
+ s->parameters.epsilon = s->parameters.epsilon_init;
+
address_index = agent_address_get_index (agent, address);
address_wrapped = agent_address_get_wrapped (agent, address);
if (NULL == address_wrapped)
{
net = address->solver_information;
- GNUNET_assert(!ril_network_is_active (s, net->type));
LOG(GNUNET_ERROR_TYPE_DEBUG,
"Address not considered by agent, address was in inactive network\n");
return;
{
if (NULL != agent->addresses_head) //if peer has an address left, use it
{
- envi_set_active_suggestion (s, agent, agent->addresses_head->address_naked, RIL_MIN_BW, RIL_MIN_BW,
- GNUNET_NO);
+ envi_set_active_suggestion (s, agent, agent->addresses_head->address_naked, agent->bw_in, agent->bw_out,
+ GNUNET_YES);
}
else
{
"to %.2f \n", GNUNET_ATS_print_property_type (type), GNUNET_i2s (&address->peer),
address->addr, rel_value);
- ril_step (solver);
+ struct GAS_RIL_Handle *s = solver;
+
+ s->parameters.temperature = s->parameters.temperature_init;
+ s->parameters.epsilon = s->parameters.epsilon_init;
+ ril_step (s);
}
/**
(GNUNET_YES == address->active) ? "active" : "inactive", GNUNET_i2s (&address->peer),
GNUNET_ATS_print_network_type (current_network), GNUNET_ATS_print_network_type (new_network));
+ s->parameters.temperature = s->parameters.temperature_init;
+ s->parameters.epsilon = s->parameters.epsilon_init;
+
if (address->active && !ril_network_is_active (solver, new_network))
{
GAS_ril_address_delete (solver, address, GNUNET_NO);
const struct ATS_Address *
GAS_ril_get_preferred_address (void *solver, const struct GNUNET_PeerIdentity *peer)
{
- /*
- * activate agent, return currently chosen address
- */
struct GAS_RIL_Handle *s = solver;
struct RIL_Peer_Agent *agent;
LOG(GNUNET_ERROR_TYPE_DEBUG,
"API_get_preferred_address() Activated agent for peer '%s', but no address available\n",
GNUNET_i2s (peer));
+ s->parameters.temperature = s->parameters.temperature_init;
+ s->parameters.epsilon = s->parameters.epsilon_init;
}
-
return agent->address_inuse;
}
return;
}
+ s->parameters.temperature = s->parameters.temperature_init;
+ s->parameters.epsilon = s->parameters.epsilon_init;
+
agent->is_active = GNUNET_NO;
envi_set_active_suggestion (s, agent, agent->address_inuse, agent->bw_in, agent->bw_out,