aboutsummaryrefslogtreecommitdiff
path: root/src/ats/libgnunet_plugin_ats_ril.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats/libgnunet_plugin_ats_ril.c')
-rwxr-xr-xsrc/ats/libgnunet_plugin_ats_ril.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ats/libgnunet_plugin_ats_ril.c b/src/ats/libgnunet_plugin_ats_ril.c
index 22535413e..045cc91d5 100755
--- a/src/ats/libgnunet_plugin_ats_ril.c
+++ b/src/ats/libgnunet_plugin_ats_ril.c
@@ -771,6 +771,7 @@ envi_reward_global (struct GAS_RIL_Handle *solver)
771 ratio_in = ((double) in_assigned) / ((double) in_available); 771 ratio_in = ((double) in_assigned) / ((double) in_available);
772 ratio_out = ((double) out_assigned) / ((double) out_available); 772 ratio_out = ((double) out_assigned) / ((double) out_available);
773 773
774 // global reward in [1,2]
774 return ((ratio_in + ratio_out) / 2) + 1; 775 return ((ratio_in + ratio_out) / 2) + 1;
775} 776}
776 777
@@ -789,18 +790,21 @@ envi_reward_local (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent)
789 properties = solver->plugin_envi->get_property (solver->plugin_envi->get_property_cls, 790 properties = solver->plugin_envi->get_property (solver->plugin_envi->get_property_cls,
790 agent->address_inuse); 791 agent->address_inuse);
791 792
792 //preference matching from latency 793 // delay in [0,1]
793 prop_index = ril_find_property_index (GNUNET_ATS_QUALITY_NET_DELAY); 794 prop_index = ril_find_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
794 dl_norm = 2 - properties[prop_index]; //invert property as we want to maximize for lower latencies 795 dl_norm = 2 - properties[prop_index]; //invert property as we want to maximize for lower latencies
795 796
797 // utilization in [0,1]
796 bw_norm = ((ril_get_atsi (agent->address_inuse, GNUNET_ATS_UTILIZATION_IN) 798 bw_norm = ((ril_get_atsi (agent->address_inuse, GNUNET_ATS_UTILIZATION_IN)
797 / ril_get_max_bw (agent, GNUNET_YES)) 799 / ril_get_max_bw (agent, GNUNET_YES))
798 + (ril_get_atsi (agent->address_inuse, GNUNET_ATS_UTILIZATION_OUT) 800 + (ril_get_atsi (agent->address_inuse, GNUNET_ATS_UTILIZATION_OUT)
799 / ril_get_max_bw (agent, GNUNET_NO))) / 2; 801 / ril_get_max_bw (agent, GNUNET_NO))) / 2;
800 802
803 // preference matching in [0,4]
801 pref_match += (preferences[GNUNET_ATS_PREFERENCE_LATENCY] * dl_norm); 804 pref_match += (preferences[GNUNET_ATS_PREFERENCE_LATENCY] * dl_norm);
802 pref_match += (preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] * bw_norm); 805 pref_match += (preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] * bw_norm);
803 806
807 // local reward in [1,2]
804 return (pref_match / 4) +1; 808 return (pref_match / 4) +1;
805} 809}
806 810