aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-01-28 13:31:58 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-01-28 13:31:58 +0000
commit993635e2173c3dfd1990e9a0e64314ad729ea749 (patch)
tree75f046d31900b8f189e514cd92c1f7034dc3725d /src
parent9338d4bf1b8a53cb0043c38cd3527e63e8ee5a64 (diff)
downloadgnunet-993635e2173c3dfd1990e9a0e64314ad729ea749.tar.gz
gnunet-993635e2173c3dfd1990e9a0e64314ad729ea749.zip
fix: only include peers with requests and addresses available, otherwise system has no solution due to min_peer restriction
Diffstat (limited to 'src')
-rw-r--r--src/ats/plugin_ats_mlp.c47
1 files changed, 37 insertions, 10 deletions
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c
index 3345be615..ac92fd305 100644
--- a/src/ats/plugin_ats_mlp.c
+++ b/src/ats/plugin_ats_mlp.c
@@ -390,7 +390,7 @@ get_performance_info (struct ATS_Address *address, uint32_t type)
390 390
391struct CountContext 391struct CountContext
392{ 392{
393 const struct GNUNET_CONTAINER_MultiPeerMap *peers; 393 const struct GNUNET_CONTAINER_MultiPeerMap *map;
394 int result; 394 int result;
395}; 395};
396 396
@@ -402,22 +402,50 @@ mlp_create_problem_count_addresses_it (void *cls,
402 struct CountContext *cctx = cls; 402 struct CountContext *cctx = cls;
403 403
404 /* Check if we have to add this peer due to a pending request */ 404 /* Check if we have to add this peer due to a pending request */
405 if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (cctx->peers, key)) 405 if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (cctx->map, key))
406 cctx->result++; 406 cctx->result++;
407 return GNUNET_OK; 407 return GNUNET_OK;
408} 408}
409 409
410 410
411static int 411static int
412mlp_create_problem_count_addresses (const struct GNUNET_CONTAINER_MultiPeerMap *peers, 412mlp_create_problem_count_addresses (const struct GNUNET_CONTAINER_MultiPeerMap *requested_peers,
413 const struct GNUNET_CONTAINER_MultiPeerMap *addresses) 413 const struct GNUNET_CONTAINER_MultiPeerMap *addresses)
414{ 414{
415 struct CountContext cctx; 415 struct CountContext cctx;
416 416
417 cctx.peers = peers; 417 cctx.map = requested_peers;
418 cctx.result = 0; 418 cctx.result = 0;
419 GNUNET_CONTAINER_multipeermap_iterate (addresses, 419 GNUNET_CONTAINER_multipeermap_iterate (addresses,
420 &mlp_create_problem_count_addresses_it, &cctx); 420 &mlp_create_problem_count_addresses_it, &cctx);
421 return cctx.result;
422}
423
424
425static int
426mlp_create_problem_count_peers_it (void *cls,
427 const struct GNUNET_PeerIdentity *key,
428 void *value)
429{
430 struct CountContext *cctx = cls;
431
432 /* Check if we have to addresses for the requested peer */
433 if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (cctx->map, key))
434 cctx->result++;
435 return GNUNET_OK;
436}
437
438
439static int
440mlp_create_problem_count_peers (const struct GNUNET_CONTAINER_MultiPeerMap *requested_peers,
441 const struct GNUNET_CONTAINER_MultiPeerMap *addresses)
442{
443 struct CountContext cctx;
444
445 cctx.map = addresses;
446 cctx.result = 0;
447 GNUNET_CONTAINER_multipeermap_iterate (requested_peers,
448 &mlp_create_problem_count_peers_it, &cctx);
421 return cctx.result; 449 return cctx.result;
422} 450}
423 451
@@ -835,7 +863,7 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp)
835 /* create the glpk problem */ 863 /* create the glpk problem */
836 p->prob = glp_create_prob (); 864 p->prob = glp_create_prob ();
837 GNUNET_assert (NULL != p->prob); 865 GNUNET_assert (NULL != p->prob);
838 p->num_peers = GNUNET_CONTAINER_multipeermap_size (mlp->requested_peers); 866 p->num_peers = mlp_create_problem_count_peers (mlp->requested_peers, mlp->addresses);
839 p->num_addresses = mlp_create_problem_count_addresses (mlp->requested_peers, mlp->addresses); 867 p->num_addresses = mlp_create_problem_count_addresses (mlp->requested_peers, mlp->addresses);
840 868
841 /* Create problem matrix: 10 * #addresses + #q * #addresses + #q, + #peer + 2 + 1 */ 869 /* Create problem matrix: 10 * #addresses + #q * #addresses + #q, + #peer + 2 + 1 */
@@ -1197,7 +1225,6 @@ GAS_mlp_solve_problem (void *solver)
1197 /* Do not execute mip solver since lp solution is invalid */ 1225 /* Do not execute mip solver since lp solution is invalid */
1198 dur_mlp = GNUNET_TIME_UNIT_ZERO; 1226 dur_mlp = GNUNET_TIME_UNIT_ZERO;
1199 dur_total = GNUNET_TIME_absolute_get_duration (start_total); 1227 dur_total = GNUNET_TIME_absolute_get_duration (start_total);
1200 GNUNET_break (0);
1201 notify(mlp, GAS_OP_SOLVE_MLP_MLP_STOP, GAS_STAT_FAIL, 1228 notify(mlp, GAS_OP_SOLVE_MLP_MLP_STOP, GAS_STAT_FAIL,
1202 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); 1229 (GNUNET_YES == mlp->mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED);
1203 res_mip = GNUNET_SYSERR; 1230 res_mip = GNUNET_SYSERR;
@@ -1244,10 +1271,10 @@ GAS_mlp_solve_problem (void *solver)
1244 (mlp->dump_solution_on_fail && ((GNUNET_OK != res_lp) || (GNUNET_OK != res_mip))) ) 1271 (mlp->dump_solution_on_fail && ((GNUNET_OK != res_lp) || (GNUNET_OK != res_mip))) )
1245 { 1272 {
1246 /* Write problem to disk */ 1273 /* Write problem to disk */
1247 GNUNET_asprintf(&filename, "problem_p_%u_a%u_%llu.mps", mlp->p.num_peers, 1274 GNUNET_asprintf(&filename, "problem_p_%u_a%u_%llu.lp", mlp->p.num_peers,
1248 mlp->p.num_addresses, time.abs_value_us); 1275 mlp->p.num_addresses, time.abs_value_us);
1249 LOG(GNUNET_ERROR_TYPE_ERROR, "Dumped problem to file: `%s' \n", filename); 1276 LOG(GNUNET_ERROR_TYPE_ERROR, "Dumped problem to file: `%s' \n", filename);
1250 glp_write_mps (mlp->p.prob, GLP_MPS_FILE, NULL, filename); 1277 glp_write_lp (mlp->p.prob, NULL, filename);
1251 GNUNET_free(filename); 1278 GNUNET_free(filename);
1252 } 1279 }
1253 if ( (mlp->dump_solution_all) || 1280 if ( (mlp->dump_solution_all) ||
@@ -1576,7 +1603,7 @@ GAS_mlp_address_delete (void *solver,
1576 if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, 1603 if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers,
1577 &address->peer))) 1604 &address->peer)))
1578 { 1605 {
1579 LOG (GNUNET_ERROR_TYPE_DEBUG, "Deleting %s for peer `%s' without address request \n", 1606 LOG (GNUNET_ERROR_TYPE_INFO, "Deleting %s for peer `%s' without address request \n",
1580 (session_only == GNUNET_YES) ? "session" : "address", 1607 (session_only == GNUNET_YES) ? "session" : "address",
1581 GNUNET_i2s(&address->peer)); 1608 GNUNET_i2s(&address->peer));
1582 return; 1609 return;