diff options
author | Fabian Oehlmann <oehlmann@in.tum.de> | 2013-12-16 12:12:06 +0000 |
---|---|---|
committer | Fabian Oehlmann <oehlmann@in.tum.de> | 2013-12-16 12:12:06 +0000 |
commit | 3776d13de4f4955b6380a701d1c2262c5e96ad01 (patch) | |
tree | 374fef971847fd3b48074cbaffeddb7c638074c8 /src/ats | |
parent | d9cbc7b13963d051dd9c238d0fee58a92f77bb72 (diff) | |
download | gnunet-3776d13de4f4955b6380a701d1c2262c5e96ad01.tar.gz gnunet-3776d13de4f4955b6380a701d1c2262c5e96ad01.zip |
added egalitarian utility goal
Diffstat (limited to 'src/ats')
-rwxr-xr-x | src/ats/plugin_ats_ril.c | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c index da8af16c9..0e66a4d60 100755 --- a/src/ats/plugin_ats_ril.c +++ b/src/ats/plugin_ats_ril.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #define RIL_FEATURES_NETWORK_COUNT 2 | 35 | #define RIL_FEATURES_NETWORK_COUNT 2 |
36 | #define RIL_FEATURES_INIT_COUNT 1 + RIL_FEATURES_NETWORK_COUNT // + GNUNET_ATS_PreferenceCount | 36 | #define RIL_FEATURES_INIT_COUNT 1 + RIL_FEATURES_NETWORK_COUNT // + GNUNET_ATS_PreferenceCount |
37 | #define RIL_INTERVAL_EXPONENT 10 | 37 | #define RIL_INTERVAL_EXPONENT 10 |
38 | #define RIL_UTILITY_MAX (double) GNUNET_ATS_MaxBandwidth | ||
38 | 39 | ||
39 | #define RIL_DEFAULT_STEP_TIME_MIN GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500) | 40 | #define RIL_DEFAULT_STEP_TIME_MIN GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500) |
40 | #define RIL_DEFAULT_STEP_TIME_MAX GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 3000) | 41 | #define RIL_DEFAULT_STEP_TIME_MAX GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 3000) |
@@ -381,6 +382,11 @@ struct GAS_RIL_Handle | |||
381 | static int | 382 | static int |
382 | ril_count_agents(struct GAS_RIL_Handle * solver); | 383 | ril_count_agents(struct GAS_RIL_Handle * solver); |
383 | 384 | ||
385 | static double | ||
386 | agent_get_utility (struct RIL_Peer_Agent *agent) | ||
387 | { | ||
388 | return (double) agent->bw_in; | ||
389 | } | ||
384 | 390 | ||
385 | /** | 391 | /** |
386 | * Estimate the current action-value for state s and action a | 392 | * Estimate the current action-value for state s and action a |
@@ -947,6 +953,27 @@ envi_get_state (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) | |||
947 | // return (pref_match / 4) +1; | 953 | // return (pref_match / 4) +1; |
948 | //} | 954 | //} |
949 | 955 | ||
956 | static double | ||
957 | envi_get_collective_utility (struct GAS_RIL_Handle *solver) | ||
958 | { | ||
959 | //TODO! add nash product | ||
960 | struct RIL_Peer_Agent *cur; | ||
961 | double result = RIL_UTILITY_MAX; | ||
962 | |||
963 | for (cur = solver->agents_head; NULL != cur; cur = cur->next) | ||
964 | { | ||
965 | if (cur->is_active) | ||
966 | { | ||
967 | if (cur->address_inuse) | ||
968 | { | ||
969 | result = GNUNET_MIN(result, agent_get_utility(cur)); | ||
970 | } | ||
971 | } | ||
972 | } | ||
973 | |||
974 | return result; | ||
975 | } | ||
976 | |||
950 | /** | 977 | /** |
951 | * Gets the reward for the last performed step, which is calculated in equal | 978 | * Gets the reward for the last performed step, which is calculated in equal |
952 | * parts from the local (the peer specific) and the global (for all peers | 979 | * parts from the local (the peer specific) and the global (for all peers |
@@ -960,44 +987,20 @@ static double | |||
960 | envi_get_reward (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) | 987 | envi_get_reward (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) |
961 | { | 988 | { |
962 | struct RIL_Network *net; | 989 | struct RIL_Network *net; |
963 | // double reward = 0; | ||
964 | long long overutilized_in = 0; | ||
965 | // long long overutilized_out; | ||
966 | long long assigned_in = 0; | ||
967 | // long long assigned_out = 0; | ||
968 | // long long unused; | ||
969 | |||
970 | //punish overutilization | ||
971 | net = agent->address_inuse->solver_information; | ||
972 | 990 | ||
991 | unsigned long long objective; | ||
992 | |||
993 | net = agent->address_inuse->solver_information; | ||
973 | if (net->bw_in_assigned > net->bw_in_available) | 994 | if (net->bw_in_assigned > net->bw_in_available) |
974 | { | 995 | { |
975 | overutilized_in = (net->bw_in_assigned - net->bw_in_available); | 996 | objective = net->bw_in_available - net->bw_in_assigned; |
976 | assigned_in = net->bw_in_available; | ||
977 | } | 997 | } |
978 | else | 998 | else |
979 | { | 999 | { |
980 | assigned_in = net->bw_in_assigned; | 1000 | objective = envi_get_collective_utility(solver); |
981 | } | 1001 | } |
982 | // if (net->bw_out_assigned > net->bw_out_available) | ||
983 | // { | ||
984 | // overutilized_out = (net->bw_out_assigned - net->bw_out_available); | ||
985 | // assigned_out = net->bw_out_available; | ||
986 | // } | ||
987 | // else | ||
988 | // { | ||
989 | // assigned_out = net->bw_out_assigned; | ||
990 | // } | ||
991 | 1002 | ||
992 | // unused = net->bw_in_available - net->bw_in_assigned; | 1003 | return objective; |
993 | // unused = unused < 0 ? unused : -unused; | ||
994 | |||
995 | return (double) (assigned_in - overutilized_in) / 1024; | ||
996 | |||
997 | // reward += envi_reward_global (solver) * (solver->parameters.reward_global_share); | ||
998 | // reward += envi_reward_local (solver, agent) * (1 - solver->parameters.reward_global_share); | ||
999 | // | ||
1000 | // return (reward - 1.) * 100; | ||
1001 | } | 1004 | } |
1002 | 1005 | ||
1003 | /** | 1006 | /** |