diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-05-12 16:47:50 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-05-12 16:47:50 +0000 |
commit | ac2be7dde06b71347d87ed491eb38d64a9163ad8 (patch) | |
tree | eb96137d65b0305ad3ab008292466f068c3632d5 /src | |
parent | 6f1bbf8034e41837c33c5e3a7270c603a02e9d2e (diff) | |
download | gnunet-ac2be7dde06b71347d87ed491eb38d64a9163ad8.tar.gz gnunet-ac2be7dde06b71347d87ed491eb38d64a9163ad8.zip |
fixes for the solver and perf tool
Diffstat (limited to 'src')
-rw-r--r-- | src/ats/perf_ats_solver.c | 218 | ||||
-rw-r--r-- | src/ats/perf_ats_solver.conf | 55 | ||||
-rw-r--r-- | src/ats/plugin_ats_mlp.c | 48 |
3 files changed, 130 insertions, 191 deletions
diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c index 066a7d4ec..197414a6d 100644 --- a/src/ats/perf_ats_solver.c +++ b/src/ats/perf_ats_solver.c | |||
@@ -370,29 +370,36 @@ static void | |||
370 | perf_update_address (struct ATS_Address *cur) | 370 | perf_update_address (struct ATS_Address *cur) |
371 | { | 371 | { |
372 | int r_type; | 372 | int r_type; |
373 | int r_val; | 373 | int abs_val; |
374 | double rel_val; | ||
374 | 375 | ||
375 | r_type = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 2); | 376 | r_type = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 2); |
376 | switch (r_type) | 377 | switch (r_type) |
377 | { | 378 | { |
378 | case 0: | 379 | case 0: |
379 | r_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); | 380 | abs_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); |
380 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 381 | rel_val = (100 + (double) abs_val) / 100; |
381 | "Updating peer `%s' address %p type %s val %u\n", | 382 | |
382 | GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DELAY", r_val); | 383 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
384 | "Updating peer `%s' address %p type %s abs val %u rel val %.3f\n", | ||
385 | GNUNET_i2s (&cur->peer), cur, | ||
386 | "GNUNET_ATS_QUALITY_NET_DELAY", | ||
387 | abs_val, rel_val); | ||
383 | ph.env.sf.s_address_update_property (ph.solver, cur, | 388 | ph.env.sf.s_address_update_property (ph.solver, cur, |
384 | GNUNET_ATS_QUALITY_NET_DELAY, | 389 | GNUNET_ATS_QUALITY_NET_DELAY, |
385 | r_val, (double) (100 + r_val / 100)); | 390 | abs_val, rel_val); |
386 | break; | 391 | break; |
387 | case 1: | 392 | case 1: |
388 | r_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 10); | 393 | abs_val = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 10); |
394 | rel_val = (100 + (double) abs_val) / 100; | ||
389 | 395 | ||
390 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 396 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
391 | "Updating peer `%s' address %p type %s val %u\n", | 397 | "Updating peer `%s' address %p type %s abs val %u rel val %.3f\n", |
392 | GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DISTANCE", r_val); | 398 | GNUNET_i2s (&cur->peer), cur, "GNUNET_ATS_QUALITY_NET_DISTANCE", |
399 | abs_val, rel_val); | ||
393 | ph.env.sf.s_address_update_property (ph.solver, cur, | 400 | ph.env.sf.s_address_update_property (ph.solver, cur, |
394 | GNUNET_ATS_QUALITY_NET_DISTANCE, | 401 | GNUNET_ATS_QUALITY_NET_DISTANCE, |
395 | r_val, (double) (100 + r_val) / 100); | 402 | abs_val, rel_val); |
396 | break; | 403 | break; |
397 | default: | 404 | default: |
398 | break; | 405 | break; |
@@ -446,15 +453,21 @@ perf_address_initial_update (void *solver, | |||
446 | struct GNUNET_CONTAINER_MultiPeerMap * addresses, | 453 | struct GNUNET_CONTAINER_MultiPeerMap * addresses, |
447 | struct ATS_Address *address) | 454 | struct ATS_Address *address) |
448 | { | 455 | { |
456 | double delay; | ||
457 | double distance; | ||
458 | uint32_t random = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); | ||
459 | delay = (100 + (double) random) / 100; | ||
449 | ph.env.sf.s_address_update_property (solver, address, GNUNET_ATS_QUALITY_NET_DELAY, | 460 | ph.env.sf.s_address_update_property (solver, address, GNUNET_ATS_QUALITY_NET_DELAY, |
450 | 100, | 461 | 100, delay); |
451 | (double) (100 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100)) | 462 | |
452 | / 100); | 463 | random = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); |
464 | distance = (100 + (double) random) / 100; | ||
453 | 465 | ||
454 | ph.env.sf.s_address_update_property (solver, address, | 466 | ph.env.sf.s_address_update_property (solver, address, |
455 | GNUNET_ATS_QUALITY_NET_DISTANCE, 10, | 467 | GNUNET_ATS_QUALITY_NET_DISTANCE, 10, distance); |
456 | (double) (100 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100)) | 468 | |
457 | / 100); | 469 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
470 | "Initial update address %p : %.2f %.2f\n", address, delay, distance); | ||
458 | } | 471 | } |
459 | 472 | ||
460 | /** | 473 | /** |
@@ -904,7 +917,7 @@ evaluate (int iteration) | |||
904 | cur_res->d_total.rel_value_us = 0; | 917 | cur_res->d_total.rel_value_us = 0; |
905 | if (GNUNET_YES == cur->valid) | 918 | if (GNUNET_YES == cur->valid) |
906 | cur_res->d_total.rel_value_us += cur->d_total.rel_value_us; | 919 | cur_res->d_total.rel_value_us += cur->d_total.rel_value_us; |
907 | fprintf (stderr, | 920 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
908 | "Total time to solve %s for %u peers %u addresses: %llu us\n", | 921 | "Total time to solve %s for %u peers %u addresses: %llu us\n", |
909 | (GNUNET_YES == cur->update) ? "updated" : "full", | 922 | (GNUNET_YES == cur->update) ? "updated" : "full", |
910 | cur->peers, cur->addresses, | 923 | cur->peers, cur->addresses, |
@@ -920,7 +933,8 @@ evaluate (int iteration) | |||
920 | cur_res->d_setup.rel_value_us = 0; | 933 | cur_res->d_setup.rel_value_us = 0; |
921 | if (GNUNET_YES == cur->valid) | 934 | if (GNUNET_YES == cur->valid) |
922 | cur_res->d_setup.rel_value_us += cur->d_setup.rel_value_us; | 935 | cur_res->d_setup.rel_value_us += cur->d_setup.rel_value_us; |
923 | fprintf (stderr, "Total time to setup %s %u peers %u addresses: %llu us\n", | 936 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
937 | "Total time to setup %s %u peers %u addresses: %llu us\n", | ||
924 | (GNUNET_YES == cur->update) ? "updated" : "full", | 938 | (GNUNET_YES == cur->update) ? "updated" : "full", |
925 | cur->peers, cur->addresses, | 939 | cur->peers, cur->addresses, |
926 | (unsigned long long) cur->d_setup.rel_value_us); | 940 | (unsigned long long) cur->d_setup.rel_value_us); |
@@ -936,7 +950,7 @@ evaluate (int iteration) | |||
936 | cur_res->d_lp.rel_value_us = 0; | 950 | cur_res->d_lp.rel_value_us = 0; |
937 | if (GNUNET_YES == cur->valid) | 951 | if (GNUNET_YES == cur->valid) |
938 | cur_res->d_lp.rel_value_us += cur->d_lp.rel_value_us; | 952 | cur_res->d_lp.rel_value_us += cur->d_lp.rel_value_us; |
939 | fprintf (stderr, | 953 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
940 | "Total time to solve %s LP for %u peers %u addresses: %llu us\n", | 954 | "Total time to solve %s LP for %u peers %u addresses: %llu us\n", |
941 | (GNUNET_YES == cur->update) ? "updated" : "full", | 955 | (GNUNET_YES == cur->update) ? "updated" : "full", |
942 | cur->peers, | 956 | cur->peers, |
@@ -955,7 +969,8 @@ evaluate (int iteration) | |||
955 | if (GNUNET_YES == cur->valid) | 969 | if (GNUNET_YES == cur->valid) |
956 | cur_res->d_mlp.rel_value_us += cur->d_mlp.rel_value_us; | 970 | cur_res->d_mlp.rel_value_us += cur->d_mlp.rel_value_us; |
957 | 971 | ||
958 | fprintf (stderr, "Total time to solve %s MLP for %u peers %u addresses: %llu us\n", | 972 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
973 | "Total time to solve %s MLP for %u peers %u addresses: %llu us\n", | ||
959 | (GNUNET_YES == cur->update) ? "updated" : "full", | 974 | (GNUNET_YES == cur->update) ? "updated" : "full", |
960 | cur->peers, cur->addresses, | 975 | cur->peers, cur->addresses, |
961 | (unsigned long long )cur->d_mlp.rel_value_us); | 976 | (unsigned long long )cur->d_mlp.rel_value_us); |
@@ -1024,7 +1039,6 @@ evaluate_average (void) | |||
1024 | 1039 | ||
1025 | struct GNUNET_DISK_FileHandle *f_full; | 1040 | struct GNUNET_DISK_FileHandle *f_full; |
1026 | struct GNUNET_DISK_FileHandle *f_update; | 1041 | struct GNUNET_DISK_FileHandle *f_update; |
1027 | struct Result *cur; | ||
1028 | char * data_fn_full; | 1042 | char * data_fn_full; |
1029 | char * data_fn_update; | 1043 | char * data_fn_update; |
1030 | char * data; | 1044 | char * data; |
@@ -1058,7 +1072,7 @@ evaluate_average (void) | |||
1058 | if (NULL == f_full) | 1072 | if (NULL == f_full) |
1059 | { | 1073 | { |
1060 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1074 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1061 | "Cannot open gnuplot file `%s'\n", | 1075 | "Cannot open data file `%s'\n", |
1062 | data_fn_full); | 1076 | data_fn_full); |
1063 | GNUNET_free (data_fn_full); | 1077 | GNUNET_free (data_fn_full); |
1064 | return; | 1078 | return; |
@@ -1109,7 +1123,6 @@ evaluate_average (void) | |||
1109 | data_fn_update); | 1123 | data_fn_update); |
1110 | } | 1124 | } |
1111 | 1125 | ||
1112 | /* NEW log */ | ||
1113 | for (c_peer = ph.N_peers_start; c_peer <= ph.N_peers_end; c_peer ++) | 1126 | for (c_peer = ph.N_peers_start; c_peer <= ph.N_peers_end; c_peer ++) |
1114 | { | 1127 | { |
1115 | char * data_str; | 1128 | char * data_str; |
@@ -1119,8 +1132,10 @@ evaluate_average (void) | |||
1119 | { | 1132 | { |
1120 | struct Result *cur_res; | 1133 | struct Result *cur_res; |
1121 | 1134 | ||
1135 | //fprintf (stderr, "P: %u I: %u == %p \n", c_peer, c_iteration, cur_res); | ||
1122 | cur_res = ph.iterations_results[c_iteration].results_array[c_peer -1]; | 1136 | cur_res = ph.iterations_results[c_iteration].results_array[c_peer -1]; |
1123 | fprintf (stderr, "P: %u I: %u: P %i A %i\n", c_peer, c_iteration, cur_res->peers, cur_res->addresses); | 1137 | //fprintf (stderr, "P: %u I: %u: P %i A %i\n", c_peer, c_iteration, cur_res->peers, cur_res->addresses); |
1138 | fprintf (stderr, "D total: %llu\n", (long long unsigned int) cur_res->d_total.rel_value_us); | ||
1124 | fprintf (stderr, "D total: %llu\n", (long long unsigned int) cur_res->d_total.rel_value_us); | 1139 | fprintf (stderr, "D total: %llu\n", (long long unsigned int) cur_res->d_total.rel_value_us); |
1125 | 1140 | ||
1126 | data_tmp = GNUNET_strdup (data_str); | 1141 | data_tmp = GNUNET_strdup (data_str); |
@@ -1137,7 +1152,6 @@ evaluate_average (void) | |||
1137 | GNUNET_DISK_file_write (f_full, data_str, strlen(data_str)); | 1152 | GNUNET_DISK_file_write (f_full, data_str, strlen(data_str)); |
1138 | GNUNET_free (data_str); | 1153 | GNUNET_free (data_str); |
1139 | } | 1154 | } |
1140 | /* NEW log */ | ||
1141 | 1155 | ||
1142 | if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_full))) | 1156 | if ((NULL != f_full) && (GNUNET_SYSERR == GNUNET_DISK_file_close (f_full))) |
1143 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", | 1157 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", |
@@ -1148,139 +1162,6 @@ evaluate_average (void) | |||
1148 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", | 1162 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", |
1149 | data_fn_update); | 1163 | data_fn_update); |
1150 | GNUNET_free_non_null (data_fn_update); | 1164 | GNUNET_free_non_null (data_fn_update); |
1151 | |||
1152 | #if 0 | ||
1153 | for (c_o = 0; c_o < 2; c_o++) | ||
1154 | { | ||
1155 | if (0 == c_o) | ||
1156 | fprintf (stderr, | ||
1157 | "Duration for a full solution averaged over %i iterations\n", | ||
1158 | ph.total_iterations); | ||
1159 | if (1 == c_o) | ||
1160 | fprintf (stderr, | ||
1161 | "Duration for a full solution averaged over %i iterations\n", | ||
1162 | ph.total_iterations); | ||
1163 | |||
1164 | for (c_i = 0; c_i <= ph.N_peers_end - ph.N_peers_start; c_i++) | ||
1165 | { | ||
1166 | if (0 == c_o) | ||
1167 | { | ||
1168 | cur = &ph.averaged_full_result[c_i]; | ||
1169 | } | ||
1170 | else if ((GNUNET_YES == ph.measure_updates) && (1 == c_o)) | ||
1171 | { | ||
1172 | cur = &ph.averaged_update_result[c_i]; | ||
1173 | } | ||
1174 | else | ||
1175 | break; | ||
1176 | |||
1177 | if (0 == cur->peers) | ||
1178 | continue; | ||
1179 | |||
1180 | str_d_total = NULL; | ||
1181 | str_d_setup = NULL; | ||
1182 | str_d_lp = NULL; | ||
1183 | str_d_mlp = NULL; | ||
1184 | |||
1185 | if (0 >= cur->valid) | ||
1186 | { | ||
1187 | fprintf (stderr, | ||
1188 | "No valid results for %s for %u peers %u addresses!\n", | ||
1189 | (GNUNET_YES == cur->update) ? "updated" : "full", | ||
1190 | cur->peers, cur->addresses); | ||
1191 | continue; | ||
1192 | } | ||
1193 | |||
1194 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_total.rel_value_us) | ||
1195 | { | ||
1196 | fprintf (stderr, | ||
1197 | "Average total time from %u iterations to solve %s for %u peers %u addresses: %llu us\n", | ||
1198 | cur->valid, | ||
1199 | (GNUNET_YES == cur->update) ? "updated" : "full", | ||
1200 | cur->peers, cur->addresses, | ||
1201 | (unsigned long long) cur->d_total.rel_value_us / cur->valid); | ||
1202 | GNUNET_asprintf(&str_d_total, "%llu", | ||
1203 | (unsigned long long) cur->d_total.rel_value_us / cur->valid); | ||
1204 | } | ||
1205 | else | ||
1206 | GNUNET_asprintf (&str_d_total, "-1"); | ||
1207 | |||
1208 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_setup.rel_value_us) | ||
1209 | { | ||
1210 | fprintf (stderr, | ||
1211 | "Average total time from %u iterations to setup for %u peers %u addresses: %llu us\n", | ||
1212 | cur->valid, cur->peers, cur->addresses, | ||
1213 | (unsigned long long) cur->d_setup.rel_value_us / cur->valid); | ||
1214 | GNUNET_asprintf(&str_d_setup, "%llu", | ||
1215 | (unsigned long long) cur->d_setup.rel_value_us / cur->valid); | ||
1216 | |||
1217 | } | ||
1218 | else | ||
1219 | GNUNET_asprintf (&str_d_setup, "-1"); | ||
1220 | |||
1221 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_lp.rel_value_us) | ||
1222 | { | ||
1223 | fprintf (stderr, | ||
1224 | "Average total time from %u iterations to solve lp %s for %u peers %u addresses: %llu us\n", | ||
1225 | cur->valid, | ||
1226 | (GNUNET_YES == cur->update) ? "updated" : "full", | ||
1227 | cur->peers, cur->addresses, | ||
1228 | (unsigned long long) cur->d_lp.rel_value_us / cur->valid); | ||
1229 | GNUNET_asprintf(&str_d_lp, "%llu", | ||
1230 | (unsigned long long) cur->d_lp.rel_value_us / ph.total_iterations); | ||
1231 | } | ||
1232 | else | ||
1233 | GNUNET_asprintf (&str_d_lp, "-1"); | ||
1234 | |||
1235 | if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != cur->d_mlp.rel_value_us) | ||
1236 | { | ||
1237 | fprintf (stderr, | ||
1238 | "Average total time from %u iterations to solve mlp %s for %u peers %u addresses: %llu us\n", | ||
1239 | cur->valid, | ||
1240 | (GNUNET_YES == cur->update) ? "updated" : "full", | ||
1241 | cur->peers, cur->addresses, | ||
1242 | (unsigned long long) cur->d_mlp.rel_value_us / cur->valid); | ||
1243 | GNUNET_asprintf(&str_d_mlp, "%llu", | ||
1244 | (unsigned long long) cur->d_mlp.rel_value_us / cur->valid); | ||
1245 | } | ||
1246 | else | ||
1247 | GNUNET_asprintf (&str_d_mlp, "-1"); | ||
1248 | |||
1249 | data = NULL; | ||
1250 | if (GNUNET_YES == ph.create_datafile) | ||
1251 | { | ||
1252 | GNUNET_asprintf (&data, | ||
1253 | "%u;%u;%s;%s;%s;%s\n", | ||
1254 | cur->peers, cur->addresses, | ||
1255 | str_d_total, | ||
1256 | str_d_setup, | ||
1257 | str_d_lp, | ||
1258 | str_d_mlp); | ||
1259 | if (cur->update == GNUNET_NO) | ||
1260 | { | ||
1261 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_full, data, strlen(data))) | ||
1262 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1263 | "Cannot write data to log file `%s'\n", | ||
1264 | data_fn_full); | ||
1265 | } | ||
1266 | if ((cur->update == GNUNET_YES) && (NULL != f_update)) | ||
1267 | { | ||
1268 | if (GNUNET_SYSERR == GNUNET_DISK_file_write (f_update, data, strlen(data))) | ||
1269 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1270 | "Cannot write data to log file `%s'\n", | ||
1271 | data_fn_update); | ||
1272 | } | ||
1273 | GNUNET_free (data); | ||
1274 | } | ||
1275 | |||
1276 | GNUNET_free_non_null (str_d_total); | ||
1277 | GNUNET_free_non_null (str_d_setup); | ||
1278 | GNUNET_free_non_null (str_d_lp); | ||
1279 | GNUNET_free_non_null (str_d_mlp); | ||
1280 | } | ||
1281 | } | ||
1282 | #endif | ||
1283 | |||
1284 | } | 1165 | } |
1285 | 1166 | ||
1286 | /** | 1167 | /** |
@@ -1297,7 +1178,7 @@ perf_run_iteration (void) | |||
1297 | int count_p = ph.N_peers_end; | 1178 | int count_p = ph.N_peers_end; |
1298 | int count_a = ph.N_address; | 1179 | int count_a = ph.N_address; |
1299 | struct ATS_Address * cur_addr; | 1180 | struct ATS_Address * cur_addr; |
1300 | 1181 | uint32_t net; | |
1301 | 1182 | ||
1302 | ph.iterations_results[ph.current_iteration-1].results_array = GNUNET_malloc ((count_p) * sizeof (struct Result *)); | 1183 | ph.iterations_results[ph.current_iteration-1].results_array = GNUNET_malloc ((count_p) * sizeof (struct Result *)); |
1303 | ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer)); | 1184 | ph.peers = GNUNET_malloc ((count_p) * sizeof (struct PerfPeer)); |
@@ -1308,6 +1189,7 @@ perf_run_iteration (void) | |||
1308 | 1189 | ||
1309 | for (cp = 0; cp < count_p; cp++) | 1190 | for (cp = 0; cp < count_p; cp++) |
1310 | { | 1191 | { |
1192 | fprintf (stderr,"%u..", cp); | ||
1311 | if (GNUNET_NO == ph.bulk_running) | 1193 | if (GNUNET_NO == ph.bulk_running) |
1312 | { | 1194 | { |
1313 | ph.bulk_running = GNUNET_YES; | 1195 | ph.bulk_running = GNUNET_YES; |
@@ -1318,7 +1200,14 @@ perf_run_iteration (void) | |||
1318 | { | 1200 | { |
1319 | cur_addr = perf_create_address (cp, ca); | 1201 | cur_addr = perf_create_address (cp, ca); |
1320 | /* Add address */ | 1202 | /* Add address */ |
1321 | uint32_t net = 1 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_ATS_NetworkTypeCount - 1); | 1203 | |
1204 | /* Random network selection */ | ||
1205 | //net = 1 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_ATS_NetworkTypeCount - 1); | ||
1206 | /* Random equally distributed network selection */ | ||
1207 | net = 1 + (ca % (GNUNET_ATS_NetworkTypeCount - 1)); | ||
1208 | /* fprintf (stderr, "Network: %u `%s'\n", | ||
1209 | * mod_net , GNUNET_ATS_print_network_type(mod_net)); */ | ||
1210 | |||
1322 | cur_addr->atsi = GNUNET_new (struct GNUNET_ATS_Information); | 1211 | cur_addr->atsi = GNUNET_new (struct GNUNET_ATS_Information); |
1323 | cur_addr->atsi_count = 1; | 1212 | cur_addr->atsi_count = 1; |
1324 | cur_addr->atsi[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); | 1213 | cur_addr->atsi[0].type = htonl (GNUNET_ATS_NETWORK_TYPE); |
@@ -1327,8 +1216,9 @@ perf_run_iteration (void) | |||
1327 | 1216 | ||
1328 | ph.current_a = ca + 1; | 1217 | ph.current_a = ca + 1; |
1329 | perf_address_initial_update (ph.solver, ph.addresses, cur_addr); | 1218 | perf_address_initial_update (ph.solver, ph.addresses, cur_addr); |
1330 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1219 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
1331 | "Adding address for peer %u address %u\n", cp, ca); | 1220 | "Adding address for peer %u address %u in network %s\n", cp, ca, |
1221 | GNUNET_ATS_print_network_type(net)); | ||
1332 | } | 1222 | } |
1333 | /* Notify solver about request */ | 1223 | /* Notify solver about request */ |
1334 | ph.env.sf.s_get (ph.solver, &ph.peers[cp].id); | 1224 | ph.env.sf.s_get (ph.solver, &ph.peers[cp].id); |
@@ -1372,7 +1262,7 @@ perf_run_iteration (void) | |||
1372 | GNUNET_assert (GNUNET_NO == ph.bulk_running); | 1262 | GNUNET_assert (GNUNET_NO == ph.bulk_running); |
1373 | } | 1263 | } |
1374 | } | 1264 | } |
1375 | 1265 | fprintf (stderr,"\n"); | |
1376 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 1266 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
1377 | "Done, cleaning up addresses\n"); | 1267 | "Done, cleaning up addresses\n"); |
1378 | if (GNUNET_NO == ph.bulk_running) | 1268 | if (GNUNET_NO == ph.bulk_running) |
diff --git a/src/ats/perf_ats_solver.conf b/src/ats/perf_ats_solver.conf index 83d5e0164..2cdb6cfae 100644 --- a/src/ats/perf_ats_solver.conf +++ b/src/ats/perf_ats_solver.conf | |||
@@ -1,19 +1,50 @@ | |||
1 | [ats] | 1 | [ats] |
2 | # Network specific inbound/outbound quotas | 2 | # Network specific inbound/outbound quotas |
3 | UNSPECIFIED_QUOTA_IN = unlimited | 3 | UNSPECIFIED_QUOTA_IN = 1000 |
4 | UNSPECIFIED_QUOTA_OUT = unlimited | 4 | UNSPECIFIED_QUOTA_OUT = 1000 |
5 | # LOOPBACK | 5 | # LOOPBACK |
6 | LOOPBACK_QUOTA_IN = unlimited | 6 | LOOPBACK_QUOTA_IN = 1000 |
7 | LOOPBACK_QUOTA_OUT = unlimited | 7 | LOOPBACK_QUOTA_OUT = 1000 |
8 | # LAN | 8 | # LAN |
9 | LAN_QUOTA_IN = unlimited | 9 | LAN_QUOTA_IN = 1000 |
10 | LAN_QUOTA_OUT = unlimited | 10 | LAN_QUOTA_OUT = 1000 |
11 | # WAN | 11 | # WAN |
12 | WAN_QUOTA_IN = unlimited | 12 | WAN_QUOTA_IN = 1000 |
13 | WAN_QUOTA_OUT = unlimited | 13 | WAN_QUOTA_OUT = 1000 |
14 | # WLAN | 14 | # WLAN |
15 | WLAN_QUOTA_IN = unlimited | 15 | WLAN_QUOTA_IN = 1000 |
16 | WLAN_QUOTA_OUT = unlimited | 16 | WLAN_QUOTA_OUT = 1000 |
17 | # BLUETOOTH | 17 | # BLUETOOTH |
18 | BLUETOOTH_QUOTA_IN = unlimited | 18 | BLUETOOTH_QUOTA_IN = 1000 |
19 | BLUETOOTH_QUOTA_OUT = unlimited | 19 | BLUETOOTH_QUOTA_OUT = 1000 |
20 | |||
21 | # Proportional specific settings | ||
22 | # How proportional to preferences is bandwidth distribution in a network | ||
23 | # 1: Fair with respect to addresses without preferences | ||
24 | # > 100: The bigger, the more respect is payed to preferences | ||
25 | PROP_PROPORTIONALITY_FACTOR = 200 | ||
26 | # Should we stick to existing connections are prefer to switch? | ||
27 | # [100...200], lower value prefers to switch, bigger value is more tolerant | ||
28 | PROP_STABILITY_FACTOR = 125 | ||
29 | |||
30 | # MLP specific settings | ||
31 | # MLP defaults | ||
32 | |||
33 | # Maximum duration for a solution process | ||
34 | # MLP_MAX_DURATION = 3 s | ||
35 | |||
36 | # Maximum number of iterations for a solution process | ||
37 | # MLP_MAX_ITERATIONS = 1024 | ||
38 | # MLP_COEFFICIENT_D = 1.0 | ||
39 | # MLP_COEFFICIENT_U = 1.0 | ||
40 | # MLP_COEFFICIENT_R = 1.0 | ||
41 | MLP_MIN_BANDWIDTH = 1 | ||
42 | # MLP_MIN_CONNECTIONS = 4 | ||
43 | |||
44 | # MLP Log settings | ||
45 | # Dump all problems to disk | ||
46 | MLP_DUMP_PROBLEM_ALL = NO | ||
47 | # Dump all solution to disk | ||
48 | MLP_DUMP_SOLUTION_ALL = NO | ||
49 | # Print GLPK output | ||
50 | MLP_GLPK_VERBOSE = NO | ||
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c index 1cbfbddfa..27a502f13 100644 --- a/src/ats/plugin_ats_mlp.c +++ b/src/ats/plugin_ats_mlp.c | |||
@@ -736,12 +736,12 @@ mlp_create_problem_add_address_information (void *cls, | |||
736 | for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) | 736 | for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) |
737 | { | 737 | { |
738 | addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE); | 738 | addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE); |
739 | |||
739 | if (GNUNET_ATS_VALUE_UNDEFINED == addr_net) | 740 | if (GNUNET_ATS_VALUE_UNDEFINED == addr_net) |
740 | { | 741 | { |
741 | GNUNET_break (0); | 742 | GNUNET_break (0); |
742 | addr_net = GNUNET_ATS_NET_UNSPECIFIED; | 743 | addr_net = GNUNET_ATS_NET_UNSPECIFIED; |
743 | } | 744 | } |
744 | |||
745 | if (mlp->pv.quota_index[c] == addr_net) | 745 | if (mlp->pv.quota_index[c] == addr_net) |
746 | { | 746 | { |
747 | mlp_create_problem_set_value (p, p->r_quota[c], mlpi->c_b, 1, __LINE__); | 747 | mlp_create_problem_set_value (p, p->r_quota[c], mlpi->c_b, 1, __LINE__); |
@@ -753,8 +753,16 @@ mlp_create_problem_add_address_information (void *cls, | |||
753 | /* For all quality metrics, set quality of this address */ | 753 | /* For all quality metrics, set quality of this address */ |
754 | props = mlp->get_properties (mlp->get_properties_cls, address); | 754 | props = mlp->get_properties (mlp->get_properties_cls, address); |
755 | for (c = 0; c < mlp->pv.m_q; c++) | 755 | for (c = 0; c < mlp->pv.m_q; c++) |
756 | { | ||
757 | if ((props[c] < 1.0) && (props[c] > 2.0)) | ||
758 | { | ||
759 | fprintf (stderr, "PROP == %.3f \t ", props[c]); | ||
760 | GNUNET_break (0); | ||
761 | } | ||
756 | mlp_create_problem_set_value (p, p->r_q[c], mlpi->c_b, props[c], __LINE__); | 762 | mlp_create_problem_set_value (p, p->r_q[c], mlpi->c_b, props[c], __LINE__); |
763 | } | ||
757 | 764 | ||
765 | //fprintf (stderr, "\n"); | ||
758 | return GNUNET_OK; | 766 | return GNUNET_OK; |
759 | } | 767 | } |
760 | 768 | ||
@@ -1173,7 +1181,7 @@ GAS_mlp_solve_problem (void *solver) | |||
1173 | return GNUNET_SYSERR; | 1181 | return GNUNET_SYSERR; |
1174 | } | 1182 | } |
1175 | notify(mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_SUCCESS, GAS_INFO_FULL); | 1183 | notify(mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_SUCCESS, GAS_INFO_FULL); |
1176 | mlp->control_param_lp.presolve = GLP_YES; | 1184 | mlp->control_param_lp.presolve = GLP_YES; /* LP presolver, we need lp solution */ |
1177 | mlp->control_param_mlp.presolve = GNUNET_NO; /* No presolver, we have LP solution */ | 1185 | mlp->control_param_mlp.presolve = GNUNET_NO; /* No presolver, we have LP solution */ |
1178 | } | 1186 | } |
1179 | else | 1187 | else |
@@ -1192,7 +1200,8 @@ GAS_mlp_solve_problem (void *solver) | |||
1192 | start_cur_op = GNUNET_TIME_absolute_get(); | 1200 | start_cur_op = GNUNET_TIME_absolute_get(); |
1193 | 1201 | ||
1194 | /* Solve LP */ | 1202 | /* Solve LP */ |
1195 | mlp->control_param_lp.presolve = GLP_YES; | 1203 | /* Only for debugging, always use LP presolver: |
1204 | * mlp->control_param_lp.presolve = GLP_YES; */ | ||
1196 | res_lp = mlp_solve_lp_problem(mlp); | 1205 | res_lp = mlp_solve_lp_problem(mlp); |
1197 | 1206 | ||
1198 | dur_lp = GNUNET_TIME_absolute_get_duration (start_cur_op); | 1207 | dur_lp = GNUNET_TIME_absolute_get_duration (start_cur_op); |
@@ -1200,6 +1209,7 @@ GAS_mlp_solve_problem (void *solver) | |||
1200 | (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, | 1209 | (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, |
1201 | (GNUNET_YES == mlp->stat_mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); | 1210 | (GNUNET_YES == mlp->stat_mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); |
1202 | 1211 | ||
1212 | res_lp = GNUNET_OK; | ||
1203 | 1213 | ||
1204 | /* Run MLP solver */ | 1214 | /* Run MLP solver */ |
1205 | if (GNUNET_OK == res_lp) | 1215 | if (GNUNET_OK == res_lp) |
@@ -1210,7 +1220,8 @@ GAS_mlp_solve_problem (void *solver) | |||
1210 | start_cur_op = GNUNET_TIME_absolute_get(); | 1220 | start_cur_op = GNUNET_TIME_absolute_get(); |
1211 | 1221 | ||
1212 | /* Solve MIP */ | 1222 | /* Solve MIP */ |
1213 | //mlp->control_param_mlp.presolve = GNUNET_YES; | 1223 | /* Only for debugging, always use MLP presolver: |
1224 | * mlp->control_param_mlp.presolve = GNUNET_YES; */ | ||
1214 | res_mip = mlp_solve_mlp_problem(mlp); | 1225 | res_mip = mlp_solve_mlp_problem(mlp); |
1215 | 1226 | ||
1216 | dur_mlp = GNUNET_TIME_absolute_get_duration (start_cur_op); | 1227 | dur_mlp = GNUNET_TIME_absolute_get_duration (start_cur_op); |
@@ -1225,6 +1236,7 @@ GAS_mlp_solve_problem (void *solver) | |||
1225 | /* Do not execute mip solver since lp solution is invalid */ | 1236 | /* Do not execute mip solver since lp solution is invalid */ |
1226 | dur_mlp = GNUNET_TIME_UNIT_ZERO; | 1237 | dur_mlp = GNUNET_TIME_UNIT_ZERO; |
1227 | dur_total = GNUNET_TIME_absolute_get_duration (start_total); | 1238 | dur_total = GNUNET_TIME_absolute_get_duration (start_total); |
1239 | //GNUNET_break(0); | ||
1228 | notify(mlp, GAS_OP_SOLVE_MLP_MLP_STOP, GAS_STAT_FAIL, | 1240 | notify(mlp, GAS_OP_SOLVE_MLP_MLP_STOP, GAS_STAT_FAIL, |
1229 | (GNUNET_YES == mlp->stat_mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); | 1241 | (GNUNET_YES == mlp->stat_mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); |
1230 | res_mip = GNUNET_SYSERR; | 1242 | res_mip = GNUNET_SYSERR; |
@@ -1254,7 +1266,7 @@ GAS_mlp_solve_problem (void *solver) | |||
1254 | mlp->ps.p_elements = mlp->p.num_elements; | 1266 | mlp->ps.p_elements = mlp->p.num_elements; |
1255 | 1267 | ||
1256 | /* Propagate result*/ | 1268 | /* Propagate result*/ |
1257 | notify(mlp, GAS_OP_SOLVE_UPDATE_NOTIFICATION_START, | 1269 | notify (mlp, GAS_OP_SOLVE_UPDATE_NOTIFICATION_START, |
1258 | (GNUNET_OK == res_lp) && (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, | 1270 | (GNUNET_OK == res_lp) && (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, |
1259 | GAS_INFO_NONE); | 1271 | GAS_INFO_NONE); |
1260 | if ((GNUNET_OK == res_lp) && (GNUNET_OK == res_mip)) | 1272 | if ((GNUNET_OK == res_lp) && (GNUNET_OK == res_mip)) |
@@ -1262,7 +1274,7 @@ GAS_mlp_solve_problem (void *solver) | |||
1262 | GNUNET_CONTAINER_multipeermap_iterate(mlp->addresses, | 1274 | GNUNET_CONTAINER_multipeermap_iterate(mlp->addresses, |
1263 | &mlp_propagate_results, mlp); | 1275 | &mlp_propagate_results, mlp); |
1264 | } | 1276 | } |
1265 | notify(mlp, GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP, | 1277 | notify (mlp, GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP, |
1266 | (GNUNET_OK == res_lp) && (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, | 1278 | (GNUNET_OK == res_lp) && (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, |
1267 | GAS_INFO_NONE); | 1279 | GAS_INFO_NONE); |
1268 | 1280 | ||
@@ -1375,7 +1387,7 @@ GAS_mlp_address_property_changed (void *solver, | |||
1375 | 1387 | ||
1376 | if (NULL == mlpi) | 1388 | if (NULL == mlpi) |
1377 | { | 1389 | { |
1378 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1390 | LOG (GNUNET_ERROR_TYPE_INFO, |
1379 | _("Updating address property `%s' for peer `%s' %p not added before\n"), | 1391 | _("Updating address property `%s' for peer `%s' %p not added before\n"), |
1380 | GNUNET_ATS_print_property_type (type), | 1392 | GNUNET_ATS_print_property_type (type), |
1381 | GNUNET_i2s(&address->peer), | 1393 | GNUNET_i2s(&address->peer), |
@@ -1390,9 +1402,11 @@ GAS_mlp_address_property_changed (void *solver, | |||
1390 | /* Peer is not requested, so no need to update problem */ | 1402 | /* Peer is not requested, so no need to update problem */ |
1391 | return; | 1403 | return; |
1392 | } | 1404 | } |
1393 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating property `%s' address for peer `%s'\n", | 1405 | LOG (GNUNET_ERROR_TYPE_INFO, "Updating property `%s' address for peer `%s' to abs %llu rel %.3f\n", |
1394 | GNUNET_ATS_print_property_type (type), | 1406 | GNUNET_ATS_print_property_type (type), |
1395 | GNUNET_i2s(&address->peer)); | 1407 | GNUNET_i2s(&address->peer), |
1408 | abs_value, | ||
1409 | rel_value); | ||
1396 | 1410 | ||
1397 | /* Find row index */ | 1411 | /* Find row index */ |
1398 | type_index = -1; | 1412 | type_index = -1; |
@@ -1681,16 +1695,23 @@ get_peer_pref_value (struct GAS_MLP_Handle *mlp, const struct GNUNET_PeerIdentit | |||
1681 | int c; | 1695 | int c; |
1682 | preferences = mlp->get_preferences (mlp->get_preferences_cls, peer); | 1696 | preferences = mlp->get_preferences (mlp->get_preferences_cls, peer); |
1683 | 1697 | ||
1684 | res = 1.0; | 1698 | res = 0.0; |
1685 | for (c = 0; c < GNUNET_ATS_PreferenceCount; c++) | 1699 | for (c = 0; c < GNUNET_ATS_PreferenceCount; c++) |
1686 | { | 1700 | { |
1687 | if (c != GNUNET_ATS_PREFERENCE_END) | 1701 | if (c != GNUNET_ATS_PREFERENCE_END) |
1688 | { | 1702 | { |
1689 | //fprintf (stderr, "VALUE[%u] %s %.3f \n", c, GNUNET_i2s (&cur->addr->peer), t[c]); | 1703 | /* fprintf (stderr, "VALUE[%u] %s %.3f \n", |
1704 | * c, GNUNET_i2s (&cur->addr->peer), t[c]); */ | ||
1690 | res += preferences[c]; | 1705 | res += preferences[c]; |
1691 | } | 1706 | } |
1692 | } | 1707 | } |
1708 | |||
1693 | res /= (GNUNET_ATS_PreferenceCount -1); | 1709 | res /= (GNUNET_ATS_PreferenceCount -1); |
1710 | res += 1.0; | ||
1711 | |||
1712 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peer preference for peer `%s' == %.2f\n", | ||
1713 | GNUNET_i2s(peer), res); | ||
1714 | |||
1694 | return res; | 1715 | return res; |
1695 | } | 1716 | } |
1696 | 1717 | ||
@@ -1847,13 +1868,10 @@ GAS_mlp_address_change_preference (void *solver, | |||
1847 | /* Update relativity constraint c9 */ | 1868 | /* Update relativity constraint c9 */ |
1848 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, peer))) | 1869 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, peer))) |
1849 | { | 1870 | { |
1850 | LOG (GNUNET_ERROR_TYPE_ERROR, "Updating preference for unknown peer `%s'\n", GNUNET_i2s(peer)); | 1871 | LOG (GNUNET_ERROR_TYPE_INFO, "Updating preference for unknown peer `%s'\n", GNUNET_i2s(peer)); |
1851 | return; | 1872 | return; |
1852 | } | 1873 | } |
1853 | p->f = get_peer_pref_value (mlp, peer); | 1874 | p->f = get_peer_pref_value (mlp, peer); |
1854 | /* | ||
1855 | LOG (GNUNET_ERROR_TYPE_ERROR, "PEER PREF: %s %.2f\n", | ||
1856 | GNUNET_i2s(peer), p->f);*/ | ||
1857 | mlp_create_problem_update_value (&mlp->p, p->r_c9, mlp->p.c_r, -p->f, __LINE__); | 1875 | mlp_create_problem_update_value (&mlp->p, p->r_c9, mlp->p.c_r, -p->f, __LINE__); |
1858 | 1876 | ||
1859 | /* Problem size changed: new address for peer with pending request */ | 1877 | /* Problem size changed: new address for peer with pending request */ |