diff options
Diffstat (limited to 'src/ats/perf_ats_mlp.c')
-rw-r--r-- | src/ats/perf_ats_mlp.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c index a9a142387..b6955b766 100644 --- a/src/ats/perf_ats_mlp.c +++ b/src/ats/perf_ats_mlp.c | |||
@@ -150,6 +150,12 @@ normalized_property_changed_cb (void *cls, | |||
150 | /* TODO */ | 150 | /* TODO */ |
151 | } | 151 | } |
152 | 152 | ||
153 | const double * | ||
154 | get_property_cb (void *cls, const struct ATS_Address *address) | ||
155 | { | ||
156 | return GAS_normalization_get_properties ((struct ATS_Address *) address); | ||
157 | } | ||
158 | |||
153 | 159 | ||
154 | static const double * | 160 | static const double * |
155 | get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) | 161 | get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) |
@@ -184,7 +190,7 @@ address_initial_update (void *solver, struct GNUNET_CONTAINER_MultiHashMap * add | |||
184 | ats[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | 190 | ats[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); |
185 | ats[1].value = htonl (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 10)); | 191 | ats[1].value = htonl (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 10)); |
186 | 192 | ||
187 | GAS_mlp_address_update (mlp, addresses, address, 0, GNUNET_YES, ats, 2); | 193 | GAS_mlp_address_update (mlp, address, 0, GNUNET_YES, ats, 2); |
188 | } | 194 | } |
189 | 195 | ||
190 | 196 | ||
@@ -215,7 +221,7 @@ update_single_addresses (struct ATS_Address *cur) | |||
215 | default: | 221 | default: |
216 | break; | 222 | break; |
217 | } | 223 | } |
218 | GAS_mlp_address_update (mlp, addresses, cur, 0, GNUNET_YES, ats, 1); | 224 | GAS_mlp_address_update (mlp, cur, 0, GNUNET_YES, ats, 1); |
219 | } | 225 | } |
220 | 226 | ||
221 | static void | 227 | static void |
@@ -314,8 +320,11 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
314 | addresses = GNUNET_CONTAINER_multihashmap_create (N_address, GNUNET_NO); | 320 | addresses = GNUNET_CONTAINER_multihashmap_create (N_address, GNUNET_NO); |
315 | 321 | ||
316 | /* Init MLP solver */ | 322 | /* Init MLP solver */ |
317 | mlp = GAS_mlp_init (cfg, stats, quotas, quotas_out, quotas_in, | 323 | mlp = GAS_mlp_init (cfg, stats, addresses, |
318 | GNUNET_ATS_NetworkTypeCount, &bandwidth_changed_cb, NULL, &get_preferences_cb, NULL); | 324 | quotas, quotas_out, quotas_in, |
325 | GNUNET_ATS_NetworkTypeCount, &bandwidth_changed_cb, NULL, | ||
326 | &get_preferences_cb, NULL, | ||
327 | &get_property_cb, NULL); | ||
319 | if (NULL == mlp) | 328 | if (NULL == mlp) |
320 | { | 329 | { |
321 | GNUNET_break (0); | 330 | GNUNET_break (0); |
@@ -338,16 +347,16 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
338 | { | 347 | { |
339 | cur_addr = perf_create_address(cp, ca); | 348 | cur_addr = perf_create_address(cp, ca); |
340 | /* add address */ | 349 | /* add address */ |
341 | GAS_mlp_address_add (mlp, addresses, cur_addr, GNUNET_ATS_NET_UNSPECIFIED); | 350 | GAS_mlp_address_add (mlp, cur_addr, GNUNET_ATS_NET_UNSPECIFIED); |
342 | address_initial_update (mlp, addresses, cur_addr); | 351 | address_initial_update (mlp, addresses, cur_addr); |
343 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding address for peer %u address %u: \n", cp, ca); | 352 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding address for peer %u address %u: \n", cp, ca); |
344 | } | 353 | } |
345 | GAS_mlp_get_preferred_address( mlp, addresses, &peers[cp].id); | 354 | GAS_mlp_get_preferred_address( mlp, &peers[cp].id); |
346 | /* solve */ | 355 | /* solve */ |
347 | if (cp + 1 >= N_peers_start) | 356 | if (cp + 1 >= N_peers_start) |
348 | { | 357 | { |
349 | /* Solve the full problem */ | 358 | /* Solve the full problem */ |
350 | GAS_mlp_solve_problem (mlp, addresses); | 359 | GAS_mlp_solve_problem (mlp); |
351 | full_lp_res = mlp->ps.lp_res; | 360 | full_lp_res = mlp->ps.lp_res; |
352 | full_mip_res = mlp->ps.mip_res; | 361 | full_mip_res = mlp->ps.mip_res; |
353 | full_lp_presolv = mlp->ps.lp_presolv; | 362 | full_lp_presolv = mlp->ps.lp_presolv; |
@@ -361,8 +370,8 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
361 | { | 370 | { |
362 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating problem with %u peers and %u addresses\n", cp + 1, ca); | 371 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating problem with %u peers and %u addresses\n", cp + 1, ca); |
363 | update_addresses (cp + 1, ca, opt_update_quantity); | 372 | update_addresses (cp + 1, ca, opt_update_quantity); |
364 | GAS_mlp_solve_problem (mlp, addresses); | 373 | GAS_mlp_solve_problem (mlp); |
365 | GAS_mlp_solve_problem (mlp, addresses); | 374 | GAS_mlp_solve_problem (mlp); |
366 | update_lp_res = mlp->ps.lp_res; | 375 | update_lp_res = mlp->ps.lp_res; |
367 | update_mip_res = mlp->ps.mip_res; | 376 | update_mip_res = mlp->ps.mip_res; |
368 | update_lp_presolv = mlp->ps.lp_presolv; | 377 | update_lp_presolv = mlp->ps.lp_presolv; |
@@ -418,7 +427,7 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
418 | { | 427 | { |
419 | for (cur = peers[cp].head; cur != NULL; cur = next) | 428 | for (cur = peers[cp].head; cur != NULL; cur = next) |
420 | { | 429 | { |
421 | GAS_mlp_address_delete (mlp, addresses, cur, GNUNET_NO); | 430 | GAS_mlp_address_delete (mlp, cur, GNUNET_NO); |
422 | next = cur->next; | 431 | next = cur->next; |
423 | GNUNET_CONTAINER_DLL_remove (peers[cp].head, peers[cp].tail, cur); | 432 | GNUNET_CONTAINER_DLL_remove (peers[cp].head, peers[cp].tail, cur); |
424 | GNUNET_free (cur); | 433 | GNUNET_free (cur); |