aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorFabian Oehlmann <oehlmann@in.tum.de>2013-12-03 10:21:14 +0000
committerFabian Oehlmann <oehlmann@in.tum.de>2013-12-03 10:21:14 +0000
commit06b98ce26989dd42cad35f91ae9d8e757b602383 (patch)
tree5ef4a52fa0d36abd144fc4b59f8bfd060dc97637 /src/ats
parentd4ec66183d6f1591a0a775ea398a4f02cb921aee (diff)
downloadgnunet-06b98ce26989dd42cad35f91ae9d8e757b602383.tar.gz
gnunet-06b98ce26989dd42cad35f91ae9d8e757b602383.zip
removed unused function
Diffstat (limited to 'src/ats')
-rwxr-xr-xsrc/ats/libgnunet_plugin_ats_ril.c323
1 files changed, 165 insertions, 158 deletions
diff --git a/src/ats/libgnunet_plugin_ats_ril.c b/src/ats/libgnunet_plugin_ats_ril.c
index 9403975b8..7cc09950a 100755
--- a/src/ats/libgnunet_plugin_ats_ril.c
+++ b/src/ats/libgnunet_plugin_ats_ril.c
@@ -715,27 +715,27 @@ ril_network_get_assigned (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network
715 return sum; 715 return sum;
716} 716}
717 717
718static void 718//static void
719envi_state_networks (struct GAS_RIL_Handle *solver) 719//envi_state_networks (struct GAS_RIL_Handle *solver)
720{ 720//{
721 int i; 721// int i;
722 struct RIL_Network net; 722// struct RIL_Network net;
723 int overutilized_in; 723// int overutilized_in;
724 int overutilized_out; 724// int overutilized_out;
725 725//
726 for (i = 0; i < solver->networks_count; i++) 726// for (i = 0; i < solver->networks_count; i++)
727 { 727// {
728 net = solver->network_entries[i]; 728// net = solver->network_entries[i];
729 729//
730 overutilized_in = net.bw_in_assigned > net.bw_in_available; 730// overutilized_in = net.bw_in_assigned > net.bw_in_available;
731 overutilized_out = net.bw_out_assigned > net.bw_out_available; 731// overutilized_out = net.bw_out_assigned > net.bw_out_available;
732 732//
733 solver->global_state_networks[i * RIL_FEATURES_NETWORK_COUNT + 0] = ((double) net.bw_in_assigned / (double) net.bw_in_available)*10; 733// solver->global_state_networks[i * RIL_FEATURES_NETWORK_COUNT + 0] = ((double) net.bw_in_assigned / (double) net.bw_in_available)*10;
734 solver->global_state_networks[i * RIL_FEATURES_NETWORK_COUNT + 1] = (double) overutilized_in; 734// solver->global_state_networks[i * RIL_FEATURES_NETWORK_COUNT + 1] = (double) overutilized_in;
735 solver->global_state_networks[i * RIL_FEATURES_NETWORK_COUNT + 2] = ((double) net.bw_out_assigned / (double) net.bw_out_available)*10; 735// solver->global_state_networks[i * RIL_FEATURES_NETWORK_COUNT + 2] = ((double) net.bw_out_assigned / (double) net.bw_out_available)*10;
736 solver->global_state_networks[i * RIL_FEATURES_NETWORK_COUNT + 3] = (double) overutilized_out; 736// solver->global_state_networks[i * RIL_FEATURES_NETWORK_COUNT + 3] = (double) overutilized_out;
737 } 737// }
738} 738//}
739 739
740/** 740/**
741 * Allocates a state vector and fills it with the features present 741 * Allocates a state vector and fills it with the features present
@@ -803,140 +803,140 @@ envi_get_state (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent)
803 return state; 803 return state;
804} 804}
805 805
806/** 806///**
807 * For all networks a peer has an address in, this gets the maximum bandwidth which could 807// * For all networks a peer has an address in, this gets the maximum bandwidth which could
808 * theoretically be available in one of the networks. This is used for bandwidth normalization. 808// * theoretically be available in one of the networks. This is used for bandwidth normalization.
809 * 809// *
810 * @param agent the agent handle 810// * @param agent the agent handle
811 * @param direction_in whether the inbound bandwidth should be considered. Returns the maximum outbound bandwidth if GNUNET_NO 811// * @param direction_in whether the inbound bandwidth should be considered. Returns the maximum outbound bandwidth if GNUNET_NO
812 */ 812// */
813static unsigned long long 813//static unsigned long long
814ril_get_max_bw (struct RIL_Peer_Agent *agent, int direction_in) 814//ril_get_max_bw (struct RIL_Peer_Agent *agent, int direction_in)
815{ 815//{
816 /* 816// /*
817 * get the maximum bandwidth possible for a peer, e.g. among all addresses which addresses' 817// * get the maximum bandwidth possible for a peer, e.g. among all addresses which addresses'
818 * network could provide the maximum bandwidth if all that bandwidth was used on that one peer. 818// * network could provide the maximum bandwidth if all that bandwidth was used on that one peer.
819 */ 819// */
820 unsigned long long max = 0; 820// unsigned long long max = 0;
821 struct RIL_Address_Wrapped *cur; 821// struct RIL_Address_Wrapped *cur;
822 struct RIL_Network *net; 822// struct RIL_Network *net;
823 823//
824 for (cur = agent->addresses_head; NULL != cur; cur = cur->next) 824// for (cur = agent->addresses_head; NULL != cur; cur = cur->next)
825 { 825// {
826 net = cur->address_naked->solver_information; 826// net = cur->address_naked->solver_information;
827 if (direction_in) 827// if (direction_in)
828 { 828// {
829 if (net->bw_in_available > max) 829// if (net->bw_in_available > max)
830 { 830// {
831 max = net->bw_in_available; 831// max = net->bw_in_available;
832 } 832// }
833 } 833// }
834 else 834// else
835 { 835// {
836 if (net->bw_out_available > max) 836// if (net->bw_out_available > max)
837 { 837// {
838 max = net->bw_out_available; 838// max = net->bw_out_available;
839 } 839// }
840 } 840// }
841 } 841// }
842 return max; 842// return max;
843} 843//}
844 844
845/** 845///**
846 * Get the index of the quality-property in question 846// * Get the index of the quality-property in question
847 * 847// *
848 * @param type the quality property type 848// * @param type the quality property type
849 * @return the index 849// * @return the index
850 */ 850// */
851static int 851//static int
852ril_find_property_index (uint32_t type) 852//ril_find_property_index (uint32_t type)
853{ 853//{
854 int existing_types[] = GNUNET_ATS_QualityProperties; 854// int existing_types[] = GNUNET_ATS_QualityProperties;
855 int c; 855// int c;
856 for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) 856// for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
857 if (existing_types[c] == type) 857// if (existing_types[c] == type)
858 return c; 858// return c;
859 return GNUNET_SYSERR; 859// return GNUNET_SYSERR;
860} 860//}
861 861
862static int 862//static int
863ril_get_atsi (struct ATS_Address *address, uint32_t type) 863//ril_get_atsi (struct ATS_Address *address, uint32_t type)
864{ 864//{
865 int c1; 865// int c1;
866 GNUNET_assert(NULL != address); 866// GNUNET_assert(NULL != address);
867 867//
868 if ((NULL == address->atsi) || (0 == address->atsi_count)) 868// if ((NULL == address->atsi) || (0 == address->atsi_count))
869 return 0; 869// return 0;
870 870//
871 for (c1 = 0; c1 < address->atsi_count; c1++) 871// for (c1 = 0; c1 < address->atsi_count; c1++)
872 { 872// {
873 if (ntohl (address->atsi[c1].type) == type) 873// if (ntohl (address->atsi[c1].type) == type)
874 return ntohl (address->atsi[c1].value); 874// return ntohl (address->atsi[c1].value);
875 } 875// }
876 return 0; 876// return 0;
877} 877//}
878 878
879static double 879//static double
880envi_reward_global (struct GAS_RIL_Handle *solver) 880//envi_reward_global (struct GAS_RIL_Handle *solver)
881{ 881//{
882 int i; 882// int i;
883 struct RIL_Network net; 883// struct RIL_Network net;
884 unsigned int sum_in_available = 0; 884// unsigned int sum_in_available = 0;
885 unsigned int sum_out_available = 0; 885// unsigned int sum_out_available = 0;
886 unsigned int sum_in_assigned = 0; 886// unsigned int sum_in_assigned = 0;
887 unsigned int sum_out_assigned = 0; 887// unsigned int sum_out_assigned = 0;
888 double ratio_in; 888// double ratio_in;
889 double ratio_out; 889// double ratio_out;
890 890//
891 for (i = 0; i < solver->networks_count; i++) 891// for (i = 0; i < solver->networks_count; i++)
892 { 892// {
893 net = solver->network_entries[i]; 893// net = solver->network_entries[i];
894 sum_in_available += net.bw_in_available; 894// sum_in_available += net.bw_in_available;
895 sum_in_assigned += net.bw_in_assigned; 895// sum_in_assigned += net.bw_in_assigned;
896 sum_out_available += net.bw_out_available; 896// sum_out_available += net.bw_out_available;
897 sum_out_assigned += net.bw_out_assigned; 897// sum_out_assigned += net.bw_out_assigned;
898 } 898// }
899 899//
900 ratio_in = ((double) sum_in_assigned) / ((double) sum_in_available); 900// ratio_in = ((double) sum_in_assigned) / ((double) sum_in_available);
901 ratio_out = ((double) sum_out_assigned) / ((double) sum_out_available); 901// ratio_out = ((double) sum_out_assigned) / ((double) sum_out_available);
902 902//
903 // global reward in [1,2] 903// // global reward in [1,2]
904 return ratio_in +1; 904// return ratio_in +1;
905 return ((ratio_in + ratio_out) / 2) + 1; 905// return ((ratio_in + ratio_out) / 2) + 1;
906} 906//}
907 907
908static double 908//static double
909envi_reward_local (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) 909//envi_reward_local (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent)
910{ 910//{
911 const double *preferences; 911// const double *preferences;
912 const double *properties; 912// const double *properties;
913 int prop_index; 913// int prop_index;
914 double pref_match = 0; 914// double pref_match = 0;
915 double bw_norm; 915// double bw_norm;
916 double dl_norm; 916// double dl_norm;
917 917//
918 preferences = solver->plugin_envi->get_preferences (solver->plugin_envi->get_preference_cls, 918// preferences = solver->plugin_envi->get_preferences (solver->plugin_envi->get_preference_cls,
919 &agent->peer); 919// &agent->peer);
920 properties = solver->plugin_envi->get_property (solver->plugin_envi->get_property_cls, 920// properties = solver->plugin_envi->get_property (solver->plugin_envi->get_property_cls,
921 agent->address_inuse); 921// agent->address_inuse);
922 922//
923 // delay in [0,1] 923// // delay in [0,1]
924 prop_index = ril_find_property_index (GNUNET_ATS_QUALITY_NET_DELAY); 924// prop_index = ril_find_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
925 dl_norm = 2 - properties[prop_index]; //invert property as we want to maximize for lower latencies 925// dl_norm = 2 - properties[prop_index]; //invert property as we want to maximize for lower latencies
926 926//
927 // utilization in [0,1] 927// // utilization in [0,1]
928 bw_norm = (((double) ril_get_atsi (agent->address_inuse, GNUNET_ATS_UTILIZATION_IN) 928// bw_norm = (((double) ril_get_atsi (agent->address_inuse, GNUNET_ATS_UTILIZATION_IN)
929 / (double) ril_get_max_bw (agent, GNUNET_YES)) 929// / (double) ril_get_max_bw (agent, GNUNET_YES))
930 + ((double) ril_get_atsi (agent->address_inuse, GNUNET_ATS_UTILIZATION_OUT) 930// + ((double) ril_get_atsi (agent->address_inuse, GNUNET_ATS_UTILIZATION_OUT)
931 / (double) ril_get_max_bw (agent, GNUNET_NO))) / 2; 931// / (double) ril_get_max_bw (agent, GNUNET_NO))) / 2;
932 932//
933 // preference matching in [0,4] 933// // preference matching in [0,4]
934 pref_match += (preferences[GNUNET_ATS_PREFERENCE_LATENCY] * dl_norm); 934// pref_match += (preferences[GNUNET_ATS_PREFERENCE_LATENCY] * dl_norm);
935 pref_match += (preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] * bw_norm); 935// pref_match += (preferences[GNUNET_ATS_PREFERENCE_BANDWIDTH] * bw_norm);
936 936//
937 // local reward in [1,2] 937// // local reward in [1,2]
938 return (pref_match / 4) +1; 938// return (pref_match / 4) +1;
939} 939//}
940 940
941/** 941/**
942 * Gets the reward for the last performed step, which is calculated in equal 942 * Gets the reward for the last performed step, which is calculated in equal
@@ -2092,13 +2092,17 @@ GAS_ril_address_delete (void *solver, struct ATS_Address *address, int session_o
2092 m_new = agent->m - RIL_FEATURES_ADDRESS_COUNT; 2092 m_new = agent->m - RIL_FEATURES_ADDRESS_COUNT;
2093 n_new = agent->n - 1; 2093 n_new = agent->n - 1;
2094 2094
2095 LOG(GNUNET_ERROR_TYPE_DEBUG, "first\n");
2096
2095 for (i = 0; i < agent->n; i++) 2097 for (i = 0; i < agent->n; i++)
2096 { 2098 {
2097 ril_cut_from_vector ((void **) &agent->W[i], sizeof(double), 2099 ril_cut_from_vector ((void **) &agent->W[i], sizeof(double),
2098 ((s->networks_count * RIL_FEATURES_NETWORK_COUNT) 2100 //((s->networks_count * RIL_FEATURES_NETWORK_COUNT)
2101 ((RIL_FEATURES_NETWORK_COUNT) //TODO! replace, when adding more networks
2099 + (address_index * RIL_FEATURES_ADDRESS_COUNT)), RIL_FEATURES_ADDRESS_COUNT, agent->m); 2102 + (address_index * RIL_FEATURES_ADDRESS_COUNT)), RIL_FEATURES_ADDRESS_COUNT, agent->m);
2100 } 2103 }
2101 GNUNET_free(agent->W[RIL_ACTION_TYPE_NUM + address_index]); 2104 GNUNET_free(agent->W[RIL_ACTION_TYPE_NUM + address_index]);
2105 LOG(GNUNET_ERROR_TYPE_DEBUG, "second\n");
2102 ril_cut_from_vector ((void **) &agent->W, sizeof(double *), RIL_ACTION_TYPE_NUM + address_index, 2106 ril_cut_from_vector ((void **) &agent->W, sizeof(double *), RIL_ACTION_TYPE_NUM + address_index,
2103 1, agent->n); 2107 1, agent->n);
2104 //correct last action 2108 //correct last action
@@ -2111,11 +2115,14 @@ GAS_ril_address_delete (void *solver, struct ATS_Address *address, int session_o
2111 agent->a_old = RIL_ACTION_INVALID; 2115 agent->a_old = RIL_ACTION_INVALID;
2112 } 2116 }
2113 //decrease old state vector and eligibility vector 2117 //decrease old state vector and eligibility vector
2118 LOG(GNUNET_ERROR_TYPE_DEBUG, "third\n");
2114 ril_cut_from_vector ((void **) &agent->s_old, sizeof(double), 2119 ril_cut_from_vector ((void **) &agent->s_old, sizeof(double),
2115 ((s->networks_count * RIL_FEATURES_NETWORK_COUNT) 2120 //((s->networks_count * RIL_FEATURES_NETWORK_COUNT)
2121 ((RIL_FEATURES_NETWORK_COUNT) //TODO! replace when adding more networks
2116 + (address_index * RIL_FEATURES_ADDRESS_COUNT)), RIL_FEATURES_ADDRESS_COUNT, agent->m); 2122 + (address_index * RIL_FEATURES_ADDRESS_COUNT)), RIL_FEATURES_ADDRESS_COUNT, agent->m);
2117 ril_cut_from_vector ((void **) &agent->e, sizeof(double), 2123 ril_cut_from_vector ((void **) &agent->e, sizeof(double),
2118 ((s->networks_count * RIL_FEATURES_NETWORK_COUNT) 2124 //((s->networks_count * RIL_FEATURES_NETWORK_COUNT)
2125 ((RIL_FEATURES_NETWORK_COUNT) //TODO! replace when adding more networks
2119 + (address_index * RIL_FEATURES_ADDRESS_COUNT)), RIL_FEATURES_ADDRESS_COUNT, agent->m); 2126 + (address_index * RIL_FEATURES_ADDRESS_COUNT)), RIL_FEATURES_ADDRESS_COUNT, agent->m);
2120 agent->m = m_new; 2127 agent->m = m_new;
2121 agent->n = n_new; 2128 agent->n = n_new;