diff options
author | Fabian Oehlmann <oehlmann@in.tum.de> | 2014-02-03 13:52:04 +0000 |
---|---|---|
committer | Fabian Oehlmann <oehlmann@in.tum.de> | 2014-02-03 13:52:04 +0000 |
commit | 75eb399d7da396ea56d274fc6b915b0956764f8e (patch) | |
tree | b7cec1ffcaee6a6cb80303aaef853ad117a07e99 /src/ats/plugin_ats_ril.c | |
parent | ebe39f090885f05281952836caf207c576ba8625 (diff) | |
download | gnunet-75eb399d7da396ea56d274fc6b915b0956764f8e.tar.gz gnunet-75eb399d7da396ea56d274fc6b915b0956764f8e.zip |
-minor renamings
-default parameters set to better values
-exploration decay added
Diffstat (limited to 'src/ats/plugin_ats_ril.c')
-rwxr-xr-x | src/ats/plugin_ats_ril.c | 141 |
1 files changed, 102 insertions, 39 deletions
diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c index 8250521b7..227173043 100755 --- a/src/ats/plugin_ats_ril.c +++ b/src/ats/plugin_ats_ril.c | |||
@@ -28,26 +28,27 @@ | |||
28 | 28 | ||
29 | #define LOG(kind,...) GNUNET_log_from (kind, "ats-ril",__VA_ARGS__) | 29 | #define LOG(kind,...) GNUNET_log_from (kind, "ats-ril",__VA_ARGS__) |
30 | 30 | ||
31 | #define RIL_MIN_BW (1 * ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__)) | 31 | #define RIL_MIN_BW (5 * ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__)) |
32 | #define RIL_MAX_BW GNUNET_ATS_MaxBandwidth | 32 | #define RIL_MAX_BW GNUNET_ATS_MaxBandwidth |
33 | 33 | ||
34 | #define RIL_ACTION_INVALID -1 | 34 | #define RIL_ACTION_INVALID -1 |
35 | #define RIL_INTERVAL_EXPONENT 10 | 35 | #define RIL_INTERVAL_EXPONENT 10 |
36 | #define RIL_UTILITY_DELAY_MAX 1000 | 36 | #define RIL_UTILITY_DELAY_MAX 1000 |
37 | 37 | ||
38 | #define RIL_DEFAULT_STEP_TIME_MIN GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 200) | 38 | #define RIL_DEFAULT_STEP_TIME_MIN GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 300) |
39 | #define RIL_DEFAULT_STEP_TIME_MAX GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 1000) | 39 | #define RIL_DEFAULT_STEP_TIME_MAX GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 2000) |
40 | #define RIL_DEFAULT_ALGORITHM RIL_ALGO_Q | 40 | #define RIL_DEFAULT_ALGORITHM RIL_ALGO_Q |
41 | #define RIL_DEFAULT_SELECT RIL_SELECT_EGREEDY | 41 | #define RIL_DEFAULT_SELECT RIL_SELECT_EGREEDY |
42 | #define RIL_DEFAULT_WELFARE RIL_WELFARE_EGALITARIAN | 42 | #define RIL_DEFAULT_WELFARE RIL_WELFARE_NASH |
43 | #define RIL_DEFAULT_DISCOUNT_BETA 1.0 | 43 | #define RIL_DEFAULT_DISCOUNT_BETA 2.0 |
44 | #define RIL_DEFAULT_DISCOUNT_GAMMA 0.5 | 44 | #define RIL_DEFAULT_DISCOUNT_GAMMA 0.5 |
45 | #define RIL_DEFAULT_GRADIENT_STEP_SIZE 0.1 | 45 | #define RIL_DEFAULT_GRADIENT_STEP_SIZE 0.001 |
46 | #define RIL_DEFAULT_TRACE_DECAY 0.5 | 46 | #define RIL_DEFAULT_TRACE_DECAY 0.5 |
47 | #define RIL_DEFAULT_EXPLORE_RATIO 0.1 | 47 | #define RIL_DEFAULT_EXPLORE_RATIO 1 |
48 | #define RIL_DEFAULT_EXPLORE_DECAY 0.95 | ||
48 | #define RIL_DEFAULT_RBF_DIVISOR 50 | 49 | #define RIL_DEFAULT_RBF_DIVISOR 50 |
49 | #define RIL_DEFAULT_GLOBAL_REWARD_SHARE 0.5 | 50 | #define RIL_DEFAULT_TEMPERATURE 10 |
50 | #define RIL_DEFAULT_TEMPERATURE 1.0 | 51 | #define RIL_DEFAULT_TEMPERATURE_DECAY 0.999 |
51 | 52 | ||
52 | #define RIL_INC_DEC_STEP_SIZE 1 | 53 | #define RIL_INC_DEC_STEP_SIZE 1 |
53 | #define RIL_NOP_DECAY 0.5 | 54 | #define RIL_NOP_DECAY 0.5 |
@@ -140,11 +141,21 @@ struct RIL_Learning_Parameters | |||
140 | enum RIL_E_Modification eligibility_trace_mode; | 141 | enum RIL_E_Modification eligibility_trace_mode; |
141 | 142 | ||
142 | /** | 143 | /** |
144 | * Initial softmax action-selection temperature | ||
145 | */ | ||
146 | double temperature_init; | ||
147 | |||
148 | /** | ||
143 | * Softmax action-selection temperature | 149 | * Softmax action-selection temperature |
144 | */ | 150 | */ |
145 | double temperature; | 151 | double temperature; |
146 | 152 | ||
147 | /** | 153 | /** |
154 | * Decay factor of the temperature value | ||
155 | */ | ||
156 | double temperature_decay; | ||
157 | |||
158 | /** | ||
148 | * Which measure of social welfare should be used | 159 | * Which measure of social welfare should be used |
149 | */ | 160 | */ |
150 | enum RIL_Welfare social_welfare; | 161 | enum RIL_Welfare social_welfare; |
@@ -160,14 +171,19 @@ struct RIL_Learning_Parameters | |||
160 | enum RIL_Select select; | 171 | enum RIL_Select select; |
161 | 172 | ||
162 | /** | 173 | /** |
174 | * Initial exploration ratio value | ||
175 | */ | ||
176 | double explore_ratio_init; | ||
177 | |||
178 | /** | ||
163 | * Ratio, with what probability an agent should explore in the e-greed policy | 179 | * Ratio, with what probability an agent should explore in the e-greed policy |
164 | */ | 180 | */ |
165 | double explore_ratio; | 181 | double explore_ratio; |
166 | 182 | ||
167 | /** | 183 | /** |
168 | * How big the share of the global part of the reward signal is | 184 | * Decay factor of the explore ratio |
169 | */ | 185 | */ |
170 | double reward_global_share; | 186 | double explore_ratio_decay; |
171 | 187 | ||
172 | /** | 188 | /** |
173 | * Minimal interval time between steps in milliseconds | 189 | * Minimal interval time between steps in milliseconds |
@@ -1044,7 +1060,6 @@ envi_get_reward (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) | |||
1044 | double objective; | 1060 | double objective; |
1045 | double delta; | 1061 | double delta; |
1046 | double steady; | 1062 | double steady; |
1047 | double pen_share; | ||
1048 | double penalty; | 1063 | double penalty; |
1049 | double reward; | 1064 | double reward; |
1050 | 1065 | ||
@@ -1065,11 +1080,10 @@ envi_get_reward (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) | |||
1065 | 1080 | ||
1066 | steady = (RIL_ACTION_NOTHING == agent->a_old) ? agent->nop_bonus : 0; | 1081 | steady = (RIL_ACTION_NOTHING == agent->a_old) ? agent->nop_bonus : 0; |
1067 | 1082 | ||
1068 | pen_share = 0.5; | ||
1069 | penalty = envi_get_penalty(solver, agent); | 1083 | penalty = envi_get_penalty(solver, agent); |
1070 | 1084 | ||
1071 | reward = delta + steady; | 1085 | reward = delta + steady; |
1072 | return ((1 - pen_share) * reward) + (pen_share * penalty); | 1086 | return reward + penalty; |
1073 | } | 1087 | } |
1074 | 1088 | ||
1075 | /** | 1089 | /** |
@@ -1316,6 +1330,7 @@ agent_select_egreedy (struct RIL_Peer_Agent *agent, double *state) | |||
1316 | { | 1330 | { |
1317 | agent->eligibility_reset = GNUNET_YES; | 1331 | agent->eligibility_reset = GNUNET_YES; |
1318 | } | 1332 | } |
1333 | agent->envi->parameters.explore_ratio *= agent->envi->parameters.explore_ratio_decay; | ||
1319 | return action; | 1334 | return action; |
1320 | } | 1335 | } |
1321 | else //exploit | 1336 | else //exploit |
@@ -1373,10 +1388,11 @@ agent_select_softmax (struct RIL_Peer_Agent *agent, double *state) | |||
1373 | { | 1388 | { |
1374 | if (sum + p[i] > r) | 1389 | if (sum + p[i] > r) |
1375 | { | 1390 | { |
1376 | if (RIL_ALGO_Q == agent->envi->parameters.algorithm) | 1391 | if (i != a_max) |
1377 | { | 1392 | { |
1378 | if (i != a_max) | 1393 | if (RIL_ALGO_Q == agent->envi->parameters.algorithm) |
1379 | agent->eligibility_reset = GNUNET_YES; | 1394 | agent->eligibility_reset = GNUNET_YES; |
1395 | agent->envi->parameters.temperature *= agent->envi->parameters.temperature_decay; | ||
1380 | } | 1396 | } |
1381 | return i; | 1397 | return i; |
1382 | } | 1398 | } |
@@ -1643,7 +1659,7 @@ ril_calculate_discount (struct GAS_RIL_Handle *solver) | |||
1643 | struct GNUNET_TIME_Relative time_delta; | 1659 | struct GNUNET_TIME_Relative time_delta; |
1644 | double tau; | 1660 | double tau; |
1645 | 1661 | ||
1646 | // MDP case - TODO! remove when debugged and test SMDP case | 1662 | // MDP case only for debugging purposes |
1647 | if (solver->simulate) | 1663 | if (solver->simulate) |
1648 | { | 1664 | { |
1649 | solver->global_discount_variable = solver->parameters.gamma; | 1665 | solver->global_discount_variable = solver->parameters.gamma; |
@@ -2099,7 +2115,11 @@ GAS_ril_address_change_preference (void *solver, | |||
2099 | "API_address_change_preference() Preference '%s' for peer '%s' changed to %.2f \n", | 2115 | "API_address_change_preference() Preference '%s' for peer '%s' changed to %.2f \n", |
2100 | GNUNET_ATS_print_preference_type (kind), GNUNET_i2s (peer), pref_rel); | 2116 | GNUNET_ATS_print_preference_type (kind), GNUNET_i2s (peer), pref_rel); |
2101 | 2117 | ||
2102 | ril_step (solver); | 2118 | struct GAS_RIL_Handle *s = solver; |
2119 | |||
2120 | s->parameters.temperature = s->parameters.temperature_init; | ||
2121 | s->parameters.explore_ratio = s->parameters.explore_ratio_init; | ||
2122 | ril_step (s); | ||
2103 | } | 2123 | } |
2104 | 2124 | ||
2105 | /** | 2125 | /** |
@@ -2128,18 +2148,21 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
2128 | { | 2148 | { |
2129 | solver->parameters.rbf_divisor = RIL_DEFAULT_RBF_DIVISOR; | 2149 | solver->parameters.rbf_divisor = RIL_DEFAULT_RBF_DIVISOR; |
2130 | } | 2150 | } |
2151 | |||
2131 | if (GNUNET_OK | 2152 | if (GNUNET_OK |
2132 | != GNUNET_CONFIGURATION_get_value_time (env->cfg, "ats", "RIL_STEP_TIME_MIN", | 2153 | != GNUNET_CONFIGURATION_get_value_time (env->cfg, "ats", "RIL_STEP_TIME_MIN", |
2133 | &solver->parameters.step_time_min)) | 2154 | &solver->parameters.step_time_min)) |
2134 | { | 2155 | { |
2135 | solver->parameters.step_time_min = RIL_DEFAULT_STEP_TIME_MIN; | 2156 | solver->parameters.step_time_min = RIL_DEFAULT_STEP_TIME_MIN; |
2136 | } | 2157 | } |
2158 | |||
2137 | if (GNUNET_OK | 2159 | if (GNUNET_OK |
2138 | != GNUNET_CONFIGURATION_get_value_time (env->cfg, "ats", "RIL_STEP_TIME_MAX", | 2160 | != GNUNET_CONFIGURATION_get_value_time (env->cfg, "ats", "RIL_STEP_TIME_MAX", |
2139 | &solver->parameters.step_time_max)) | 2161 | &solver->parameters.step_time_max)) |
2140 | { | 2162 | { |
2141 | solver->parameters.step_time_max = RIL_DEFAULT_STEP_TIME_MAX; | 2163 | solver->parameters.step_time_max = RIL_DEFAULT_STEP_TIME_MAX; |
2142 | } | 2164 | } |
2165 | |||
2143 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_ALGORITHM", &string)) | 2166 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_ALGORITHM", &string)) |
2144 | { | 2167 | { |
2145 | solver->parameters.algorithm = !strcmp (string, "SARSA") ? RIL_ALGO_SARSA : RIL_ALGO_Q; | 2168 | solver->parameters.algorithm = !strcmp (string, "SARSA") ? RIL_ALGO_SARSA : RIL_ALGO_Q; |
@@ -2149,6 +2172,7 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
2149 | { | 2172 | { |
2150 | solver->parameters.algorithm = RIL_DEFAULT_ALGORITHM; | 2173 | solver->parameters.algorithm = RIL_DEFAULT_ALGORITHM; |
2151 | } | 2174 | } |
2175 | |||
2152 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_SELECT", &string)) | 2176 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_SELECT", &string)) |
2153 | { | 2177 | { |
2154 | solver->parameters.select = !strcmp (string, "EGREEDY") ? RIL_SELECT_EGREEDY : RIL_SELECT_SOFTMAX; | 2178 | solver->parameters.select = !strcmp (string, "EGREEDY") ? RIL_SELECT_EGREEDY : RIL_SELECT_SOFTMAX; |
@@ -2158,6 +2182,7 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
2158 | { | 2182 | { |
2159 | solver->parameters.select = RIL_DEFAULT_SELECT; | 2183 | solver->parameters.select = RIL_DEFAULT_SELECT; |
2160 | } | 2184 | } |
2185 | |||
2161 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_DISCOUNT_BETA", &string)) | 2186 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_DISCOUNT_BETA", &string)) |
2162 | { | 2187 | { |
2163 | solver->parameters.beta = strtod (string, NULL); | 2188 | solver->parameters.beta = strtod (string, NULL); |
@@ -2172,6 +2197,7 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
2172 | { | 2197 | { |
2173 | solver->parameters.beta = RIL_DEFAULT_DISCOUNT_BETA; | 2198 | solver->parameters.beta = RIL_DEFAULT_DISCOUNT_BETA; |
2174 | } | 2199 | } |
2200 | |||
2175 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_DISCOUNT_GAMMA", &string)) | 2201 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_DISCOUNT_GAMMA", &string)) |
2176 | { | 2202 | { |
2177 | solver->parameters.gamma = strtod (string, NULL); | 2203 | solver->parameters.gamma = strtod (string, NULL); |
@@ -2186,6 +2212,7 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
2186 | { | 2212 | { |
2187 | solver->parameters.gamma = RIL_DEFAULT_DISCOUNT_GAMMA; | 2213 | solver->parameters.gamma = RIL_DEFAULT_DISCOUNT_GAMMA; |
2188 | } | 2214 | } |
2215 | |||
2189 | if (GNUNET_OK | 2216 | if (GNUNET_OK |
2190 | == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_GRADIENT_STEP_SIZE", &string)) | 2217 | == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_GRADIENT_STEP_SIZE", &string)) |
2191 | { | 2218 | { |
@@ -2201,6 +2228,7 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
2201 | { | 2228 | { |
2202 | solver->parameters.alpha = RIL_DEFAULT_GRADIENT_STEP_SIZE; | 2229 | solver->parameters.alpha = RIL_DEFAULT_GRADIENT_STEP_SIZE; |
2203 | } | 2230 | } |
2231 | |||
2204 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_TRACE_DECAY", &string)) | 2232 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_TRACE_DECAY", &string)) |
2205 | { | 2233 | { |
2206 | solver->parameters.lambda = strtod (string, NULL); | 2234 | solver->parameters.lambda = strtod (string, NULL); |
@@ -2215,52 +2243,72 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
2215 | { | 2243 | { |
2216 | solver->parameters.lambda = RIL_DEFAULT_TRACE_DECAY; | 2244 | solver->parameters.lambda = RIL_DEFAULT_TRACE_DECAY; |
2217 | } | 2245 | } |
2246 | |||
2218 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_EXPLORE_RATIO", &string)) | 2247 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_EXPLORE_RATIO", &string)) |
2219 | { | 2248 | { |
2220 | solver->parameters.explore_ratio = strtod (string, NULL); | 2249 | solver->parameters.explore_ratio_init = strtod (string, NULL); |
2221 | GNUNET_free (string); | 2250 | GNUNET_free (string); |
2222 | if (solver->parameters.explore_ratio < 0 || solver->parameters.explore_ratio > 1) | 2251 | if (solver->parameters.explore_ratio_init < 0 || solver->parameters.explore_ratio_init > 1) |
2223 | { | 2252 | { |
2224 | 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); | 2253 | 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); |
2225 | solver->parameters.explore_ratio = RIL_DEFAULT_EXPLORE_RATIO; | 2254 | solver->parameters.explore_ratio_init = RIL_DEFAULT_EXPLORE_RATIO; |
2226 | } | 2255 | } |
2227 | } | 2256 | } |
2228 | else | 2257 | else |
2229 | { | 2258 | { |
2230 | solver->parameters.explore_ratio = RIL_DEFAULT_EXPLORE_RATIO; | 2259 | solver->parameters.explore_ratio_init = RIL_DEFAULT_EXPLORE_RATIO; |
2231 | } | 2260 | } |
2232 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_GLOBAL_REWARD_SHARE", &string)) | 2261 | |
2262 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_EXPLORE_DECAY", &string)) | ||
2233 | { | 2263 | { |
2234 | solver->parameters.reward_global_share = strtod (string, NULL); | 2264 | solver->parameters.explore_ratio_decay = strtod (string, NULL); |
2235 | GNUNET_free (string); | 2265 | GNUNET_free (string); |
2236 | if (solver->parameters.reward_global_share < 0 || solver->parameters.reward_global_share > 1) | 2266 | if (solver->parameters.explore_ratio_decay < 0 || solver->parameters.explore_ratio_decay > 1) |
2237 | { | 2267 | { |
2238 | 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); | 2268 | 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); |
2239 | solver->parameters.reward_global_share = RIL_DEFAULT_GLOBAL_REWARD_SHARE; | 2269 | solver->parameters.explore_ratio_decay = RIL_DEFAULT_EXPLORE_DECAY; |
2240 | } | 2270 | } |
2241 | } | 2271 | } |
2242 | else | 2272 | else |
2243 | { | 2273 | { |
2244 | solver->parameters.reward_global_share = RIL_DEFAULT_GLOBAL_REWARD_SHARE; | 2274 | solver->parameters.explore_ratio_decay = RIL_DEFAULT_EXPLORE_DECAY; |
2245 | } | 2275 | } |
2276 | |||
2246 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_TEMPERATURE", &string)) | 2277 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_TEMPERATURE", &string)) |
2247 | { | 2278 | { |
2248 | solver->parameters.temperature = strtod (string, NULL); | 2279 | solver->parameters.temperature_init = strtod (string, NULL); |
2249 | GNUNET_free (string); | 2280 | GNUNET_free (string); |
2250 | if (solver->parameters.temperature <= 0) | 2281 | if (solver->parameters.temperature_init <= 0) |
2251 | { | 2282 | { |
2252 | LOG (GNUNET_ERROR_TYPE_WARNING, "RIL_TEMPERATURE not positive. Set to default value of %f instead.\n", RIL_DEFAULT_TEMPERATURE); | 2283 | LOG (GNUNET_ERROR_TYPE_WARNING, "RIL_TEMPERATURE not positive. Set to default value of %f instead.\n", RIL_DEFAULT_TEMPERATURE); |
2253 | solver->parameters.temperature = RIL_DEFAULT_TEMPERATURE; | 2284 | solver->parameters.temperature_init = RIL_DEFAULT_TEMPERATURE; |
2254 | } | 2285 | } |
2255 | } | 2286 | } |
2256 | else | 2287 | else |
2257 | { | 2288 | { |
2258 | solver->parameters.temperature = RIL_DEFAULT_TEMPERATURE; | 2289 | solver->parameters.temperature_init = RIL_DEFAULT_TEMPERATURE; |
2259 | } | 2290 | } |
2291 | |||
2292 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_TEMPERATURE_DECAY", &string)) | ||
2293 | { | ||
2294 | solver->parameters.temperature_decay = strtod (string, NULL); | ||
2295 | GNUNET_free (string); | ||
2296 | if (solver->parameters.temperature_decay <= 0 || solver->parameters.temperature_decay > 1) | ||
2297 | { | ||
2298 | 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); | ||
2299 | solver->parameters.temperature_decay = RIL_DEFAULT_TEMPERATURE_DECAY; | ||
2300 | } | ||
2301 | } | ||
2302 | else | ||
2303 | { | ||
2304 | solver->parameters.temperature_decay = RIL_DEFAULT_TEMPERATURE_DECAY; | ||
2305 | } | ||
2306 | |||
2260 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg, "ats", "RIL_SIMULATE", &solver->simulate)) | 2307 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg, "ats", "RIL_SIMULATE", &solver->simulate)) |
2261 | { | 2308 | { |
2262 | solver->simulate = GNUNET_NO; | 2309 | solver->simulate = GNUNET_NO; |
2263 | } | 2310 | } |
2311 | |||
2264 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(env->cfg, "ats", "RIL_REPLACE_TRACES")) | 2312 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(env->cfg, "ats", "RIL_REPLACE_TRACES")) |
2265 | { | 2313 | { |
2266 | solver->parameters.eligibility_trace_mode = RIL_E_REPLACE; | 2314 | solver->parameters.eligibility_trace_mode = RIL_E_REPLACE; |
@@ -2269,6 +2317,7 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
2269 | { | 2317 | { |
2270 | solver->parameters.eligibility_trace_mode = RIL_E_ACCUMULATE; | 2318 | solver->parameters.eligibility_trace_mode = RIL_E_ACCUMULATE; |
2271 | } | 2319 | } |
2320 | |||
2272 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_SOCIAL_WELFARE", &string)) | 2321 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", "RIL_SOCIAL_WELFARE", &string)) |
2273 | { | 2322 | { |
2274 | solver->parameters.social_welfare = !strcmp (string, "NASH") ? RIL_WELFARE_NASH : RIL_WELFARE_EGALITARIAN; | 2323 | solver->parameters.social_welfare = !strcmp (string, "NASH") ? RIL_WELFARE_NASH : RIL_WELFARE_EGALITARIAN; |
@@ -2313,11 +2362,10 @@ libgnunet_plugin_ats_ril_init (void *cls) | |||
2313 | solver->parameters.alpha, | 2362 | solver->parameters.alpha, |
2314 | solver->parameters.beta, | 2363 | solver->parameters.beta, |
2315 | solver->parameters.lambda); | 2364 | solver->parameters.lambda); |
2316 | LOG(GNUNET_ERROR_TYPE_DEBUG, "init() exploration_ratio = %f, temperature = %f, ActionSelection = %s, global_share = %f\n", | 2365 | LOG(GNUNET_ERROR_TYPE_DEBUG, "init() exploration_ratio = %f, temperature = %f, ActionSelection = %s\n", |
2317 | solver->parameters.explore_ratio, | 2366 | solver->parameters.explore_ratio, |
2318 | solver->parameters.temperature, | 2367 | solver->parameters.temperature, |
2319 | solver->parameters.select ? "EGREEDY" : "SOFTMAX", | 2368 | solver->parameters.select ? "EGREEDY" : "SOFTMAX"); |
2320 | solver->parameters.reward_global_share); | ||
2321 | LOG(GNUNET_ERROR_TYPE_DEBUG, "init() RBF_DIVISOR = %llu\n", | 2369 | LOG(GNUNET_ERROR_TYPE_DEBUG, "init() RBF_DIVISOR = %llu\n", |
2322 | solver->parameters.rbf_divisor); | 2370 | solver->parameters.rbf_divisor); |
2323 | 2371 | ||
@@ -2395,6 +2443,9 @@ GAS_ril_address_add (void *solver, struct ATS_Address *address, uint32_t network | |||
2395 | return; | 2443 | return; |
2396 | } | 2444 | } |
2397 | 2445 | ||
2446 | s->parameters.temperature = s->parameters.temperature_init; | ||
2447 | s->parameters.explore_ratio = s->parameters.explore_ratio_init; | ||
2448 | |||
2398 | agent = ril_get_agent (s, &address->peer, GNUNET_YES); | 2449 | agent = ril_get_agent (s, &address->peer, GNUNET_YES); |
2399 | 2450 | ||
2400 | //add address | 2451 | //add address |
@@ -2478,6 +2529,9 @@ GAS_ril_address_delete (void *solver, struct ATS_Address *address, int session_o | |||
2478 | return; | 2529 | return; |
2479 | } | 2530 | } |
2480 | 2531 | ||
2532 | s->parameters.temperature = s->parameters.temperature_init; | ||
2533 | s->parameters.explore_ratio = s->parameters.explore_ratio_init; | ||
2534 | |||
2481 | address_index = agent_address_get_index (agent, address); | 2535 | address_index = agent_address_get_index (agent, address); |
2482 | address_wrapped = agent_address_get_wrapped (agent, address); | 2536 | address_wrapped = agent_address_get_wrapped (agent, address); |
2483 | 2537 | ||
@@ -2564,7 +2618,11 @@ GAS_ril_address_property_changed (void *solver, | |||
2564 | "to %.2f \n", GNUNET_ATS_print_property_type (type), GNUNET_i2s (&address->peer), | 2618 | "to %.2f \n", GNUNET_ATS_print_property_type (type), GNUNET_i2s (&address->peer), |
2565 | address->addr, rel_value); | 2619 | address->addr, rel_value); |
2566 | 2620 | ||
2567 | ril_step (solver); | 2621 | struct GAS_RIL_Handle *s = solver; |
2622 | |||
2623 | s->parameters.temperature = s->parameters.temperature_init; | ||
2624 | s->parameters.explore_ratio = s->parameters.explore_ratio_init; | ||
2625 | ril_step (s); | ||
2568 | } | 2626 | } |
2569 | 2627 | ||
2570 | /** | 2628 | /** |
@@ -2628,6 +2686,9 @@ GAS_ril_address_change_network (void *solver, | |||
2628 | (GNUNET_YES == address->active) ? "active" : "inactive", GNUNET_i2s (&address->peer), | 2686 | (GNUNET_YES == address->active) ? "active" : "inactive", GNUNET_i2s (&address->peer), |
2629 | GNUNET_ATS_print_network_type (current_network), GNUNET_ATS_print_network_type (new_network)); | 2687 | GNUNET_ATS_print_network_type (current_network), GNUNET_ATS_print_network_type (new_network)); |
2630 | 2688 | ||
2689 | s->parameters.temperature = s->parameters.temperature_init; | ||
2690 | s->parameters.explore_ratio = s->parameters.explore_ratio_init; | ||
2691 | |||
2631 | if (address->active && !ril_network_is_active (solver, new_network)) | 2692 | if (address->active && !ril_network_is_active (solver, new_network)) |
2632 | { | 2693 | { |
2633 | GAS_ril_address_delete (solver, address, GNUNET_NO); | 2694 | GAS_ril_address_delete (solver, address, GNUNET_NO); |
@@ -2724,9 +2785,6 @@ GAS_ril_bulk_stop (void *solver) | |||
2724 | const struct ATS_Address * | 2785 | const struct ATS_Address * |
2725 | GAS_ril_get_preferred_address (void *solver, const struct GNUNET_PeerIdentity *peer) | 2786 | GAS_ril_get_preferred_address (void *solver, const struct GNUNET_PeerIdentity *peer) |
2726 | { | 2787 | { |
2727 | /* | ||
2728 | * activate agent, return currently chosen address | ||
2729 | */ | ||
2730 | struct GAS_RIL_Handle *s = solver; | 2788 | struct GAS_RIL_Handle *s = solver; |
2731 | struct RIL_Peer_Agent *agent; | 2789 | struct RIL_Peer_Agent *agent; |
2732 | 2790 | ||
@@ -2750,6 +2808,8 @@ GAS_ril_get_preferred_address (void *solver, const struct GNUNET_PeerIdentity *p | |||
2750 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 2808 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
2751 | "API_get_preferred_address() Activated agent for peer '%s', but no address available\n", | 2809 | "API_get_preferred_address() Activated agent for peer '%s', but no address available\n", |
2752 | GNUNET_i2s (peer)); | 2810 | GNUNET_i2s (peer)); |
2811 | s->parameters.temperature = s->parameters.temperature_init; | ||
2812 | s->parameters.explore_ratio = s->parameters.explore_ratio_init; | ||
2753 | } | 2813 | } |
2754 | return agent->address_inuse; | 2814 | return agent->address_inuse; |
2755 | } | 2815 | } |
@@ -2784,6 +2844,9 @@ GAS_ril_stop_get_preferred_address (void *solver, const struct GNUNET_PeerIdenti | |||
2784 | return; | 2844 | return; |
2785 | } | 2845 | } |
2786 | 2846 | ||
2847 | s->parameters.temperature = s->parameters.temperature_init; | ||
2848 | s->parameters.explore_ratio = s->parameters.explore_ratio_init; | ||
2849 | |||
2787 | agent->is_active = GNUNET_NO; | 2850 | agent->is_active = GNUNET_NO; |
2788 | 2851 | ||
2789 | envi_set_active_suggestion (s, agent, agent->address_inuse, agent->bw_in, agent->bw_out, | 2852 | envi_set_active_suggestion (s, agent, agent->address_inuse, agent->bw_in, agent->bw_out, |