diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-11-19 16:42:03 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-11-19 16:42:03 +0000 |
commit | 94a6bb6f521b4d57a10035ad294b4c8ef58f01ff (patch) | |
tree | 0357438d1a30092487866a990989e77b5a70e571 /src/ats/gnunet-service-ats_addresses.c | |
parent | 52acb8f4435955e07aa7694e96a1ab732c9c730d (diff) | |
download | gnunet-94a6bb6f521b4d57a10035ad294b4c8ef58f01ff.tar.gz gnunet-94a6bb6f521b4d57a10035ad294b4c8ef58f01ff.zip |
evaluation
Diffstat (limited to 'src/ats/gnunet-service-ats_addresses.c')
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 115 |
1 files changed, 82 insertions, 33 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index 833a26c41..be0e03031 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -1342,6 +1342,7 @@ eval_count_active_it (void *cls, const struct GNUNET_PeerIdentity *id, void *obj | |||
1342 | return GNUNET_YES; | 1342 | return GNUNET_YES; |
1343 | } | 1343 | } |
1344 | 1344 | ||
1345 | |||
1345 | /** | 1346 | /** |
1346 | * Summary context | 1347 | * Summary context |
1347 | */ | 1348 | */ |
@@ -1401,33 +1402,20 @@ struct RelativityContext { | |||
1401 | struct GAS_Addresses_Handle *ah; | 1402 | struct GAS_Addresses_Handle *ah; |
1402 | }; | 1403 | }; |
1403 | 1404 | ||
1404 | #if 0 | ||
1405 | static int | 1405 | static int |
1406 | eval_preference_relativity (void *cls, const struct GNUNET_PeerIdentity *id, void *obj) | 1406 | find_active_address (void *cls, const struct GNUNET_PeerIdentity *id, void *obj) |
1407 | { | 1407 | { |
1408 | struct RelativityContext *rc = cls; | 1408 | struct ATS_Address **res = cls; |
1409 | struct ATS_Address *addr = obj; | 1409 | struct ATS_Address *addr = obj; |
1410 | int prefs[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceType ; | ||
1411 | int c; | ||
1412 | const double *preferences; | ||
1413 | 1410 | ||
1414 | if (GNUNET_YES == addr->active) | 1411 | if (GNUNET_YES == addr->active) |
1415 | { | 1412 | (*res) = addr; |
1416 | preferences = get_preferences_cb (rc->ah->env.get_preference_cls, id); | ||
1417 | for (c = 0; c < GNUNET_ATS_PreferenceCount; c++) | ||
1418 | { | ||
1419 | if (prefs[c] == GNUNET_ATS_PREFERENCE_END) | ||
1420 | continue; | ||
1421 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Preference for peer `%s' type %s: %f\n", | ||
1422 | GNUNET_i2s (id), GNUNET_ATS_print_preference_type(prefs[c]), | ||
1423 | preferences[c]); | ||
1424 | } | ||
1425 | } | ||
1426 | 1413 | ||
1427 | return GNUNET_OK; | 1414 | if (NULL != (*res)) |
1415 | return GNUNET_NO; | ||
1416 | else | ||
1417 | return GNUNET_YES; | ||
1428 | } | 1418 | } |
1429 | #endif | ||
1430 | |||
1431 | 1419 | ||
1432 | /** | 1420 | /** |
1433 | * Evaluate current bandwidth assignment | 1421 | * Evaluate current bandwidth assignment |
@@ -1458,11 +1446,17 @@ GAS_addresses_evaluate_assignment (struct GAS_Addresses_Handle *ah) | |||
1458 | 1446 | ||
1459 | /* Variable related to utilization */ | 1447 | /* Variable related to utilization */ |
1460 | struct SummaryContext sum; | 1448 | struct SummaryContext sum; |
1449 | struct ATS_Address *active_address; | ||
1461 | int network_count; | 1450 | int network_count; |
1462 | 1451 | ||
1463 | /* Variables for preferences */ | 1452 | /* Variables for preferences */ |
1464 | int prefs[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceType; | 1453 | int prefs[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceType; |
1465 | double pref_val; | 1454 | double pref_val; |
1455 | double prop_val; | ||
1456 | const double *norm_values; | ||
1457 | double prefs_fulfill[GNUNET_ATS_PreferenceCount]; | ||
1458 | int prefs_clients[GNUNET_ATS_PreferenceCount]; | ||
1459 | int rels; | ||
1466 | 1460 | ||
1467 | GNUNET_assert (NULL != ah); | 1461 | GNUNET_assert (NULL != ah); |
1468 | GNUNET_assert (NULL != ah->addresses); | 1462 | GNUNET_assert (NULL != ah->addresses); |
@@ -1540,25 +1534,80 @@ GAS_addresses_evaluate_assignment (struct GAS_Addresses_Handle *ah) | |||
1540 | } | 1534 | } |
1541 | else | 1535 | else |
1542 | { | 1536 | { |
1543 | for (pcur = ah->preference_clients_head; NULL != pcur; pcur = pcur->next) | 1537 | for (c = 0; c < GNUNET_ATS_PreferenceCount; c++) |
1544 | { | 1538 | { |
1545 | /* V metrics*/ | 1539 | prefs_fulfill[c] = 0.0; |
1546 | for (c = 0; c < GNUNET_ATS_PreferenceCount; c++) | 1540 | prefs_clients[c] = 0; |
1547 | { | 1541 | } |
1548 | 1542 | ||
1549 | if (prefs[c] == GNUNET_ATS_PREFERENCE_END) | 1543 | for (cur = ah->pending_requests_head; NULL != cur; cur = cur->next) |
1550 | continue; | 1544 | { |
1551 | pref_val = -1.0; | 1545 | active_address = NULL; |
1552 | pref_val = GAS_normalization_get_preferences_by_client (pcur->client, prefs[c]); | 1546 | GNUNET_CONTAINER_multipeermap_get_multiple (ah->addresses, |
1553 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "normalized pref for client %p == %.3f\n", | 1547 | &cur->id, &find_active_address, &active_address); |
1554 | pcur->client, pref_val); | 1548 | |
1555 | if (-1.0 == pref_val) | 1549 | for (pcur = ah->preference_clients_head; NULL != pcur; pcur = pcur->next) |
1550 | { | ||
1551 | for (c = 0; c < GNUNET_ATS_PreferenceCount; c++) | ||
1556 | { | 1552 | { |
1557 | GNUNET_break (0); | 1553 | if (prefs[c] == GNUNET_ATS_PREFERENCE_END) |
1558 | continue; | 1554 | continue; |
1555 | pref_val = -1.0; | ||
1556 | pref_val = GAS_normalization_get_preferences_by_client (pcur->client, &cur->id, prefs[c]); | ||
1557 | if (-1.0 == pref_val) | ||
1558 | { | ||
1559 | GNUNET_break (0); | ||
1560 | continue; | ||
1561 | } | ||
1562 | |||
1563 | if (DEFAULT_REL_PREFERENCE == pref_val) | ||
1564 | { | ||
1565 | /* Default preference value */ | ||
1566 | continue; | ||
1567 | } | ||
1568 | |||
1569 | if (NULL != active_address) | ||
1570 | { | ||
1571 | norm_values = GAS_normalization_get_properties (active_address); | ||
1572 | prop_val = norm_values[c]; | ||
1573 | if ((norm_values[c] <= 1.0) || (norm_values[c] >= 2.0)) | ||
1574 | prop_val = DEFAULT_REL_QUALITY; | ||
1575 | } | ||
1576 | else | ||
1577 | { | ||
1578 | prop_val = DEFAULT_REL_QUALITY; | ||
1579 | } | ||
1580 | |||
1581 | /* We now have preference values [1..2] and properties [1..2] */ | ||
1582 | |||
1583 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u Client %p, Peer %s Property %s: pref: %.3f prop %.3f \n", | ||
1584 | c, | ||
1585 | pcur->client, | ||
1586 | GNUNET_i2s (&cur->id), | ||
1587 | GNUNET_ATS_print_preference_type(prefs[c]), | ||
1588 | pref_val, | ||
1589 | prop_val); | ||
1590 | |||
1591 | prefs_fulfill[c] += (pref_val * prop_val) / 2; | ||
1592 | prefs_clients[c] ++; | ||
1559 | } | 1593 | } |
1560 | } | 1594 | } |
1561 | } | 1595 | } |
1596 | rels = 0; | ||
1597 | for (c = 0; c < GNUNET_ATS_PreferenceCount; c++) | ||
1598 | { | ||
1599 | if (0 < prefs_clients[c]) | ||
1600 | { | ||
1601 | prefs_fulfill[c] /= prefs_clients[c]; | ||
1602 | rels ++; | ||
1603 | quality_application_requirements += prefs_fulfill[c]; | ||
1604 | } | ||
1605 | } | ||
1606 | if (rels > 0) | ||
1607 | quality_application_requirements /= rels; | ||
1608 | else | ||
1609 | quality_application_requirements = 0.0; | ||
1610 | |||
1562 | include_requirements = GNUNET_YES; | 1611 | include_requirements = GNUNET_YES; |
1563 | } | 1612 | } |
1564 | /* GUQ */ | 1613 | /* GUQ */ |