aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-06-24 10:56:22 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-06-24 10:56:22 +0000
commite31f1725d8aa2cc0e08aa8501ca961761f04c764 (patch)
treecc02a7ee9214fcf607d1888cab9a493f12eb1b4d /src/ats
parent5752e1aa99cae87bda55a05e098e8f8113142f36 (diff)
downloadgnunet-e31f1725d8aa2cc0e08aa8501ca961761f04c764.tar.gz
gnunet-e31f1725d8aa2cc0e08aa8501ca961761f04c764.zip
quality normalization without checking if min and max are given
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/gnunet-service-ats_normalization.c56
-rw-r--r--src/ats/gnunet-service-ats_normalization.h2
2 files changed, 39 insertions, 19 deletions
diff --git a/src/ats/gnunet-service-ats_normalization.c b/src/ats/gnunet-service-ats_normalization.c
index c290b697c..f5dbf04c9 100644
--- a/src/ats/gnunet-service-ats_normalization.c
+++ b/src/ats/gnunet-service-ats_normalization.c
@@ -576,11 +576,44 @@ uint32_t property_average (struct ATS_Address *address,
576 return 0; 576 return 0;
577} 577}
578 578
579void property_normalize (struct ATS_Address *address, 579double property_normalize (struct Property *p,
580 uint32_t type) 580 struct ATS_Address *address,
581 uint32_t type,
582 uint32_t avg_value)
581{ 583{
584 double res;
585 double delta;
582 /* Normalize the values of this property */ 586 /* Normalize the values of this property */
583 //GNUNET_break (0); 587 if (p->max < avg_value)
588 {
589 p->max = avg_value;
590 if (GNUNET_NO == p->have_max)
591 p->have_max = GNUNET_YES;
592 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
593 "New maximum of %u for property %u\n",
594 p->max, avg_value);
595 }
596 if (p->min > avg_value)
597 {
598 p->min = avg_value;
599 if (GNUNET_NO == p->have_min)
600 p->have_min = GNUNET_YES;
601 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
602 "New minimum of %u for property %u\n",
603 p->min, avg_value);
604 }
605
606 if ((GNUNET_YES == p->have_max) && (GNUNET_YES == p->have_min))
607 {
608 delta = p->max - p->min;
609 res = (delta + avg_value) / (delta);
610 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
611 "New normalized value of %f for property %u\n",
612 res, type);
613 return res;
614 }
615
616 return DEFAULT_REL_QUALITY;
584} 617}
585 618
586 619
@@ -627,22 +660,7 @@ GAS_normalization_normalize_property (struct ATS_Address *address,
627 /* Normalizing */ 660 /* Normalizing */
628 /* Check min, max */ 661 /* Check min, max */
629 cur_prop = &properties[c2]; 662 cur_prop = &properties[c2];
630 if (cur_prop->max < current_val) 663 property_normalize (cur_prop, address, ntohl(atsi[c1].type), current_val);
631 {
632 cur_prop->max = current_val;
633 if (GNUNET_NO == cur_prop->have_max)
634 cur_prop->have_max = GNUNET_YES;
635 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New maximum of %u for property %u\n", cur_prop->max, current_type);
636 }
637 if (cur_prop->min > current_val)
638 {
639 cur_prop->min = current_val;
640 if (GNUNET_NO == cur_prop->have_min)
641 cur_prop->have_min = GNUNET_YES;
642 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New minimum of %u for property %u\n", cur_prop->min, current_type);
643 }
644
645 //property_normalize (address, ntohl(atsi[c1].type));
646 } 664 }
647 665
648} 666}
diff --git a/src/ats/gnunet-service-ats_normalization.h b/src/ats/gnunet-service-ats_normalization.h
index 967702bae..24b6b5051 100644
--- a/src/ats/gnunet-service-ats_normalization.h
+++ b/src/ats/gnunet-service-ats_normalization.h
@@ -33,6 +33,8 @@
33#define DEFAULT_REL_PREFERENCE 1.0 33#define DEFAULT_REL_PREFERENCE 1.0
34#define DEFAULT_ABS_PREFERENCE 0.0 34#define DEFAULT_ABS_PREFERENCE 0.0
35 35
36#define DEFAULT_REL_QUALITY 1.0
37
36typedef void 38typedef void
37(*GAS_Normalization_preference_changed_cb) (void *cls, 39(*GAS_Normalization_preference_changed_cb) (void *cls,
38 const struct GNUNET_PeerIdentity *peer, 40 const struct GNUNET_PeerIdentity *peer,