diff options
author | Fabian Oehlmann <oehlmann@in.tum.de> | 2013-12-16 11:38:09 +0000 |
---|---|---|
committer | Fabian Oehlmann <oehlmann@in.tum.de> | 2013-12-16 11:38:09 +0000 |
commit | c751c30da5392f186d8fd3d5999b1fe0fae06b46 (patch) | |
tree | 0ff15f7e180ac8ac0a42cf594aee9e41789c238a /src/ats | |
parent | 2f8be33175a8a018363e512a8f1dac9d9065a41d (diff) | |
download | gnunet-c751c30da5392f186d8fd3d5999b1fe0fae06b46.tar.gz gnunet-c751c30da5392f186d8fd3d5999b1fe0fae06b46.zip |
normalized feature vector
Diffstat (limited to 'src/ats')
-rwxr-xr-x | src/ats/plugin_ats_ril.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c index a1ea939f1..da8af16c9 100755 --- a/src/ats/plugin_ats_ril.c +++ b/src/ats/plugin_ats_ril.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #define RIL_ACTION_INVALID -1 | 33 | #define RIL_ACTION_INVALID -1 |
34 | #define RIL_FEATURES_ADDRESS_COUNT (0)// + GNUNET_ATS_QualityPropertiesCount) | 34 | #define RIL_FEATURES_ADDRESS_COUNT (0)// + GNUNET_ATS_QualityPropertiesCount) |
35 | #define RIL_FEATURES_NETWORK_COUNT 2 | 35 | #define RIL_FEATURES_NETWORK_COUNT 2 |
36 | #define RIL_FEATURES_INIT_COUNT 1 + RIL_FEATURES_NETWORK_COUNT // + GNUNET_ATS_PreferenceCount | ||
36 | #define RIL_INTERVAL_EXPONENT 10 | 37 | #define RIL_INTERVAL_EXPONENT 10 |
37 | 38 | ||
38 | #define RIL_DEFAULT_STEP_TIME_MIN GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500) | 39 | #define RIL_DEFAULT_STEP_TIME_MIN GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500) |
@@ -758,30 +759,26 @@ ril_network_get_assigned (struct GAS_RIL_Handle *solver, enum GNUNET_ATS_Network | |||
758 | static double * | 759 | static double * |
759 | envi_get_state (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) | 760 | envi_get_state (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) |
760 | { | 761 | { |
761 | int i; | 762 | // int i; |
762 | // int k; | 763 | // int k; |
763 | double *state = GNUNET_malloc (sizeof (double) * agent->m); | 764 | double *state = GNUNET_malloc (sizeof (double) * agent->m); |
764 | struct RIL_Address_Wrapped *cur_address; | 765 | // struct RIL_Address_Wrapped *cur_address; |
765 | // const double *preferences; | 766 | // const double *preferences; |
766 | // const double *properties; | 767 | // const double *properties; |
767 | struct RIL_Network *net; | 768 | struct RIL_Network *net; |
768 | 769 | ||
769 | //copy global networks state | 770 | //copy global networks state |
770 | for (i = 0; i < solver->networks_count * RIL_FEATURES_NETWORK_COUNT; i++) | 771 | // for (i = 0; i < solver->networks_count * RIL_FEATURES_NETWORK_COUNT; i++) |
771 | { | 772 | // { |
772 | // state[i] = solver->global_state_networks[i]; | 773 | // state[i] = solver->global_state_networks[i]; |
773 | } | 774 | // } |
775 | |||
774 | net = agent->address_inuse->solver_information; | 776 | net = agent->address_inuse->solver_information; |
775 | 777 | ||
776 | state[0] = (double) net->bw_in_assigned / 1024; //(double) net->bw_in_available; | 778 | state[0] = 1; |
777 | if (net->bw_in_assigned > net->bw_in_available) | 779 | state[1] = (double) net->bw_in_assigned / (double) GNUNET_ATS_MaxBandwidth; |
778 | { | 780 | state[2] = GNUNET_MIN((double) (net->bw_in_available - net->bw_in_assigned), 0) / (double) GNUNET_ATS_MaxBandwidth; |
779 | state[1] = 1;// net->bw_in_available; | 781 | |
780 | } | ||
781 | else | ||
782 | { | ||
783 | state[1] = 0; | ||
784 | } | ||
785 | // LOG(GNUNET_ERROR_TYPE_INFO, "get_state() state[0] = %f\n", state[0]); | 782 | // LOG(GNUNET_ERROR_TYPE_INFO, "get_state() state[0] = %f\n", state[0]); |
786 | // LOG(GNUNET_ERROR_TYPE_INFO, "get_state() state[1] = %f\n", state[1]); | 783 | // LOG(GNUNET_ERROR_TYPE_INFO, "get_state() state[1] = %f\n", state[1]); |
787 | // | 784 | // |
@@ -798,8 +795,8 @@ envi_get_state (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) | |||
798 | // } | 795 | // } |
799 | 796 | ||
800 | //get address specific features | 797 | //get address specific features |
801 | for (cur_address = agent->addresses_head; NULL != cur_address; cur_address = cur_address->next) | 798 | // for (cur_address = agent->addresses_head; NULL != cur_address; cur_address = cur_address->next) |
802 | { | 799 | // { |
803 | // //when changing the number of address specific state features, change RIL_FEATURES_ADDRESS_COUNT macro | 800 | // //when changing the number of address specific state features, change RIL_FEATURES_ADDRESS_COUNT macro |
804 | // state[i++] = cur_address->address_naked->active; | 801 | // state[i++] = cur_address->address_naked->active; |
805 | // state[i++] = cur_address->address_naked->active ? agent->bw_in : 0; | 802 | // state[i++] = cur_address->address_naked->active ? agent->bw_in : 0; |
@@ -810,7 +807,7 @@ envi_get_state (struct GAS_RIL_Handle *solver, struct RIL_Peer_Agent *agent) | |||
810 | // { | 807 | // { |
811 | // state[i++] = properties[k]; | 808 | // state[i++] = properties[k]; |
812 | // } | 809 | // } |
813 | } | 810 | // } |
814 | 811 | ||
815 | return state; | 812 | return state; |
816 | } | 813 | } |
@@ -1634,7 +1631,7 @@ agent_init (void *s, const struct GNUNET_PeerIdentity *peer) | |||
1634 | agent->bw_out = MIN_BW; | 1631 | agent->bw_out = MIN_BW; |
1635 | agent->suggestion_issue = GNUNET_NO; | 1632 | agent->suggestion_issue = GNUNET_NO; |
1636 | agent->n = RIL_ACTION_TYPE_NUM; | 1633 | agent->n = RIL_ACTION_TYPE_NUM; |
1637 | agent->m = (RIL_FEATURES_NETWORK_COUNT);// + GNUNET_ATS_PreferenceCount; | 1634 | agent->m = RIL_FEATURES_INIT_COUNT; |
1638 | agent->W = (double **) GNUNET_malloc (sizeof (double *) * agent->n); | 1635 | agent->W = (double **) GNUNET_malloc (sizeof (double *) * agent->n); |
1639 | for (i = 0; i < agent->n; i++) | 1636 | for (i = 0; i < agent->n; i++) |
1640 | { | 1637 | { |