diff options
author | Fabian Oehlmann <oehlmann@in.tum.de> | 2014-01-28 20:23:17 +0000 |
---|---|---|
committer | Fabian Oehlmann <oehlmann@in.tum.de> | 2014-01-28 20:23:17 +0000 |
commit | fb6b98aee7b05eddc2de621c1c6ec8a4ac177768 (patch) | |
tree | efcba7de4c25bb3cd90e0b3285a38a5c51aa2935 /src | |
parent | 6f2f81102aec50dab3b84ee4ef9fdb930e15e08e (diff) | |
download | gnunet-fb6b98aee7b05eddc2de621c1c6ec8a4ac177768.tar.gz gnunet-fb6b98aee7b05eddc2de621c1c6ec8a4ac177768.zip |
higher initialization of bandwidth
Diffstat (limited to 'src')
-rwxr-xr-x | src/ats/plugin_ats_ril.c | 69 |
1 files changed, 26 insertions, 43 deletions
diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c index 22fd1e365..d5213899e 100755 --- a/src/ats/plugin_ats_ril.c +++ b/src/ats/plugin_ats_ril.c | |||
@@ -29,14 +29,14 @@ | |||
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 ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__) | 31 | #define RIL_MIN_BW ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__) |
32 | #define RIL_MAX_BW 1024 * 1000//GNUNET_ATS_MaxBandwidth TODO! revert | 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 100 | 36 | #define RIL_UTILITY_DELAY_MAX 1000 |
37 | 37 | ||
38 | #define RIL_DEFAULT_STEP_TIME_MIN GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500) | 38 | #define RIL_DEFAULT_STEP_TIME_MIN GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100) |
39 | #define RIL_DEFAULT_STEP_TIME_MAX GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 3000) | 39 | #define RIL_DEFAULT_STEP_TIME_MAX GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 1000) |
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_EGALITARIAN |
@@ -44,13 +44,13 @@ | |||
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.1 |
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 0.2 |
48 | #define RIL_DEFAULT_RBF_DIVISOR 10 | 48 | #define RIL_DEFAULT_RBF_DIVISOR 50 |
49 | #define RIL_DEFAULT_GLOBAL_REWARD_SHARE 0.5 | 49 | #define RIL_DEFAULT_GLOBAL_REWARD_SHARE 0.5 |
50 | #define RIL_DEFAULT_TEMPERATURE 1.0 | 50 | #define RIL_DEFAULT_TEMPERATURE 1.0 |
51 | 51 | ||
52 | #define RIL_INC_DEC_STEP_SIZE 1 | 52 | #define RIL_INC_DEC_STEP_SIZE 100 |
53 | #define RIL_NOP_BONUS 0.5 | 53 | #define RIL_NOP_DECAY 0.5 |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * ATS reinforcement learning solver | 56 | * ATS reinforcement learning solver |
@@ -67,7 +67,7 @@ | |||
67 | enum RIL_Action_Type | 67 | enum RIL_Action_Type |
68 | { | 68 | { |
69 | RIL_ACTION_NOTHING = 0, | 69 | RIL_ACTION_NOTHING = 0, |
70 | RIL_ACTION_BW_IN_DBL = -2, //TODO! put actions back | 70 | RIL_ACTION_BW_IN_DBL = -2, //TODO? Potentially add more actions |
71 | RIL_ACTION_BW_IN_HLV = -3, | 71 | RIL_ACTION_BW_IN_HLV = -3, |
72 | RIL_ACTION_BW_IN_INC = 1, | 72 | RIL_ACTION_BW_IN_INC = 1, |
73 | RIL_ACTION_BW_IN_DEC = 2, | 73 | RIL_ACTION_BW_IN_DEC = 2, |
@@ -957,9 +957,9 @@ agent_get_utility (struct RIL_Peer_Agent *agent) | |||
957 | delay_atsi = (double) ril_get_atsi (agent->address_inuse, GNUNET_ATS_QUALITY_NET_DELAY); | 957 | delay_atsi = (double) ril_get_atsi (agent->address_inuse, GNUNET_ATS_QUALITY_NET_DELAY); |
958 | delay_norm = RIL_UTILITY_DELAY_MAX*exp(-delay_atsi*0.00001); | 958 | delay_norm = RIL_UTILITY_DELAY_MAX*exp(-delay_atsi*0.00001); |
959 | 959 | ||
960 | pref_match = (preferences[GNUNET_ATS_PREFERENCE_LATENCY] * delay_norm); | 960 | pref_match = preferences[GNUNET_ATS_PREFERENCE_LATENCY] * delay_norm; |
961 | pref_match += (preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] * (double) (agent->bw_in/RIL_MIN_BW)); | 961 | pref_match += preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] * |
962 | pref_match += (preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] * (double) (agent->bw_out/RIL_MIN_BW)); | 962 | sqrt((double) (agent->bw_in/RIL_MIN_BW) * (double) (agent->bw_out/RIL_MIN_BW)); |
963 | 963 | ||
964 | // return (double) (agent->bw_in/RIL_MIN_BW); | 964 | // return (double) (agent->bw_in/RIL_MIN_BW); |
965 | // return sqrt((double) (agent->bw_in/RIL_MIN_BW) * (double) (agent->bw_out/RIL_MIN_BW)); | 965 | // return sqrt((double) (agent->bw_in/RIL_MIN_BW) * (double) (agent->bw_out/RIL_MIN_BW)); |
@@ -1008,24 +1008,6 @@ ril_network_get_social_welfare (struct GAS_RIL_Handle *solver, struct RIL_Scope | |||
1008 | return 1; | 1008 | return 1; |
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | //static double | ||
1012 | //envi_penalty_share (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) | ||
1013 | //{ | ||
1014 | // struct RIL_Scope *net; | ||
1015 | // double util_ratio_in; | ||
1016 | // double util_ratio_out; | ||
1017 | // double util_ratio_max; | ||
1018 | // double sigmoid_x; | ||
1019 | // | ||
1020 | // net = agent->address_inuse->solver_information; | ||
1021 | // | ||
1022 | // util_ratio_in = (double) net->bw_in_utilized / (double) net->bw_in_available; | ||
1023 | // util_ratio_out = (double) net->bw_out_utilized / (double) net->bw_out_available; | ||
1024 | // util_ratio_max = GNUNET_MAX (util_ratio_in, util_ratio_out); | ||
1025 | // sigmoid_x = util_ratio_max - 1; | ||
1026 | // return 1 - (1 / (1 + exp(5 * sigmoid_x))); | ||
1027 | //} | ||
1028 | |||
1029 | static double | 1011 | static double |
1030 | envi_get_penalty (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) | 1012 | envi_get_penalty (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) |
1031 | { | 1013 | { |
@@ -1085,12 +1067,15 @@ envi_get_reward (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) | |||
1085 | 1067 | ||
1086 | if (delta != 0) | 1068 | if (delta != 0) |
1087 | { | 1069 | { |
1088 | agent->nop_bonus = delta * 0.5; | 1070 | agent->nop_bonus = delta * RIL_NOP_DECAY; |
1071 | } | ||
1072 | else | ||
1073 | { | ||
1074 | agent->nop_bonus *= RIL_NOP_DECAY; | ||
1089 | } | 1075 | } |
1090 | 1076 | ||
1091 | steady = (RIL_ACTION_NOTHING == agent->a_old) ? agent->nop_bonus : 0; | 1077 | steady = (RIL_ACTION_NOTHING == agent->a_old) ? agent->nop_bonus : 0; |
1092 | 1078 | ||
1093 | //pen_share = envi_penalty_share(solver, agent); TODO revert | ||
1094 | pen_share = 0.5; | 1079 | pen_share = 0.5; |
1095 | penalty = envi_get_penalty(solver, agent); | 1080 | penalty = envi_get_penalty(solver, agent); |
1096 | 1081 | ||
@@ -1557,8 +1542,8 @@ ril_get_used_resource_ratio (struct GAS_RIL_Handle *solver) | |||
1557 | net = solver->network_entries[i]; | 1542 | net = solver->network_entries[i]; |
1558 | if (net.bw_in_assigned > 0) //only consider scopes where an address is actually active | 1543 | if (net.bw_in_assigned > 0) //only consider scopes where an address is actually active |
1559 | { | 1544 | { |
1560 | sum_assigned += net.bw_in_assigned; | 1545 | sum_assigned += net.bw_in_utilized; |
1561 | sum_assigned += net.bw_out_assigned; | 1546 | sum_assigned += net.bw_out_utilized; |
1562 | sum_available += net.bw_in_available; | 1547 | sum_available += net.bw_in_available; |
1563 | sum_available += net.bw_out_available; | 1548 | sum_available += net.bw_out_available; |
1564 | } | 1549 | } |
@@ -1572,7 +1557,7 @@ ril_get_used_resource_ratio (struct GAS_RIL_Handle *solver) | |||
1572 | ratio = 0; | 1557 | ratio = 0; |
1573 | } | 1558 | } |
1574 | 1559 | ||
1575 | return ratio > 1 ? 1 : ratio; //overassignment is possible, cap at 1 | 1560 | return ratio > 1 ? 1 : ratio; //overutilization is possible, cap at 1 |
1576 | } | 1561 | } |
1577 | 1562 | ||
1578 | /** | 1563 | /** |
@@ -1651,7 +1636,7 @@ ril_try_unblock_agent (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *age | |||
1651 | if (ril_network_is_not_full(solver, net->type)) | 1636 | if (ril_network_is_not_full(solver, net->type)) |
1652 | { | 1637 | { |
1653 | if (NULL == agent->address_inuse) | 1638 | if (NULL == agent->address_inuse) |
1654 | envi_set_active_suggestion (solver, agent, addr_wrap->address_naked, RIL_MIN_BW, RIL_MIN_BW, silent); | 1639 | envi_set_active_suggestion (solver, agent, addr_wrap->address_naked, addr_wrap->bw_in, addr_wrap->bw_out, silent); |
1655 | return; | 1640 | return; |
1656 | } | 1641 | } |
1657 | } | 1642 | } |
@@ -1671,7 +1656,7 @@ ril_calculate_discount (struct GAS_RIL_Handle *solver) | |||
1671 | struct GNUNET_TIME_Relative time_delta; | 1656 | struct GNUNET_TIME_Relative time_delta; |
1672 | double tau; | 1657 | double tau; |
1673 | 1658 | ||
1674 | // MDP case - TODO remove when debugged | 1659 | // MDP case - TODO! remove when debugged and test SMDP case |
1675 | if (solver->simulate) | 1660 | if (solver->simulate) |
1676 | { | 1661 | { |
1677 | solver->global_discount_variable = solver->parameters.gamma; | 1662 | solver->global_discount_variable = solver->parameters.gamma; |
@@ -2429,8 +2414,8 @@ GAS_ril_address_add (void *solver, struct ATS_Address *address, uint32_t network | |||
2429 | //add address | 2414 | //add address |
2430 | address_wrapped = GNUNET_new (struct RIL_Address_Wrapped); | 2415 | address_wrapped = GNUNET_new (struct RIL_Address_Wrapped); |
2431 | address_wrapped->address_naked = address; | 2416 | address_wrapped->address_naked = address; |
2432 | address_wrapped->bw_in = RIL_MIN_BW; | 2417 | address_wrapped->bw_in = net->bw_in_available > net->bw_in_utilized ? (net->bw_in_available - net->bw_in_utilized) / 2 : RIL_MIN_BW; |
2433 | address_wrapped->bw_out = RIL_MIN_BW; | 2418 | address_wrapped->bw_out = net->bw_out_available > net->bw_out_utilized ? (net->bw_out_available - net->bw_out_utilized) / 2 : RIL_MIN_BW; |
2434 | GNUNET_CONTAINER_DLL_insert_tail(agent->addresses_head, agent->addresses_tail, address_wrapped); | 2419 | GNUNET_CONTAINER_DLL_insert_tail(agent->addresses_head, agent->addresses_tail, address_wrapped); |
2435 | 2420 | ||
2436 | //increase size of W | 2421 | //increase size of W |
@@ -2515,7 +2500,6 @@ GAS_ril_address_delete (void *solver, struct ATS_Address *address, int session_o | |||
2515 | if (NULL == address_wrapped) | 2500 | if (NULL == address_wrapped) |
2516 | { | 2501 | { |
2517 | net = address->solver_information; | 2502 | net = address->solver_information; |
2518 | GNUNET_assert(!ril_network_is_active (s, net->type)); | ||
2519 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 2503 | LOG(GNUNET_ERROR_TYPE_DEBUG, |
2520 | "Address not considered by agent, address was in inactive network\n"); | 2504 | "Address not considered by agent, address was in inactive network\n"); |
2521 | return; | 2505 | return; |
@@ -2563,8 +2547,8 @@ GAS_ril_address_delete (void *solver, struct ATS_Address *address, int session_o | |||
2563 | { | 2547 | { |
2564 | if (NULL != agent->addresses_head) //if peer has an address left, use it | 2548 | if (NULL != agent->addresses_head) //if peer has an address left, use it |
2565 | { | 2549 | { |
2566 | envi_set_active_suggestion (s, agent, agent->addresses_head->address_naked, RIL_MIN_BW, RIL_MIN_BW, | 2550 | envi_set_active_suggestion (s, agent, agent->addresses_head->address_naked, agent->addresses_head->bw_in, agent->addresses_head->bw_out, |
2567 | GNUNET_NO); | 2551 | GNUNET_YES); |
2568 | } | 2552 | } |
2569 | else | 2553 | else |
2570 | { | 2554 | { |
@@ -2783,7 +2767,6 @@ GAS_ril_get_preferred_address (void *solver, const struct GNUNET_PeerIdentity *p | |||
2783 | "API_get_preferred_address() Activated agent for peer '%s', but no address available\n", | 2767 | "API_get_preferred_address() Activated agent for peer '%s', but no address available\n", |
2784 | GNUNET_i2s (peer)); | 2768 | GNUNET_i2s (peer)); |
2785 | } | 2769 | } |
2786 | |||
2787 | return agent->address_inuse; | 2770 | return agent->address_inuse; |
2788 | } | 2771 | } |
2789 | 2772 | ||