aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFabian Oehlmann <oehlmann@in.tum.de>2014-02-13 15:38:20 +0000
committerFabian Oehlmann <oehlmann@in.tum.de>2014-02-13 15:38:20 +0000
commit263c4b44b864cce3b7c1864cd9afddbf3b63fc2d (patch)
tree19a8906e6ee43635619d934a8ecb85587c5b6f4f /src
parenta2158010a6b5f932006a66f44a6d3269c4c5c3d7 (diff)
downloadgnunet-263c4b44b864cce3b7c1864cd9afddbf3b63fc2d.tar.gz
gnunet-263c4b44b864cce3b7c1864cd9afddbf3b63fc2d.zip
- fixed warning about missing return values
Diffstat (limited to 'src')
-rwxr-xr-xsrc/ats/plugin_ats_ril.c63
1 files changed, 41 insertions, 22 deletions
diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c
index 44eff203d..0a64cfee9 100755
--- a/src/ats/plugin_ats_ril.c
+++ b/src/ats/plugin_ats_ril.c
@@ -35,14 +35,14 @@
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, 300) 38#define RIL_DEFAULT_STEP_TIME_MIN GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 200)
39#define RIL_DEFAULT_STEP_TIME_MAX GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 2000) 39#define RIL_DEFAULT_STEP_TIME_MAX GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 2000)
40#define RIL_DEFAULT_ALGORITHM RIL_ALGO_SARSA 40#define RIL_DEFAULT_ALGORITHM RIL_ALGO_SARSA
41#define RIL_DEFAULT_SELECT RIL_SELECT_SOFTMAX 41#define RIL_DEFAULT_SELECT RIL_SELECT_SOFTMAX
42#define RIL_DEFAULT_WELFARE RIL_WELFARE_NASH 42#define RIL_DEFAULT_WELFARE RIL_WELFARE_NASH
43#define RIL_DEFAULT_DISCOUNT_BETA 0.6 43#define RIL_DEFAULT_DISCOUNT_BETA 0.6
44#define RIL_DEFAULT_DISCOUNT_GAMMA 0.5 44#define RIL_DEFAULT_DISCOUNT_GAMMA 0.5
45#define RIL_DEFAULT_GRADIENT_STEP_SIZE 0.001 45#define RIL_DEFAULT_GRADIENT_STEP_SIZE 0.01
46#define RIL_DEFAULT_TRACE_DECAY 0.5 46#define RIL_DEFAULT_TRACE_DECAY 0.5
47#define RIL_DEFAULT_EXPLORE_RATIO 1 47#define RIL_DEFAULT_EXPLORE_RATIO 1
48#define RIL_DEFAULT_EXPLORE_DECAY 0.95 48#define RIL_DEFAULT_EXPLORE_DECAY 0.95
@@ -557,7 +557,7 @@ agent_action_is_possible (struct RIL_Peer_Agent *agent, int action)
557 break; 557 break;
558 case RIL_ACTION_BW_IN_DEC: 558 case RIL_ACTION_BW_IN_DEC:
559 case RIL_ACTION_BW_IN_HLV: 559 case RIL_ACTION_BW_IN_HLV:
560 if (agent->bw_in <= RIL_MIN_BW) 560 if (agent->bw_in <= 0)
561 return GNUNET_NO; 561 return GNUNET_NO;
562 else 562 else
563 return GNUNET_YES; 563 return GNUNET_YES;
@@ -571,7 +571,7 @@ agent_action_is_possible (struct RIL_Peer_Agent *agent, int action)
571 break; 571 break;
572 case RIL_ACTION_BW_OUT_DEC: 572 case RIL_ACTION_BW_OUT_DEC:
573 case RIL_ACTION_BW_OUT_HLV: 573 case RIL_ACTION_BW_OUT_HLV:
574 if (agent->bw_out <= RIL_MIN_BW) 574 if (agent->bw_out <= 0)
575 return GNUNET_NO; 575 return GNUNET_NO;
576 else 576 else
577 return GNUNET_YES; 577 return GNUNET_YES;
@@ -673,6 +673,7 @@ agent_get_action_random (struct RIL_Peer_Agent *agent)
673 } 673 }
674 674
675 GNUNET_assert(GNUNET_NO); 675 GNUNET_assert(GNUNET_NO);
676 return RIL_ACTION_INVALID;
676} 677}
677 678
678 679
@@ -782,6 +783,16 @@ ril_inform (struct GAS_RIL_Handle *solver,
782 solver->plugin_envi->info_cb (solver->plugin_envi->info_cb_cls, op, stat, GAS_INFO_NONE); 783 solver->plugin_envi->info_cb (solver->plugin_envi->info_cb_cls, op, stat, GAS_INFO_NONE);
783} 784}
784 785
786/**
787 * Calculates the maximum bandwidth an agent can assign in a network scope
788 *
789 * @param net
790 */
791static unsigned long long
792ril_get_max_bw (struct RIL_Scope *net)
793{
794 return GNUNET_MIN(2 * GNUNET_MAX(net->bw_in_available, net->bw_out_available), GNUNET_ATS_MaxBandwidth);
795}
785 796
786/** 797/**
787 * Changes the active assignment suggestion of the handler and invokes the bw_changed callback to 798 * Changes the active assignment suggestion of the handler and invokes the bw_changed callback to
@@ -895,7 +906,7 @@ envi_get_state (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent)
895 906
896 state = GNUNET_malloc (sizeof(double) * agent->m); 907 state = GNUNET_malloc (sizeof(double) * agent->m);
897 908
898 max_bw = RIL_MAX_BW; 909 max_bw = ril_get_max_bw((struct RIL_Scope *) agent->address_inuse->solver_information);
899 910
900 y[0] = (double) agent->bw_out; 911 y[0] = (double) agent->bw_out;
901 y[1] = (double) agent->bw_in; 912 y[1] = (double) agent->bw_in;
@@ -964,7 +975,8 @@ agent_get_utility (struct RIL_Peer_Agent *agent)
964 975
965 pref_match = preferences[GNUNET_ATS_PREFERENCE_LATENCY] * delay_norm; 976 pref_match = preferences[GNUNET_ATS_PREFERENCE_LATENCY] * delay_norm;
966 pref_match += preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] * 977 pref_match += preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] *
967 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)); 978 sqrt((double) (agent->bw_in/RIL_MIN_BW) * (double) (agent->bw_out/RIL_MIN_BW));
979// 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));
968 980
969// return (double) (agent->bw_in/RIL_MIN_BW); 981// return (double) (agent->bw_in/RIL_MIN_BW);
970// return sqrt((double) (agent->bw_in/RIL_MIN_BW) * (double) (agent->bw_out/RIL_MIN_BW)); 982// return sqrt((double) (agent->bw_in/RIL_MIN_BW) * (double) (agent->bw_out/RIL_MIN_BW));
@@ -1098,20 +1110,23 @@ envi_action_bw_double (struct GAS_RIL_Handle *solver,
1098 int direction_in) 1110 int direction_in)
1099{ 1111{
1100 unsigned long long new_bw; 1112 unsigned long long new_bw;
1113 unsigned long long max_bw;
1114
1115 max_bw = ril_get_max_bw((struct RIL_Scope *) agent->address_inuse->solver_information);
1101 1116
1102 if (direction_in) 1117 if (direction_in)
1103 { 1118 {
1104 new_bw = agent->bw_in * 2; 1119 new_bw = agent->bw_in * 2;
1105 if (new_bw < agent->bw_in || new_bw > RIL_MAX_BW) 1120 if (new_bw < agent->bw_in || new_bw > max_bw)
1106 new_bw = RIL_MAX_BW; 1121 new_bw = max_bw;
1107 envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw, 1122 envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw,
1108 agent->bw_out, GNUNET_NO); 1123 agent->bw_out, GNUNET_NO);
1109 } 1124 }
1110 else 1125 else
1111 { 1126 {
1112 new_bw = agent->bw_out * 2; 1127 new_bw = agent->bw_out * 2;
1113 if (new_bw < agent->bw_out || new_bw > RIL_MAX_BW) 1128 if (new_bw < agent->bw_out || new_bw > max_bw)
1114 new_bw = RIL_MAX_BW; 1129 new_bw = max_bw;
1115 envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in, 1130 envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in,
1116 new_bw, GNUNET_NO); 1131 new_bw, GNUNET_NO);
1117 } 1132 }
@@ -1136,16 +1151,16 @@ envi_action_bw_halven (struct GAS_RIL_Handle *solver,
1136 if (direction_in) 1151 if (direction_in)
1137 { 1152 {
1138 new_bw = agent->bw_in / 2; 1153 new_bw = agent->bw_in / 2;
1139 if (new_bw < RIL_MIN_BW || new_bw > agent->bw_in) 1154 if (new_bw <= 0 || new_bw > agent->bw_in)
1140 new_bw = RIL_MIN_BW; 1155 new_bw = 0;
1141 envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw, agent->bw_out, 1156 envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw, agent->bw_out,
1142 GNUNET_NO); 1157 GNUNET_NO);
1143 } 1158 }
1144 else 1159 else
1145 { 1160 {
1146 new_bw = agent->bw_out / 2; 1161 new_bw = agent->bw_out / 2;
1147 if (new_bw < RIL_MIN_BW || new_bw > agent->bw_out) 1162 if (new_bw <= 0 || new_bw > agent->bw_out)
1148 new_bw = RIL_MIN_BW; 1163 new_bw = 0;
1149 envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in, new_bw, 1164 envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in, new_bw,
1150 GNUNET_NO); 1165 GNUNET_NO);
1151 } 1166 }
@@ -1163,20 +1178,23 @@ static void
1163envi_action_bw_inc (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent, int direction_in) 1178envi_action_bw_inc (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent, int direction_in)
1164{ 1179{
1165 unsigned long long new_bw; 1180 unsigned long long new_bw;
1181 unsigned long long max_bw;
1182
1183 max_bw = ril_get_max_bw((struct RIL_Scope *) agent->address_inuse->solver_information);
1166 1184
1167 if (direction_in) 1185 if (direction_in)
1168 { 1186 {
1169 new_bw = agent->bw_in + (RIL_INC_DEC_STEP_SIZE * RIL_MIN_BW); 1187 new_bw = agent->bw_in + (RIL_INC_DEC_STEP_SIZE * RIL_MIN_BW);
1170 if (new_bw < agent->bw_in || new_bw > RIL_MAX_BW) 1188 if (new_bw < agent->bw_in || new_bw > max_bw)
1171 new_bw = RIL_MAX_BW; 1189 new_bw = max_bw;
1172 envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw, 1190 envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw,
1173 agent->bw_out, GNUNET_NO); 1191 agent->bw_out, GNUNET_NO);
1174 } 1192 }
1175 else 1193 else
1176 { 1194 {
1177 new_bw = agent->bw_out + (RIL_INC_DEC_STEP_SIZE * RIL_MIN_BW); 1195 new_bw = agent->bw_out + (RIL_INC_DEC_STEP_SIZE * RIL_MIN_BW);
1178 if (new_bw < agent->bw_out || new_bw > RIL_MAX_BW) 1196 if (new_bw < agent->bw_out || new_bw > max_bw)
1179 new_bw = RIL_MAX_BW; 1197 new_bw = max_bw;
1180 envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in, 1198 envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in,
1181 new_bw, GNUNET_NO); 1199 new_bw, GNUNET_NO);
1182 } 1200 }
@@ -1199,16 +1217,16 @@ envi_action_bw_dec (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent,
1199 if (direction_in) 1217 if (direction_in)
1200 { 1218 {
1201 new_bw = agent->bw_in - (RIL_INC_DEC_STEP_SIZE * RIL_MIN_BW); 1219 new_bw = agent->bw_in - (RIL_INC_DEC_STEP_SIZE * RIL_MIN_BW);
1202 if (new_bw < RIL_MIN_BW || new_bw > agent->bw_in) 1220 if (new_bw <= 0 || new_bw > agent->bw_in)
1203 new_bw = RIL_MIN_BW; 1221 new_bw = 0;
1204 envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw, agent->bw_out, 1222 envi_set_active_suggestion (solver, agent, agent->address_inuse, new_bw, agent->bw_out,
1205 GNUNET_NO); 1223 GNUNET_NO);
1206 } 1224 }
1207 else 1225 else
1208 { 1226 {
1209 new_bw = agent->bw_out - (RIL_INC_DEC_STEP_SIZE * RIL_MIN_BW); 1227 new_bw = agent->bw_out - (RIL_INC_DEC_STEP_SIZE * RIL_MIN_BW);
1210 if (new_bw < RIL_MIN_BW || new_bw > agent->bw_out) 1228 if (new_bw <= 0 || new_bw > agent->bw_out)
1211 new_bw = RIL_MIN_BW; 1229 new_bw = 0;
1212 envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in, new_bw, 1230 envi_set_active_suggestion (solver, agent, agent->address_inuse, agent->bw_in, new_bw,
1213 GNUNET_NO); 1231 GNUNET_NO);
1214 } 1232 }
@@ -1398,6 +1416,7 @@ agent_select_softmax (struct RIL_Peer_Agent *agent, double *state)
1398 sum += p[i]; 1416 sum += p[i];
1399 } 1417 }
1400 GNUNET_assert(GNUNET_NO); 1418 GNUNET_assert(GNUNET_NO);
1419 return RIL_ACTION_INVALID;
1401} 1420}
1402 1421
1403/** 1422/**