aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-02-21 10:51:49 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-02-21 10:51:49 +0000
commiteb9d17abd52471e8cd3dcb45bbd4b93231da23c3 (patch)
tree23c508f04b9b50419e0bce9f1c1de8a6e4ebd25c
parent9685d476103ec9491e7c562362d464bff69bbc9a (diff)
downloadgnunet-eb9d17abd52471e8cd3dcb45bbd4b93231da23c3.tar.gz
gnunet-eb9d17abd52471e8cd3dcb45bbd4b93231da23c3.zip
clean up of MLP_Handle
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c479
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.h189
-rw-r--r--src/ats/perf_ats_mlp.c12
-rw-r--r--src/ats/test_ats_mlp.c43
-rw-r--r--src/ats/test_ats_mlp_averaging.c12
5 files changed, 422 insertions, 313 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c
index 711f48ce6..607f9372c 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.c
+++ b/src/ats/gnunet-service-ats_addresses_mlp.c
@@ -136,7 +136,7 @@
136#define LOG(kind,...) GNUNET_log_from (kind, "ats-mlp",__VA_ARGS__) 136#define LOG(kind,...) GNUNET_log_from (kind, "ats-mlp",__VA_ARGS__)
137 137
138#define WRITE_MLP GNUNET_NO 138#define WRITE_MLP GNUNET_NO
139#define DEBUG_ATS GNUNET_NO 139#define DEBUG_MLP_PROBLEM_CREATION GNUNET_YES
140#define VERBOSE_GLPK GNUNET_NO 140#define VERBOSE_GLPK GNUNET_NO
141 141
142/** 142/**
@@ -166,31 +166,31 @@ mlp_delete_problem (struct GAS_MLP_Handle *mlp)
166{ 166{
167 if (mlp != NULL) 167 if (mlp != NULL)
168 { 168 {
169 if (mlp->prob != NULL) 169 if (mlp->p.prob != NULL)
170 glp_delete_prob(mlp->prob); 170 glp_delete_prob(mlp->p.prob);
171 171
172 /* delete row index */ 172 /* delete row index */
173 if (mlp->ia != NULL) 173 if (mlp->p.ia != NULL)
174 { 174 {
175 GNUNET_free (mlp->ia); 175 GNUNET_free (mlp->p.ia);
176 mlp->ia = NULL; 176 mlp->p.ia = NULL;
177 } 177 }
178 178
179 /* delete column index */ 179 /* delete column index */
180 if (mlp->ja != NULL) 180 if (mlp->p.ja != NULL)
181 { 181 {
182 GNUNET_free (mlp->ja); 182 GNUNET_free (mlp->p.ja);
183 mlp->ja = NULL; 183 mlp->p.ja = NULL;
184 } 184 }
185 185
186 /* delete coefficients */ 186 /* delete coefficients */
187 if (mlp->ar != NULL) 187 if (mlp->p.ar != NULL)
188 { 188 {
189 GNUNET_free (mlp->ar); 189 GNUNET_free (mlp->p.ar);
190 mlp->ar = NULL; 190 mlp->p.ar = NULL;
191 } 191 }
192 mlp->ci = 0; 192 mlp->p.ci = 0;
193 mlp->prob = NULL; 193 mlp->p.prob = NULL;
194 } 194 }
195} 195}
196 196
@@ -549,7 +549,7 @@ mlp_scheduler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
549 549
550 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduled problem solving\n"); 550 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduled problem solving\n");
551 551
552 if (mlp->addr_in_problem != 0) 552 if (mlp->addresses_in_problem != 0)
553 GAS_mlp_solve_problem(mlp, &ctx); 553 GAS_mlp_solve_problem(mlp, &ctx);
554} 554}
555 555
@@ -733,6 +733,7 @@ static int
733create_constraint_it (void *cls, const struct GNUNET_HashCode * key, void *value) 733create_constraint_it (void *cls, const struct GNUNET_HashCode * key, void *value)
734{ 734{
735 struct GAS_MLP_Handle *mlp = cls; 735 struct GAS_MLP_Handle *mlp = cls;
736 struct MLP_Problem *p = &mlp->p;
736 struct ATS_Address *address = value; 737 struct ATS_Address *address = value;
737 struct MLP_information *mlpi; 738 struct MLP_information *mlpi;
738 unsigned int row_index; 739 unsigned int row_index;
@@ -744,62 +745,62 @@ create_constraint_it (void *cls, const struct GNUNET_HashCode * key, void *value
744 /* c 1) bandwidth capping 745 /* c 1) bandwidth capping
745 * b_t + (-M) * n_t <= 0 746 * b_t + (-M) * n_t <= 0
746 */ 747 */
747 row_index = glp_add_rows (mlp->prob, 1); 748 row_index = glp_add_rows (p->prob, 1);
748 mlpi->r_c1 = row_index; 749 mlpi->r_c1 = row_index;
749 /* set row name */ 750 /* set row name */
750 GNUNET_asprintf(&name, "c1_%s_%s", GNUNET_i2s(&address->peer), address->plugin); 751 GNUNET_asprintf(&name, "c1_%s_%s", GNUNET_i2s(&address->peer), address->plugin);
751 glp_set_row_name (mlp->prob, row_index, name); 752 glp_set_row_name (p->prob, row_index, name);
752 GNUNET_free (name); 753 GNUNET_free (name);
753 /* set row bounds: <= 0 */ 754 /* set row bounds: <= 0 */
754 glp_set_row_bnds (mlp->prob, row_index, GLP_UP, 0.0, 0.0); 755 glp_set_row_bnds (p->prob, row_index, GLP_UP, 0.0, 0.0);
755 mlp->ia[mlp->ci] = row_index; 756 p->ia[p->ci] = row_index;
756 mlp->ja[mlp->ci] = mlpi->c_b; 757 p->ja[p->ci] = mlpi->c_b;
757 mlp->ar[mlp->ci] = 1; 758 p->ar[p->ci] = 1;
758 mlp->ci++; 759 p->ci++;
759 760
760 mlp->ia[mlp->ci] = row_index; 761 p->ia[p->ci] = row_index;
761 mlp->ja[mlp->ci] = mlpi->c_n; 762 p->ja[p->ci] = mlpi->c_n;
762 mlp->ar[mlp->ci] = -mlp->BIG_M; 763 p->ar[p->ci] = -mlp->BIG_M;
763 mlp->ci++; 764 p->ci++;
764 765
765 /* c 3) minimum bandwidth 766 /* c 3) minimum bandwidth
766 * b_t + (-n_t * b_min) >= 0 767 * b_t + (-n_t * b_min) >= 0
767 */ 768 */
768 769
769 row_index = glp_add_rows (mlp->prob, 1); 770 row_index = glp_add_rows (p->prob, 1);
770 /* set row name */ 771 /* set row name */
771 GNUNET_asprintf(&name, "c3_%s_%s", GNUNET_i2s(&address->peer), address->plugin); 772 GNUNET_asprintf(&name, "c3_%s_%s", GNUNET_i2s(&address->peer), address->plugin);
772 glp_set_row_name (mlp->prob, row_index, name); 773 glp_set_row_name (p->prob, row_index, name);
773 GNUNET_free (name); 774 GNUNET_free (name);
774 mlpi->r_c3 = row_index; 775 mlpi->r_c3 = row_index;
775 /* set row bounds: >= 0 */ 776 /* set row bounds: >= 0 */
776 glp_set_row_bnds (mlp->prob, row_index, GLP_LO, 0.0, 0.0); 777 glp_set_row_bnds (p->prob, row_index, GLP_LO, 0.0, 0.0);
777 778
778 mlp->ia[mlp->ci] = row_index; 779 p->ia[p->ci] = row_index;
779 mlp->ja[mlp->ci] = mlpi->c_b; 780 p->ja[p->ci] = mlpi->c_b;
780 mlp->ar[mlp->ci] = 1; 781 p->ar[p->ci] = 1;
781 mlp->ci++; 782 p->ci++;
782 783
783 mlp->ia[mlp->ci] = row_index; 784 p->ia[p->ci] = row_index;
784 mlp->ja[mlp->ci] = mlpi->c_n; 785 p->ja[p->ci] = mlpi->c_n;
785 mlp->ar[mlp->ci] = - (double) mlp->b_min; 786 p->ar[p->ci] = - (double) mlp->pv.b_min;
786 mlp->ci++; 787 p->ci++;
787 788
788 /* c 4) minimum connections 789 /* c 4) minimum connections
789 * (1)*n_1 + ... + (1)*n_m >= n_min 790 * (1)*n_1 + ... + (1)*n_m >= n_min
790 */ 791 */
791 mlp->ia[mlp->ci] = mlp->r_c4; 792 p->ia[p->ci] = p->r_c4;
792 mlp->ja[mlp->ci] = mlpi->c_n; 793 p->ja[p->ci] = mlpi->c_n;
793 mlp->ar[mlp->ci] = 1; 794 p->ar[p->ci] = 1;
794 mlp->ci++; 795 p->ci++;
795 796
796 /* c 6) maximize diversity 797 /* c 6) maximize diversity
797 * (1)*n_1 + ... + (1)*n_m - d == 0 798 * (1)*n_1 + ... + (1)*n_m - d == 0
798 */ 799 */
799 mlp->ia[mlp->ci] = mlp->r_c6; 800 p->ia[p->ci] = p->r_c6;
800 mlp->ja[mlp->ci] = mlpi->c_n; 801 p->ja[p->ci] = mlpi->c_n;
801 mlp->ar[mlp->ci] = 1; 802 p->ar[p->ci] = 1;
802 mlp->ci++; 803 p->ci++;
803 804
804 /* c 10) obey network specific quotas 805 /* c 10) obey network specific quotas
805 * (1)*b_1 + ... + (1)*b_m <= quota_n 806 * (1)*b_1 + ... + (1)*b_m <= quota_n
@@ -809,19 +810,19 @@ create_constraint_it (void *cls, const struct GNUNET_HashCode * key, void *value
809 int c; 810 int c;
810 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) 811 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
811 { 812 {
812 if (mlp->quota_index[c] == address->atsp_network_type) 813 if (mlp->pv.quota_index[c] == address->atsp_network_type)
813 { 814 {
814 cur_row = mlp->r_quota[c]; 815 cur_row = p->r_quota[c];
815 break; 816 break;
816 } 817 }
817 } 818 }
818 819
819 if (cur_row != 0) 820 if (cur_row != 0)
820 { 821 {
821 mlp->ia[mlp->ci] = cur_row; 822 p->ia[p->ci] = cur_row;
822 mlp->ja[mlp->ci] = mlpi->c_b; 823 p->ja[p->ci] = mlpi->c_b;
823 mlp->ar[mlp->ci] = 1; 824 p->ar[p->ci] = 1;
824 mlp->ci++; 825 p->ci++;
825 } 826 }
826 else 827 else
827 { 828 {
@@ -844,11 +845,12 @@ static void
844mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHashMap * addresses) 845mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHashMap * addresses)
845{ 846{
846 unsigned int n_addresses; 847 unsigned int n_addresses;
848 struct MLP_Problem *p = &mlp->p;
847 int c; 849 int c;
848 char *name; 850 char *name;
849 851
850 /* Problem matrix*/ 852 /* Problem matrix*/
851 n_addresses = GNUNET_CONTAINER_multihashmap_size(addresses); 853 n_addresses = p->addresses_in_problem;
852 854
853 /* Required indices in the constrain matrix 855 /* Required indices in the constrain matrix
854 * 856 *
@@ -902,21 +904,21 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
902 * */ 904 * */
903 905
904 /* last +1 caused by glpk index starting with one: [1..pi]*/ 906 /* last +1 caused by glpk index starting with one: [1..pi]*/
905 int pi = ((7 * n_addresses) + (5 * n_addresses + mlp->m_q + mlp->c_p + 2) + 1); 907 int pi = ((7 * n_addresses) + (5 * n_addresses + mlp->pv.m_q + mlp->c_p + 2) + 1);
906 mlp->cm_size = pi; 908 mlp->cm_size = pi;
907 mlp->ci = 1; 909 p->ci = 1;
908 910
909 /* row index */ 911 /* row index */
910 int *ia = GNUNET_malloc (pi * sizeof (int)); 912 int *ia = GNUNET_malloc (pi * sizeof (int));
911 mlp->ia = ia; 913 p->ia = ia;
912 914
913 /* column index */ 915 /* column index */
914 int *ja = GNUNET_malloc (pi * sizeof (int)); 916 int *ja = GNUNET_malloc (pi * sizeof (int));
915 mlp->ja = ja; 917 p->ja = ja;
916 918
917 /* coefficient */ 919 /* coefficient */
918 double *ar= GNUNET_malloc (pi * sizeof (double)); 920 double *ar= GNUNET_malloc (pi * sizeof (double));
919 mlp->ar = ar; 921 p->ar = ar;
920 922
921 /* Adding constraint rows 923 /* Adding constraint rows
922 * This constraints are kind of "for all addresses" 924 * This constraints are kind of "for all addresses"
@@ -930,39 +932,60 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
930 */ 932 */
931 933
932 /* Row for c4) minimum connection */ 934 /* Row for c4) minimum connection */
933 int min = mlp->n_min; 935 name = "c4";
936 int min = mlp->pv.n_min;
934 /* Number of minimum connections is min(|Peers|, n_min) */ 937 /* Number of minimum connections is min(|Peers|, n_min) */
935 if (mlp->n_min > mlp->c_p) 938 if (mlp->pv.n_min > mlp->c_p)
936 min = mlp->c_p; 939 min = mlp->c_p;
937 940 p->r_c4 = glp_add_rows (p->prob, 1);
938 mlp->r_c4 = glp_add_rows (mlp->prob, 1); 941 glp_set_row_name (p->prob, p->r_c4, name);
939 glp_set_row_name (mlp->prob, mlp->r_c4, "c4"); 942 glp_set_row_bnds (p->prob, p->r_c4, GLP_LO, min, min);
940 glp_set_row_bnds (mlp->prob, mlp->r_c4, GLP_LO, min, min); 943#if DEBUG_MLP_PROBLEM_CREATION
944 LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added row [%u] `%s': %s %u\n",
945 p->r_c4, name,
946 ">=", min);
947#endif
941 948
942 /* Add row for c6) */ 949 /* Add row for c6) */
943 950 name = "c6";
944 mlp->r_c6 = glp_add_rows (mlp->prob, 1); 951 p->r_c6 = glp_add_rows (p->prob, 1);
945 /* Set type type to fix */ 952 /* Set type type to fix */
946 glp_set_row_bnds (mlp->prob, mlp->r_c6, GLP_FX, 0.0, 0.0); 953 glp_set_row_name (p->prob, p->r_c6, name);
954 glp_set_row_bnds (p->prob, p->r_c6, GLP_FX, 0.0, 0.0);
955#if DEBUG_MLP_PROBLEM_CREATION
956 LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added row [%u] `%s': %s %u\n",
957 p->r_c6, name,
958 "==", 0);
959#endif
947 /* Setting -D */ 960 /* Setting -D */
948 ia[mlp->ci] = mlp->r_c6 ; 961 ia[p->ci] = p->r_c6 ;
949 ja[mlp->ci] = mlp->c_d; 962 ja[p->ci] = p->c_d;
950 ar[mlp->ci] = -1; 963 ar[p->ci] = -1;
951 mlp->ci++; 964 p->ci++;
965#if DEBUG_MLP_PROBLEM_CREATION
966 LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Set value [%u,%u] == %.2f\n",
967 ia[p->ci], ja[p->ci], ar[p->ci]);
968#endif
969
952 970
953 /* Add rows for c 10) */ 971 /* Add rows for c 10) */
954 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) 972 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
955 { 973 {
956 mlp->r_quota[c] = glp_add_rows (mlp->prob, 1); 974 p->r_quota[c] = glp_add_rows (p->prob, 1);
957 char * text; 975 char * text;
958 GNUNET_asprintf(&text, "quota_ats_%i", mlp->quota_index[c]); 976 GNUNET_asprintf(&text, "quota_ats_%i", mlp->pv.quota_index[c]);
959 glp_set_row_name (mlp->prob, mlp->r_quota[c], text); 977 glp_set_row_name (p->prob, p->r_quota[c], text);
960 GNUNET_free (text);
961 /* Set bounds to 0 <= x <= quota_out */ 978 /* Set bounds to 0 <= x <= quota_out */
962 glp_set_row_bnds (mlp->prob, mlp->r_quota[c], GLP_UP, 0.0, mlp->quota_out[c]); 979 glp_set_row_bnds (p->prob, p->r_quota[c], GLP_UP, 0.0, mlp->pv.quota_out[c]);
980#if DEBUG_MLP_PROBLEM_CREATION
981 LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added row [%u] `%s': %s %u\n",
982 p->r_quota[c], name,
983 "<=", mlp->pv.quota_out[c]);
984#endif
985 GNUNET_free (text);
963 } 986 }
964 987
965 GNUNET_CONTAINER_multihashmap_iterate (addresses, create_constraint_it, mlp); 988 //GNUNET_CONTAINER_multihashmap_iterate (addresses, create_constraint_it, mlp);
966 989
967 /* Adding constraint rows 990 /* Adding constraint rows
968 * This constraints are kind of "for all peers" 991 * This constraints are kind of "for all peers"
@@ -979,16 +1002,26 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
979 * */ 1002 * */
980 1003
981 /* Adding rows for c 8) */ 1004 /* Adding rows for c 8) */
982 mlp->r_c8 = glp_add_rows (mlp->prob, mlp->c_p); 1005 p->r_c8 = glp_add_rows (p->prob, mlp->c_p);
983 glp_set_row_name (mlp->prob, mlp->r_c8, "c8"); 1006 name = "c8";
1007 glp_set_row_name (p->prob, p->r_c8, "c8");
984 /* Set row bound == 0 */ 1008 /* Set row bound == 0 */
985 glp_set_row_bnds (mlp->prob, mlp->r_c8, GLP_FX, 0.0, 0.0); 1009 glp_set_row_bnds (p->prob, p->r_c8, GLP_FX, 0.0, 0.0);
986 /* -u */ 1010#if DEBUG_MLP_PROBLEM_CREATION
1011 LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added row [%u] `%s': %s %u\n",
1012 p->r_c8, name,
1013 "==", 0);
1014#endif
987 1015
988 ia[mlp->ci] = mlp->r_c8; 1016 /* -u */
989 ja[mlp->ci] = mlp->c_u; 1017 ia[p->ci] = p->r_c8;
990 ar[mlp->ci] = -1; 1018 ja[p->ci] = p->c_u;
991 mlp->ci++; 1019 ar[p->ci] = -1;
1020 p->ci++;
1021#if DEBUG_MLP_PROBLEM_CREATION
1022 LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Set value [%u,%u] == %.2f\n",
1023 ia[p->ci], ja[p->ci], ar[p->ci]);
1024#endif
992 1025
993 struct ATS_Peer * peer = mlp->peer_head; 1026 struct ATS_Peer * peer = mlp->peer_head;
994 /* For all peers */ 1027 /* For all peers */
@@ -998,26 +1031,26 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
998 struct MLP_information *mlpi = NULL; 1031 struct MLP_information *mlpi = NULL;
999 1032
1000 /* Adding rows for c 2) */ 1033 /* Adding rows for c 2) */
1001 peer->r_c2 = glp_add_rows (mlp->prob, 1); 1034 peer->r_c2 = glp_add_rows (p->prob, 1);
1002 GNUNET_asprintf(&name, "c2_%s", GNUNET_i2s(&peer->id)); 1035 GNUNET_asprintf(&name, "c2_%s", GNUNET_i2s(&peer->id));
1003 glp_set_row_name (mlp->prob, peer->r_c2, name); 1036 glp_set_row_name (p->prob, peer->r_c2, name);
1004 GNUNET_free (name); 1037 GNUNET_free (name);
1005 /* Set row bound == 1 */ 1038 /* Set row bound == 1 */
1006 glp_set_row_bnds (mlp->prob, peer->r_c2, GLP_FX, 1.0, 1.0); 1039 glp_set_row_bnds (p->prob, peer->r_c2, GLP_FX, 1.0, 1.0);
1007 1040
1008 /* Adding rows for c 9) */ 1041 /* Adding rows for c 9) */
1009 peer->r_c9 = glp_add_rows (mlp->prob, 1); 1042 peer->r_c9 = glp_add_rows (p->prob, 1);
1010 GNUNET_asprintf(&name, "c9_%s", GNUNET_i2s(&peer->id)); 1043 GNUNET_asprintf(&name, "c9_%s", GNUNET_i2s(&peer->id));
1011 glp_set_row_name (mlp->prob, peer->r_c9, name); 1044 glp_set_row_name (p->prob, peer->r_c9, name);
1012 GNUNET_free (name); 1045 GNUNET_free (name);
1013 /* Set row bound == 0 */ 1046 /* Set row bound == 0 */
1014 glp_set_row_bnds (mlp->prob, peer->r_c9, GLP_LO, 0.0, 0.0); 1047 glp_set_row_bnds (p->prob, peer->r_c9, GLP_LO, 0.0, 0.0);
1015 1048
1016 /* Set -r */ 1049 /* Set -r */
1017 ia[mlp->ci] = peer->r_c9; 1050 ia[p->ci] = peer->r_c9;
1018 ja[mlp->ci] = mlp->c_r; 1051 ja[p->ci] = p->c_r;
1019 ar[mlp->ci] = -peer->f; 1052 ar[p->ci] = -peer->f;
1020 mlp->ci++; 1053 p->ci++;
1021 1054
1022 /* For all addresses of this peer */ 1055 /* For all addresses of this peer */
1023 while (addr != NULL) 1056 while (addr != NULL)
@@ -1025,23 +1058,23 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
1025 mlpi = (struct MLP_information *) addr->solver_information; 1058 mlpi = (struct MLP_information *) addr->solver_information;
1026 1059
1027 /* coefficient for c 2) */ 1060 /* coefficient for c 2) */
1028 ia[mlp->ci] = peer->r_c2; 1061 ia[p->ci] = peer->r_c2;
1029 ja[mlp->ci] = mlpi->c_n; 1062 ja[p->ci] = mlpi->c_n;
1030 ar[mlp->ci] = 1; 1063 ar[p->ci] = 1;
1031 mlp->ci++; 1064 p->ci++;
1032 1065
1033 /* coefficient for c 8) */ 1066 /* coefficient for c 8) */
1034 ia[mlp->ci] = mlp->r_c8; 1067 ia[p->ci] = p->r_c8;
1035 ja[mlp->ci] = mlpi->c_b; 1068 ja[p->ci] = mlpi->c_b;
1036 ar[mlp->ci] = peer->f; 1069 ar[p->ci] = peer->f;
1037 mlp->ci++; 1070 p->ci++;
1038 1071
1039#if ENABLE_C9 1072#if ENABLE_C9
1040 /* coefficient for c 9) */ 1073 /* coefficient for c 9) */
1041 ia[mlp->ci] = peer->r_c9; 1074 ia[p->ci] = peer->r_c9;
1042 ja[mlp->ci] = mlpi->c_b; 1075 ja[p->ci] = mlpi->c_b;
1043 ar[mlp->ci] = 1; 1076 ar[p->ci] = 1;
1044 mlp->ci++; 1077 p->ci++;
1045#endif 1078#endif
1046 1079
1047 addr = addr->next; 1080 addr = addr->next;
@@ -1050,7 +1083,7 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
1050 } 1083 }
1051 1084
1052 /* c 7) For all quality metrics */ 1085 /* c 7) For all quality metrics */
1053 for (c = 0; c < mlp->m_q; c++) 1086 for (c = 0; c < mlp->pv.m_q; c++)
1054 { 1087 {
1055 struct ATS_Peer *tp; 1088 struct ATS_Peer *tp;
1056 struct ATS_Address *ta; 1089 struct ATS_Address *ta;
@@ -1058,17 +1091,17 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
1058 double value = 1.0; 1091 double value = 1.0;
1059 1092
1060 /* Adding rows for c 7) */ 1093 /* Adding rows for c 7) */
1061 mlp->r_q[c] = glp_add_rows (mlp->prob, 1); 1094 p->r_q[c] = glp_add_rows (p->prob, 1);
1062 GNUNET_asprintf(&name, "c7_q%i_%s", c, mlp_ats_to_string(mlp->q[c])); 1095 GNUNET_asprintf(&name, "c7_q%i_%s", c, mlp_ats_to_string(mlp->pv.q[c]));
1063 glp_set_row_name (mlp->prob, mlp->r_q[c], name); 1096 glp_set_row_name (p->prob, p->r_q[c], name);
1064 GNUNET_free (name); 1097 GNUNET_free (name);
1065 /* Set row bound == 0 */ 1098 /* Set row bound == 0 */
1066 glp_set_row_bnds (mlp->prob, mlp->r_q[c], GLP_FX, 0.0, 0.0); 1099 glp_set_row_bnds (p->prob, p->r_q[c], GLP_FX, 0.0, 0.0);
1067 1100
1068 ia[mlp->ci] = mlp->r_q[c]; 1101 ia[p->ci] = p->r_q[c];
1069 ja[mlp->ci] = mlp->c_q[c]; 1102 ja[p->ci] = p->c_q[c];
1070 ar[mlp->ci] = -1; 1103 ar[p->ci] = -1;
1071 mlp->ci++; 1104 p->ci++;
1072 1105
1073 for (tp = mlp->peer_head; tp != NULL; tp = tp->next) 1106 for (tp = mlp->peer_head; tp != NULL; tp = tp->next)
1074 for (ta = tp->head; ta != NULL; ta = ta->next) 1107 for (ta = tp->head; ta != NULL; ta = ta->next)
@@ -1076,12 +1109,12 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
1076 mlpi = ta->solver_information; 1109 mlpi = ta->solver_information;
1077 value = mlpi->q_averaged[c]; 1110 value = mlpi->q_averaged[c];
1078 1111
1079 mlpi->r_q[c] = mlp->r_q[c]; 1112 mlpi->r_q[c] = p->r_q[c];
1080 1113
1081 ia[mlp->ci] = mlp->r_q[c]; 1114 ia[p->ci] = p->r_q[c];
1082 ja[mlp->ci] = mlpi->c_b; 1115 ja[p->ci] = mlpi->c_b;
1083 ar[mlp->ci] = tp->f_q[c] * value; 1116 ar[p->ci] = tp->f_q[c] * value;
1084 mlp->ci++; 1117 p->ci++;
1085 } 1118 }
1086 } 1119 }
1087} 1120}
@@ -1100,6 +1133,7 @@ static int
1100mlp_create_address_columns_it (void *cls, const struct GNUNET_HashCode * key, void *value) 1133mlp_create_address_columns_it (void *cls, const struct GNUNET_HashCode * key, void *value)
1101{ 1134{
1102 struct GAS_MLP_Handle *mlp = cls; 1135 struct GAS_MLP_Handle *mlp = cls;
1136 struct MLP_Problem *p = &mlp->p;
1103 struct ATS_Address *address = value; 1137 struct ATS_Address *address = value;
1104 struct MLP_information *mlpi; 1138 struct MLP_information *mlpi;
1105 unsigned int col; 1139 unsigned int col;
@@ -1115,39 +1149,44 @@ mlp_create_address_columns_it (void *cls, const struct GNUNET_HashCode * key, vo
1115 if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(mlp->peers, key)) 1149 if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(mlp->peers, key))
1116 return GNUNET_OK; 1150 return GNUNET_OK;
1117 1151
1118 LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding column for peer %s address %p\n", 1152 p->addresses_in_problem ++;
1119 GNUNET_i2s(&address->peer), address);
1120
1121 mlpi = GNUNET_malloc (sizeof (struct MLP_information)); 1153 mlpi = GNUNET_malloc (sizeof (struct MLP_information));
1122 address->solver_information = mlpi; 1154 address->solver_information = mlpi;
1123 1155
1124 /* Add bandwidth column */ 1156 /* Add bandwidth column */
1125 col = glp_add_cols (mlp->prob, 2); 1157 col = glp_add_cols (p->prob, 2);
1126 mlpi->c_b = col; 1158 mlpi->c_b = col;
1127 mlpi->c_n = col + 1; 1159 mlpi->c_n = col + 1;
1128 1160
1129 1161
1130 GNUNET_asprintf (&name, "b_%s_%s", GNUNET_i2s (&address->peer), address->plugin); 1162 GNUNET_asprintf (&name, "b_%s_%s", GNUNET_i2s (&address->peer), address->plugin);
1131 glp_set_col_name (mlp->prob, mlpi->c_b , name); 1163 glp_set_col_name (p->prob, mlpi->c_b , name);
1132 GNUNET_free (name);
1133 /* Lower bound == 0 */ 1164 /* Lower bound == 0 */
1134 glp_set_col_bnds (mlp->prob, mlpi->c_b , GLP_LO, 0.0, 0.0); 1165 glp_set_col_bnds (p->prob, mlpi->c_b , GLP_LO, 0.0, 0.0);
1135 /* Continuous value*/ 1166 /* Continuous value*/
1136 glp_set_col_kind (mlp->prob, mlpi->c_b , GLP_CV); 1167 glp_set_col_kind (p->prob, mlpi->c_b , GLP_CV);
1137 /* Objective function coefficient == 0 */ 1168 /* Objective function coefficient == 0 */
1138 glp_set_obj_coef (mlp->prob, mlpi->c_b , 0); 1169 glp_set_obj_coef (p->prob, mlpi->c_b , 0);
1139 1170#if DEBUG_MLP_PROBLEM_CREATION
1171 LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%u] `%s': `%s' address %p\n",
1172 mlpi->c_b, name, GNUNET_i2s(&address->peer), address);
1173#endif
1174 GNUNET_free (name);
1140 1175
1141 /* Add usage column */ 1176 /* Add usage column */
1142 GNUNET_asprintf (&name, "n_%s_%s", GNUNET_i2s (&address->peer), address->plugin); 1177 GNUNET_asprintf (&name, "n_%s_%s", GNUNET_i2s (&address->peer), address->plugin);
1143 glp_set_col_name (mlp->prob, mlpi->c_n, name); 1178 glp_set_col_name (p->prob, mlpi->c_n, name);
1144 GNUNET_free (name);
1145 /* Limit value : 0 <= value <= 1 */ 1179 /* Limit value : 0 <= value <= 1 */
1146 glp_set_col_bnds (mlp->prob, mlpi->c_n, GLP_DB, 0.0, 1.0); 1180 glp_set_col_bnds (p->prob, mlpi->c_n, GLP_DB, 0.0, 1.0);
1147 /* Integer value*/ 1181 /* Integer value*/
1148 glp_set_col_kind (mlp->prob, mlpi->c_n, GLP_IV); 1182 glp_set_col_kind (p->prob, mlpi->c_n, GLP_IV);
1149 /* Objective function coefficient == 0 */ 1183 /* Objective function coefficient == 0 */
1150 glp_set_obj_coef (mlp->prob, mlpi->c_n, 0); 1184 glp_set_obj_coef (p->prob, mlpi->c_n, 0);
1185#if DEBUG_MLP_PROBLEM_CREATION
1186 LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%u] `%s': `%s' address %p\n",
1187 mlpi->c_n, name, GNUNET_i2s(&address->peer), address);
1188#endif
1189 GNUNET_free (name);
1151 1190
1152 return GNUNET_OK; 1191 return GNUNET_OK;
1153} 1192}
@@ -1162,77 +1201,97 @@ mlp_create_address_columns_it (void *cls, const struct GNUNET_HashCode * key, vo
1162static int 1201static int
1163mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHashMap * addresses) 1202mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHashMap * addresses)
1164{ 1203{
1165 int res = GNUNET_OK; 1204 struct MLP_Problem *p = &mlp->p;
1205 int res = GNUNET_OK;
1166 int c; 1206 int c;
1167 int cur_col; 1207 int cur_col;
1168 int elements = 0;
1169 char *name; 1208 char *name;
1170 1209
1171 LOG (GNUNET_ERROR_TYPE_DEBUG, "Rebuilding problem for %u peer(s) \n", 1210 LOG (GNUNET_ERROR_TYPE_DEBUG, "Rebuilding problem for %u peer(s) \n",
1172 GNUNET_CONTAINER_multihashmap_size(mlp->peers)); 1211 GNUNET_CONTAINER_multihashmap_size(mlp->peers));
1173 1212
1174 GNUNET_assert (mlp->prob == NULL); 1213 GNUNET_assert (p->prob == NULL);
1175 1214
1176 /* create the glpk problem */ 1215 /* create the glpk problem */
1177 mlp->prob = glp_create_prob (); 1216 p->prob = glp_create_prob ();
1178 GNUNET_assert (NULL != mlp->prob); 1217 p->addresses_in_problem = 0;;
1218 GNUNET_assert (NULL != p->prob);
1179 1219
1180 /* Set a problem name */ 1220 /* Set a problem name */
1181 glp_set_prob_name (mlp->prob, "GNUnet ats bandwidth distribution"); 1221 glp_set_prob_name (p->prob, "GNUnet ats bandwidth distribution");
1182 1222
1183 /* Set optimization direction to maximize */ 1223 /* Set optimization direction to maximize */
1184 glp_set_obj_dir (mlp->prob, GLP_MAX); 1224 glp_set_obj_dir (p->prob, GLP_MAX);
1185 1225
1186 /* Adding invariant columns */ 1226 /* Adding invariant columns */
1187 /* Diversity d column */ 1227 /* Diversity d column */
1188 mlp->c_d = glp_add_cols (mlp->prob, 1); 1228 p->c_d = glp_add_cols (p->prob, 1);
1189 /* Column name */ 1229 /* Column name */
1190 glp_set_col_name (mlp->prob, mlp->c_d, "d"); 1230 glp_set_col_name (p->prob, p->c_d, "d");
1191 /* Column objective function coefficient */ 1231 /* Column objective function coefficient */
1192 glp_set_obj_coef (mlp->prob, mlp->c_d, mlp->co_D); 1232 glp_set_obj_coef (p->prob, p->c_d, mlp->pv.co_D);
1193 /* Column lower bound = 0.0 */ 1233 /* Column lower bound = 0.0 */
1194 glp_set_col_bnds (mlp->prob, mlp->c_d, GLP_LO, 0.0, 0.0); 1234 glp_set_col_bnds (p->prob, p->c_d, GLP_LO, 0.0, 0.0);
1235#if DEBUG_MLP_PROBLEM_CREATION
1236 LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%i] `%s': %.2f \n",
1237 p->c_d, "d", mlp->pv.co_D);
1238#endif
1239
1195 1240
1196 /* Utilization u column */ 1241 /* Utilization u column */
1197 mlp->c_u = glp_add_cols (mlp->prob, 1); 1242 p->c_u = glp_add_cols (p->prob, 1);
1198 /* Column name */ 1243 /* Column name */
1199 glp_set_col_name (mlp->prob, mlp->c_u, "u"); 1244 glp_set_col_name (p->prob, p->c_u, "u");
1200 /* Column objective function coefficient */ 1245 /* Column objective function coefficient */
1201 glp_set_obj_coef (mlp->prob, mlp->c_u, mlp->co_U); 1246 glp_set_obj_coef (p->prob, p->c_u, mlp->pv.co_U);
1202 /* Column lower bound = 0.0 */ 1247 /* Column lower bound = 0.0 */
1203 glp_set_col_bnds (mlp->prob, mlp->c_u, GLP_LO, 0.0, 0.0); 1248 glp_set_col_bnds (p->prob, p->c_u, GLP_LO, 0.0, 0.0);
1249#if DEBUG_MLP_PROBLEM_CREATION
1250 LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%i] `%s': %.2f \n",
1251 p->c_u, "u", mlp->pv.co_U);
1252#endif
1204 1253
1205 /* Relativity r column */ 1254 /* Relativity r column */
1206 mlp->c_r = glp_add_cols (mlp->prob, 1); 1255 p->c_r = glp_add_cols (p->prob, 1);
1207 /* Column name */ 1256 /* Column name */
1208 glp_set_col_name (mlp->prob, mlp->c_r, "r"); 1257 glp_set_col_name (p->prob, p->c_r, "r");
1209 /* Column objective function coefficient */ 1258 /* Column objective function coefficient */
1210 glp_set_obj_coef (mlp->prob, mlp->c_r, mlp->co_R); 1259 glp_set_obj_coef (p->prob, p->c_r, mlp->pv.co_R);
1211 /* Column lower bound = 0.0 */ 1260 /* Column lower bound = 0.0 */
1212 glp_set_col_bnds (mlp->prob, mlp->c_r, GLP_LO, 0.0, 0.0); 1261 glp_set_col_bnds (p->prob, p->c_r, GLP_LO, 0.0, 0.0);
1262#if DEBUG_MLP_PROBLEM_CREATION
1263 LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%i] `%s': %.2f \n",
1264 p->c_r, "r", mlp->pv.co_R);
1265#endif
1213 1266
1214 /* Quality metric columns */ 1267 /* Quality metric columns */
1215 cur_col = glp_add_cols(mlp->prob, mlp->m_q); 1268 cur_col = glp_add_cols(p->prob, mlp->pv.m_q);
1216 for (c = 0; c < mlp->m_q; c++) 1269 for (c = 0; c < mlp->pv.m_q; c++)
1217 { 1270 {
1218 mlp->c_q[c] = cur_col + c; 1271 p->c_q[c] = cur_col + c;
1219 GNUNET_asprintf (&name, "q_%u", mlp->q[c]); 1272 GNUNET_asprintf (&name, "q_%u", mlp->pv.q[c]);
1220 glp_set_col_name (mlp->prob, mlp->c_q[c], name); 1273 glp_set_col_name (p->prob, p->c_q[c], name);
1221 /* Column lower bound = 0.0 */ 1274 /* Column lower bound = 0.0 */
1222 glp_set_col_bnds (mlp->prob, mlp->c_q[c], GLP_LO, 0.0, 0.0); 1275 glp_set_col_bnds (p->prob, p->c_q[c], GLP_LO, 0.0, 0.0);
1223 GNUNET_free (name);
1224 /* Coefficient == Qm */ 1276 /* Coefficient == Qm */
1225 glp_set_obj_coef (mlp->prob, mlp->c_q[c], mlp->co_Q[c]); 1277 glp_set_obj_coef (p->prob, p->c_q[c], mlp->pv.co_Q[c]);
1278#if DEBUG_MLP_PROBLEM_CREATION
1279 LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%i] `%s': %.2f \n",
1280 p->c_q[c], name, mlp->pv.co_Q[c]);
1281#endif
1282 GNUNET_free (name);
1226 } 1283 }
1227 1284
1228 /* Add columns for addresses */ 1285 /* Add columns for addresses */
1229 GNUNET_CONTAINER_multihashmap_iterate (addresses, mlp_create_address_columns_it, mlp); 1286 GNUNET_CONTAINER_multihashmap_iterate (addresses, mlp_create_address_columns_it, mlp);
1287 LOG (GNUNET_ERROR_TYPE_DEBUG, "Problems contains %u addresses, %u addresses skipped \n",
1288 p->addresses_in_problem, GNUNET_CONTAINER_multihashmap_size(addresses)- p->addresses_in_problem);
1230 1289
1231 /* Add constraints */ 1290 /* Add constraints rows */
1232 mlp_add_constraints_all_addresses (mlp, addresses); 1291 mlp_add_constraints_all_addresses (mlp, addresses);
1233 1292
1234 /* Load the matrix */ 1293 /* Load the matrix */
1235 glp_load_matrix(mlp->prob, elements /*(mlp->ci-1)*/, mlp->ia, mlp->ja, mlp->ar); 1294 //glp_load_matrix(mlp->prob, (mlp->ci-1), mlp->ia, mlp->ja, mlp->ar);
1236 1295
1237 return res; 1296 return res;
1238} 1297}
@@ -1517,7 +1576,7 @@ GAS_mlp_address_update (void *solver,
1517 } 1576 }
1518 1577
1519 address->solver_information = mlpi; 1578 address->solver_information = mlpi;
1520 mlp->addr_in_problem ++; 1579 mlp->addresses_in_problem ++;
1521 GNUNET_STATISTICS_update (mlp->stats, "# addresses in MLP", 1, GNUNET_NO); 1580 GNUNET_STATISTICS_update (mlp->stats, "# addresses in MLP", 1, GNUNET_NO);
1522 1581
1523 /* Check for and add peer */ 1582 /* Check for and add peer */
@@ -1633,7 +1692,7 @@ GAS_mlp_address_delete (void *solver,
1633 GNUNET_free (address->solver_information); 1692 GNUNET_free (address->solver_information);
1634 address->solver_information = NULL; 1693 address->solver_information = NULL;
1635 1694
1636 mlp->addr_in_problem --; 1695 mlp->addresses_in_problem --;
1637 GNUNET_STATISTICS_update (mlp->stats, "# addresses in MLP", -1, GNUNET_NO); 1696 GNUNET_STATISTICS_update (mlp->stats, "# addresses in MLP", -1, GNUNET_NO);
1638 } 1697 }
1639 1698
@@ -1912,14 +1971,6 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1912 break; 1971 break;
1913 } 1972 }
1914 1973
1915 /* Create initial MLP problem */
1916 mlp->prob = glp_create_prob();
1917 if (NULL == mlp->prob)
1918 {
1919 LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to create MLP problem!");
1920 GNUNET_free (mlp);
1921 return NULL;
1922 }
1923 1974
1924 mlp->BIG_M = (double) BIG_M_VALUE; 1975 mlp->BIG_M = (double) BIG_M_VALUE;
1925 1976
@@ -1966,9 +2017,9 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1966 for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) 2017 for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
1967 { 2018 {
1968 /* initialize quality coefficients with default value 1.0 */ 2019 /* initialize quality coefficients with default value 1.0 */
1969 mlp->co_Q[c] = DEFAULT_QUALITY; 2020 mlp->pv.co_Q[c] = DEFAULT_QUALITY;
1970 2021
1971 mlp->q[c] = q[c]; 2022 mlp->pv.q[c] = q[c];
1972 if (q[c] == GNUNET_ATS_QUALITY_NET_DELAY) 2023 if (q[c] == GNUNET_ATS_QUALITY_NET_DELAY)
1973 i_delay = c; 2024 i_delay = c;
1974 if (q[c] == GNUNET_ATS_QUALITY_NET_DISTANCE) 2025 if (q[c] == GNUNET_ATS_QUALITY_NET_DISTANCE)
@@ -1979,16 +2030,16 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1979 "MLP_COEFFICIENT_QUALITY_DELAY", 2030 "MLP_COEFFICIENT_QUALITY_DELAY",
1980 &tmp))) 2031 &tmp)))
1981 2032
1982 mlp->co_Q[i_delay] = (double) tmp / 100; 2033 mlp->pv.co_Q[i_delay] = (double) tmp / 100;
1983 else 2034 else
1984 mlp->co_Q[i_delay] = DEFAULT_QUALITY; 2035 mlp->pv.co_Q[i_delay] = DEFAULT_QUALITY;
1985 2036
1986 if ((i_distance != NaN) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", 2037 if ((i_distance != NaN) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
1987 "MLP_COEFFICIENT_QUALITY_DISTANCE", 2038 "MLP_COEFFICIENT_QUALITY_DISTANCE",
1988 &tmp))) 2039 &tmp)))
1989 mlp->co_Q[i_distance] = (double) tmp / 100; 2040 mlp->pv.co_Q[i_distance] = (double) tmp / 100;
1990 else 2041 else
1991 mlp->co_Q[i_distance] = DEFAULT_QUALITY; 2042 mlp->pv.co_Q[i_distance] = DEFAULT_QUALITY;
1992 2043
1993 /* Get minimum bandwidth per used address from configuration */ 2044 /* Get minimum bandwidth per used address from configuration */
1994 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", 2045 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
@@ -2017,62 +2068,62 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
2017 { 2068 {
2018 if (quotas[c] == network[c2]) 2069 if (quotas[c] == network[c2])
2019 { 2070 {
2020 mlp->quota_index[c] = network[c2]; 2071 mlp->pv.quota_index[c] = network[c2];
2021 mlp->quota_out[c] = out_dest[c2]; 2072 mlp->pv.quota_out[c] = out_dest[c2];
2022 mlp->quota_in[c] = in_dest[c2]; 2073 mlp->pv.quota_in[c] = in_dest[c2];
2023 found = GNUNET_YES; 2074 found = GNUNET_YES;
2024 LOG (GNUNET_ERROR_TYPE_DEBUG, "Quota for network `%s' (in/out) %llu/%llu\n", 2075 LOG (GNUNET_ERROR_TYPE_DEBUG, "Quota for network `%s' (in/out) %llu/%llu\n",
2025 GNUNET_ATS_print_network_type(mlp->quota_index[c]), 2076 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2026 mlp->quota_out[c], 2077 mlp->pv.quota_out[c],
2027 mlp->quota_in[c]); 2078 mlp->pv.quota_in[c]);
2028 break; 2079 break;
2029 } 2080 }
2030 } 2081 }
2031 2082
2032 /* Check if defined quota could make problem unsolvable */ 2083 /* Check if defined quota could make problem unsolvable */
2033 if ((n_min * b_min) > mlp->quota_out[c]) 2084 if ((n_min * b_min) > mlp->pv.quota_out[c])
2034 { 2085 {
2035 LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inconsistent outbound quota configuration for network `%s', is %llu must be at least %llu\n"), 2086 LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inconsistent outbound quota configuration for network `%s', is %llu must be at least %llu\n"),
2036 GNUNET_ATS_print_network_type(mlp->quota_index[c]), 2087 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2037 mlp->quota_out[c], 2088 mlp->pv.quota_out[c],
2038 (n_min * b_min)); 2089 (n_min * b_min));
2039 mlp->quota_out[c] = (n_min * b_min); 2090 mlp->pv.quota_out[c] = (n_min * b_min);
2040 } 2091 }
2041 if ((n_min * b_min) > mlp->quota_in[c]) 2092 if ((n_min * b_min) > mlp->pv.quota_in[c])
2042 { 2093 {
2043 LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inconsistent inbound quota configuration for network `%s', is %llu must be at least %llu\n"), 2094 LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inconsistent inbound quota configuration for network `%s', is %llu must be at least %llu\n"),
2044 GNUNET_ATS_print_network_type(mlp->quota_index[c]), 2095 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2045 mlp->quota_in[c], 2096 mlp->pv.quota_in[c],
2046 (n_min * b_min)); 2097 (n_min * b_min));
2047 mlp->quota_in[c] = (n_min * b_min); 2098 mlp->pv.quota_in[c] = (n_min * b_min);
2048 } 2099 }
2049 2100
2050 /* Check if bandwidth is too big to make problem solvable */ 2101 /* Check if bandwidth is too big to make problem solvable */
2051 if (mlp->BIG_M < mlp->quota_out[c]) 2102 if (mlp->BIG_M < mlp->pv.quota_out[c])
2052 { 2103 {
2053 LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting outbound quota configuration for network `%s'from %llu to %.0f\n"), 2104 LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting outbound quota configuration for network `%s'from %llu to %.0f\n"),
2054 GNUNET_ATS_print_network_type(mlp->quota_index[c]), 2105 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2055 mlp->quota_out[c], 2106 mlp->pv.quota_out[c],
2056 mlp->BIG_M); 2107 mlp->BIG_M);
2057 mlp->quota_out[c] = mlp->BIG_M; 2108 mlp->pv.quota_out[c] = mlp->BIG_M;
2058 } 2109 }
2059 if (mlp->BIG_M < mlp->quota_in[c]) 2110 if (mlp->BIG_M < mlp->pv.quota_in[c])
2060 { 2111 {
2061 LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inbound quota configuration for network `%s' from %llu to %.0f\n"), 2112 LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inbound quota configuration for network `%s' from %llu to %.0f\n"),
2062 GNUNET_ATS_print_network_type(mlp->quota_index[c]), 2113 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2063 mlp->quota_in[c], 2114 mlp->pv.quota_in[c],
2064 mlp->BIG_M); 2115 mlp->BIG_M);
2065 mlp->quota_in[c] = mlp->BIG_M; 2116 mlp->pv.quota_in[c] = mlp->BIG_M;
2066 } 2117 }
2067 2118
2068 if (GNUNET_NO == found) 2119 if (GNUNET_NO == found)
2069 { 2120 {
2070 mlp->quota_in[c] = ntohl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); 2121 mlp->pv.quota_in[c] = ntohl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
2071 mlp->quota_out[c] = ntohl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); 2122 mlp->pv.quota_out[c] = ntohl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
2072 LOG (GNUNET_ERROR_TYPE_INFO, _("Using default quota configuration for network `%s' (in/out) %llu/%llu\n"), 2123 LOG (GNUNET_ERROR_TYPE_INFO, _("Using default quota configuration for network `%s' (in/out) %llu/%llu\n"),
2073 GNUNET_ATS_print_network_type(mlp->quota_index[c]), 2124 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2074 mlp->quota_in[c], 2125 mlp->pv.quota_in[c],
2075 mlp->quota_out[c]); 2126 mlp->pv.quota_out[c]);
2076 } 2127 }
2077 } 2128 }
2078 2129
@@ -2088,12 +2139,14 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
2088 mlp->stats = (struct GNUNET_STATISTICS_Handle *) stats; 2139 mlp->stats = (struct GNUNET_STATISTICS_Handle *) stats;
2089 mlp->bw_changed_cb = bw_changed_cb; 2140 mlp->bw_changed_cb = bw_changed_cb;
2090 mlp->bw_changed_cb_cls = bw_changed_cb_cls; 2141 mlp->bw_changed_cb_cls = bw_changed_cb_cls;
2091 mlp->co_D = D; 2142 /* Setting MLP Input variables */
2092 mlp->co_R = R; 2143 mlp->pv.co_D = D;
2093 mlp->co_U = U; 2144 mlp->pv.co_R = R;
2094 mlp->b_min = b_min; 2145 mlp->pv.co_U = U;
2095 mlp->n_min = n_min; 2146 mlp->pv.b_min = b_min;
2096 mlp->m_q = GNUNET_ATS_QualityPropertiesCount; 2147 mlp->pv.n_min = n_min;
2148 mlp->pv.m_q = GNUNET_ATS_QualityPropertiesCount;
2149
2097 mlp->semaphore = GNUNET_NO; 2150 mlp->semaphore = GNUNET_NO;
2098 mlp->max_iterations = max_iterations; 2151 mlp->max_iterations = max_iterations;
2099 mlp->max_exec_duration = max_duration; 2152 mlp->max_exec_duration = max_duration;
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h
index c442bd905..bffdd08c9 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.h
+++ b/src/ats/gnunet-service-ats_addresses_mlp.h
@@ -80,6 +80,109 @@ struct GAS_MLP_SolutionContext
80 struct GNUNET_TIME_Relative mlp_duration; 80 struct GNUNET_TIME_Relative mlp_duration;
81}; 81};
82 82
83
84
85struct MLP_Problem
86{
87 /**
88 * GLPK (MLP) problem object
89 */
90#if HAVE_LIBGLPK
91 glp_prob *prob;
92#else
93 void *prob;
94#endif
95 unsigned int addresses_in_problem;
96
97 /* Row index constraint 2: */
98 unsigned int r_c2;
99 /* Row index constraint 4: minimum connections */
100 unsigned int r_c4;
101 /* Row index constraint 6: maximize diversity */
102 unsigned int r_c6;
103 /* Row index constraint 8: utilization*/
104 unsigned int r_c8;
105 /* Row index constraint 9: relativity*/
106 unsigned int r_c9;
107 /* Row indices quality metrics */
108 int r_q[GNUNET_ATS_QualityPropertiesCount];
109 /* Row indices ATS network quotas */
110 int r_quota[GNUNET_ATS_NetworkTypeCount];
111
112 /* Column index Diversity (D) column */
113 int c_d;
114 /* Column index Utilization (U) column */
115 int c_u;
116 /* Column index Proportionality (R) column */
117 int c_r;
118 /* Column index quality metrics */
119 int c_q[GNUNET_ATS_QualityPropertiesCount];
120 /* column index ressource costs */
121 int c_rc[GNUNET_ATS_QualityPropertiesCount];
122 /* Column indices ATS network quotas */
123 int c_quota[GNUNET_ATS_NetworkTypeCount];
124
125 /* Problem matrix */
126 /* Current index */
127 unsigned int ci;
128 /* Row index array */
129 int *ia;
130 /* Column index array */
131 int *ja;
132 /* Column index value */
133 double *ar;
134
135
136
137};
138
139struct MLP_Variables
140{
141
142 /* ATS Quality metrics
143 *
144 * Array with GNUNET_ATS_QualityPropertiesCount elements
145 * contains mapping to GNUNET_ATS_Property*/
146 int q[GNUNET_ATS_QualityPropertiesCount];
147
148 /* Number of quality metrics */
149 int m_q;
150
151 /* Number of quality metrics */
152 int m_rc;
153
154 /* Quality metric coefficients*/
155 double co_Q[GNUNET_ATS_QualityPropertiesCount];
156
157 /* Ressource costs coefficients*/
158 double co_RC[GNUNET_ATS_QualityPropertiesCount];
159
160 /* Diversity coefficient */
161 double co_D;
162
163 /* Utility coefficient */
164 double co_U;
165
166 /* Relativity coefficient */
167 double co_R;
168
169 /* Minimum bandwidth assigned to an address */
170 unsigned int b_min;
171
172 /* Minimum number of addresses with bandwidth assigned */
173 unsigned int n_min;
174
175 /* Quotas */
176 /* Array mapping array index to ATS network */
177 int quota_index [GNUNET_ATS_NetworkTypeCount];
178 /* Outbound quotas */
179 unsigned long long quota_out[GNUNET_ATS_NetworkTypeCount];
180 /* Inbound quotas */
181 unsigned long long quota_in[GNUNET_ATS_NetworkTypeCount];
182
183};
184
185
83/** 186/**
84 * MLP Handle 187 * MLP Handle
85 */ 188 */
@@ -100,17 +203,14 @@ struct GAS_MLP_Handle
100 */ 203 */
101 void *bw_changed_cb_cls; 204 void *bw_changed_cb_cls;
102 205
103 /** 206 struct MLP_Problem p;
104 * GLPK (MLP) problem object 207
105 */ 208 struct MLP_Variables pv;
106#if HAVE_LIBGLPK
107 glp_prob *prob;
108#else
109 void *prob;
110#endif
111 209
112 double BIG_M; 210 double BIG_M;
113 211
212
213
114 /** 214 /**
115 * GLPK LP control parameter 215 * GLPK LP control parameter
116 */ 216 */
@@ -218,7 +318,7 @@ struct GAS_MLP_Handle
218 */ 318 */
219 uint64_t mlp_total_duration; 319 uint64_t mlp_total_duration;
220 320
221 unsigned int addr_in_problem; 321
222 322
223 /* Information about the problem */ 323 /* Information about the problem */
224 324
@@ -228,64 +328,9 @@ struct GAS_MLP_Handle
228 /* Number of peers */ 328 /* Number of peers */
229 unsigned int c_p; 329 unsigned int c_p;
230 330
231 /* current problem matrix */ 331
232 /* row index array */
233 int *ia;
234 /* column index array */
235 int *ja;
236 /* column index array */
237 double *ar;
238 /* current size of the constraint matrix |indices| */ 332 /* current size of the constraint matrix |indices| */
239 unsigned int cm_size; 333 unsigned int cm_size;
240 unsigned int ci;
241
242 /* Row index constraint 2: */
243 unsigned int r_c2;
244 /* Row index constraint 4: minimum connections */
245 unsigned int r_c4;
246 /* Row index constraint 6: maximize diversity */
247 unsigned int r_c6;
248 /* Row index constraint 8: utilization*/
249 unsigned int r_c8;
250 /* Row index constraint 9: relativity*/
251 unsigned int r_c9;
252
253 /* column index Diversity (D) column */
254 int c_d;
255 double co_D;
256
257 /* column index Utilization (U) column */
258 int c_u;
259 double co_U;
260
261 /* column index Proportionality (R) column */
262 int c_r;
263 double co_R;
264
265 /* ATS Quality metrics
266 *
267 * array with GNUNET_ATS_QualityPropertiesCount elements
268 * contains mapping to GNUNET_ATS_Property*/
269 int q[GNUNET_ATS_QualityPropertiesCount];
270
271 /* column index quality metrics */
272 int c_q[GNUNET_ATS_QualityPropertiesCount];
273
274 /* column index quality metrics */
275 int r_q[GNUNET_ATS_QualityPropertiesCount];
276
277 /* quality metric coefficients*/
278 double co_Q[GNUNET_ATS_QualityPropertiesCount];
279
280 /* number of quality metrics */
281 int m_q;
282
283 /* ATS network quotas */
284 int c_quota[GNUNET_ATS_NetworkTypeCount];
285 int r_quota[GNUNET_ATS_NetworkTypeCount];
286 int quota_index [GNUNET_ATS_NetworkTypeCount];
287 unsigned long long quota_out[GNUNET_ATS_NetworkTypeCount];
288 unsigned long long quota_in[GNUNET_ATS_NetworkTypeCount];
289 334
290 /* ATS ressource costs 335 /* ATS ressource costs
291 * 336 *
@@ -293,20 +338,6 @@ struct GAS_MLP_Handle
293 * contains mapping to GNUNET_ATS_Property*/ 338 * contains mapping to GNUNET_ATS_Property*/
294 int rc[GNUNET_ATS_QualityPropertiesCount]; 339 int rc[GNUNET_ATS_QualityPropertiesCount];
295 340
296 /* column index ressource costs */
297 int c_rc[GNUNET_ATS_QualityPropertiesCount];
298
299 /* ressource costs coefficients*/
300 double co_RC[GNUNET_ATS_QualityPropertiesCount];
301
302 /* number of quality metrics */
303 int m_rc;
304
305 /* minimum bandwidth assigned to an address */
306 unsigned int b_min;
307
308 /* minimum number of addresses with bandwidth assigned */
309 unsigned int n_min;
310}; 341};
311 342
312 343
diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c
index 9d098d454..8f2bd8c07 100644
--- a/src/ats/perf_ats_mlp.c
+++ b/src/ats/perf_ats_mlp.c
@@ -356,12 +356,12 @@ check (void *cls, char *const *args, const char *cfgfile,
356 ca++; 356 ca++;
357 } 357 }
358 358
359 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Problem contains %u peers and %u adresses\n", mlp->c_p, mlp->addr_in_problem); 359 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Problem contains %u peers and %u adresses\n", mlp->c_p, mlp->addresses_in_problem);
360 360
361 if (((GNUNET_YES == range) && (((start >= 0) && ((c+1) >= start)) && (c <= end))) || ((c+1) == peers)) 361 if (((GNUNET_YES == range) && (((start >= 0) && ((c+1) >= start)) && (c <= end))) || ((c+1) == peers))
362 { 362 {
363 GNUNET_assert ((c+1) == mlp->c_p); 363 GNUNET_assert ((c+1) == mlp->c_p);
364 GNUNET_assert ((c+1) * addresses == mlp->addr_in_problem); 364 GNUNET_assert ((c+1) * addresses == mlp->addresses_in_problem);
365 365
366 /* Solving the problem */ 366 /* Solving the problem */
367 struct GAS_MLP_SolutionContext ctx; 367 struct GAS_MLP_SolutionContext ctx;
@@ -375,10 +375,10 @@ check (void *cls, char *const *args, const char *cfgfile,
375 GNUNET_assert (GNUNET_OK == ctx.lp_result); 375 GNUNET_assert (GNUNET_OK == ctx.lp_result);
376 GNUNET_assert (GNUNET_OK == ctx.mlp_result); 376 GNUNET_assert (GNUNET_OK == ctx.mlp_result);
377 if (GNUNET_YES == numeric) 377 if (GNUNET_YES == numeric)
378 printf ("%u;%u;%llu;%llu\n",mlp->c_p, mlp->addr_in_problem, (unsigned long long) ctx.lp_duration.rel_value, (unsigned long long) ctx.mlp_duration.rel_value); 378 printf ("%u;%u;%llu;%llu\n",mlp->c_p, mlp->addresses_in_problem, (unsigned long long) ctx.lp_duration.rel_value, (unsigned long long) ctx.mlp_duration.rel_value);
379 else 379 else
380 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Problem solved for %u peers with %u address successfully (LP: %llu ms / MLP: %llu ms)\n", 380 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Problem solved for %u peers with %u address successfully (LP: %llu ms / MLP: %llu ms)\n",
381 mlp->c_p, mlp->addr_in_problem, ctx.lp_duration.rel_value, ctx.mlp_duration.rel_value); 381 mlp->c_p, mlp->addresses_in_problem, ctx.lp_duration.rel_value, ctx.mlp_duration.rel_value);
382 } 382 }
383 else 383 else
384 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Solving problem with %u peers and %u addresses failed\n", c, c2); 384 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Solving problem with %u peers and %u addresses failed\n", c, c2);
@@ -397,12 +397,12 @@ check (void *cls, char *const *args, const char *cfgfile,
397 GNUNET_assert (GNUNET_OK == uctx.lp_result); 397 GNUNET_assert (GNUNET_OK == uctx.lp_result);
398 GNUNET_assert (GNUNET_OK == uctx.mlp_result); 398 GNUNET_assert (GNUNET_OK == uctx.mlp_result);
399 if (GNUNET_YES == numeric) 399 if (GNUNET_YES == numeric)
400 printf ("%u;%u;%llu;%llu;%llu;%llu\n",mlp->c_p, mlp->addr_in_problem, 400 printf ("%u;%u;%llu;%llu;%llu;%llu\n",mlp->c_p, mlp->addresses_in_problem,
401 (unsigned long long) ctx.lp_duration.rel_value, (unsigned long long) ctx.mlp_duration.rel_value, 401 (unsigned long long) ctx.lp_duration.rel_value, (unsigned long long) ctx.mlp_duration.rel_value,
402 (unsigned long long) uctx.lp_duration.rel_value, (unsigned long long) uctx.mlp_duration.rel_value); 402 (unsigned long long) uctx.lp_duration.rel_value, (unsigned long long) uctx.mlp_duration.rel_value);
403 else 403 else
404 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Updated problem solved for %u peers with %u address successfully (Initial: LP/MLP: %llu/%llu ms, Update: %llu/%llu ms)\n", 404 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Updated problem solved for %u peers with %u address successfully (Initial: LP/MLP: %llu/%llu ms, Update: %llu/%llu ms)\n",
405 mlp->c_p, mlp->addr_in_problem, 405 mlp->c_p, mlp->addresses_in_problem,
406 (unsigned long long) ctx.lp_duration.rel_value, (unsigned long long) ctx.mlp_duration.rel_value, 406 (unsigned long long) ctx.lp_duration.rel_value, (unsigned long long) ctx.mlp_duration.rel_value,
407 (unsigned long long) uctx.lp_duration.rel_value, (unsigned long long) uctx.mlp_duration.rel_value); 407 (unsigned long long) uctx.lp_duration.rel_value, (unsigned long long) uctx.mlp_duration.rel_value);
408 } 408 }
diff --git a/src/ats/test_ats_mlp.c b/src/ats/test_ats_mlp.c
index b6aa30c04..7ca8aaaf1 100644
--- a/src/ats/test_ats_mlp.c
+++ b/src/ats/test_ats_mlp.c
@@ -55,12 +55,12 @@ struct GNUNET_CONTAINER_MultiHashMap * addresses;
55/** 55/**
56 * Peer 56 * Peer
57 */ 57 */
58struct GNUNET_PeerIdentity p; 58struct GNUNET_PeerIdentity p[2];
59 59
60/** 60/**
61 * ATS Address 61 * ATS Address
62 */ 62 */
63struct ATS_Address *address[2]; 63struct ATS_Address *address[3];
64 64
65/** 65/**
66 * Timeout task 66 * Timeout task
@@ -136,6 +136,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
136 end_now (1); 136 end_now (1);
137} 137}
138 138
139
139static void 140static void
140check (void *cls, char *const *args, const char *cfgfile, 141check (void *cls, char *const *args, const char *cfgfile,
141 const struct GNUNET_CONFIGURATION_Handle *cfg) 142 const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -183,23 +184,47 @@ check (void *cls, char *const *args, const char *cfgfile,
183 return; 184 return;
184 } 185 }
185 186
186 /* Create peer */ 187 /* Create peer 0 */
187 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p.hashPubKey)) 188 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p[0].hashPubKey))
188 { 189 {
189 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); 190 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
190 end_now (1); 191 end_now (1);
191 return; 192 return;
192 } 193 }
193 194
195 /* Create peer 1 */
196 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1, &p[1].hashPubKey))
197 {
198 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
199 end_now (1);
200 return;
201 }
202
203 /* Create address 3 */
204 address[2] = create_address (&p[1], "test_plugin", "test_addr2", strlen("test_addr2")+1, 0);
205 if (NULL == address[2])
206 {
207 GNUNET_break (0);
208 end_now (1);
209 return;
210 }
211 GNUNET_CONTAINER_multihashmap_put (addresses, &p[1].hashPubKey, address[2],
212 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
213
214
215 /* Adding address 1*/
216 GAS_mlp_address_add (mlp, addresses, address[2]);
217
218
194 /* Create address 0 */ 219 /* Create address 0 */
195 address[0] = create_address (&p, "test_plugin", "test_addr0", strlen("test_addr0")+1, 0); 220 address[0] = create_address (&p[0], "test_plugin", "test_addr0", strlen("test_addr0")+1, 0);
196 if (NULL == address[0]) 221 if (NULL == address[0])
197 { 222 {
198 GNUNET_break (0); 223 GNUNET_break (0);
199 end_now (1); 224 end_now (1);
200 return; 225 return;
201 } 226 }
202 GNUNET_CONTAINER_multihashmap_put (addresses, &p.hashPubKey, address[0], 227 GNUNET_CONTAINER_multihashmap_put (addresses, &p[0].hashPubKey, address[0],
203 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 228 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
204 229
205 /* Adding address 0 */ 230 /* Adding address 0 */
@@ -212,17 +237,17 @@ check (void *cls, char *const *args, const char *cfgfile,
212 237
213 238
214 /* Retrieving preferred address for peer and wait for callback */ 239 /* Retrieving preferred address for peer and wait for callback */
215 GAS_mlp_get_preferred_address (mlp, addresses, &p); 240 GAS_mlp_get_preferred_address (mlp, addresses, &p[0]);
216 241
217 /* Create address 1 */ 242 /* Create address 1 */
218 address[1] = create_address (&p, "test_plugin", "test_addr1", strlen("test_addr1")+1, 0); 243 address[1] = create_address (&p[0], "test_plugin", "test_addr1", strlen("test_addr1")+1, 0);
219 if (NULL == address[1]) 244 if (NULL == address[1])
220 { 245 {
221 GNUNET_break (0); 246 GNUNET_break (0);
222 end_now (1); 247 end_now (1);
223 return; 248 return;
224 } 249 }
225 GNUNET_CONTAINER_multihashmap_put (addresses, &p.hashPubKey, address[1], 250 GNUNET_CONTAINER_multihashmap_put (addresses, &p[0].hashPubKey, address[1],
226 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 251 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
227 252
228 253
diff --git a/src/ats/test_ats_mlp_averaging.c b/src/ats/test_ats_mlp_averaging.c
index 59291b01f..390f380ea 100644
--- a/src/ats/test_ats_mlp_averaging.c
+++ b/src/ats/test_ats_mlp_averaging.c
@@ -189,28 +189,28 @@ check (void *cls, char *const *args, const char *cfgfile,
189 // mlpi = addr[0].mlp_information; 189 // mlpi = addr[0].mlp_information;
190 190
191 GNUNET_assert (mlp != NULL); 191 GNUNET_assert (mlp != NULL);
192 GNUNET_assert (mlp->addr_in_problem == 1); 192 GNUNET_assert (mlp->addresses_in_problem == 1);
193 193
194 /* Update an peer 1 address 1 */ 194 /* Update an peer 1 address 1 */
195 set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 20); 195 set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 20);
196 GAS_mlp_address_update (mlp, addresses, &addr[0]); 196 GAS_mlp_address_update (mlp, addresses, &addr[0]);
197 GNUNET_assert (mlp->addr_in_problem == 1); 197 GNUNET_assert (mlp->addresses_in_problem == 1);
198 198
199 199
200 /* Update an peer 1 address 1 */ 200 /* Update an peer 1 address 1 */
201 set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 10); 201 set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 10);
202 GAS_mlp_address_update (mlp, addresses, &addr[0]); 202 GAS_mlp_address_update (mlp, addresses, &addr[0]);
203 GNUNET_assert (mlp->addr_in_problem == 1); 203 GNUNET_assert (mlp->addresses_in_problem == 1);
204 204
205 /* Update an peer 1 address 1 */ 205 /* Update an peer 1 address 1 */
206 set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 10); 206 set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 10);
207 GAS_mlp_address_update (mlp, addresses, &addr[0]); 207 GAS_mlp_address_update (mlp, addresses, &addr[0]);
208 GNUNET_assert (mlp->addr_in_problem == 1); 208 GNUNET_assert (mlp->addresses_in_problem == 1);
209 209
210 /* Update an peer 1 address 1 */ 210 /* Update an peer 1 address 1 */
211 set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 30); 211 set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 30);
212 GAS_mlp_address_update (mlp, addresses, &addr[0]); 212 GAS_mlp_address_update (mlp, addresses, &addr[0]);
213 GNUNET_assert (mlp->addr_in_problem == 1); 213 GNUNET_assert (mlp->addresses_in_problem == 1);
214 214
215 215
216 GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp, &ctx)); 216 GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp, &ctx));
@@ -224,7 +224,7 @@ check (void *cls, char *const *args, const char *cfgfile,
224 GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[0].peer.hashPubKey, &addr[0]); 224 GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[0].peer.hashPubKey, &addr[0]);
225 GAS_mlp_address_delete (mlp, addresses, &addr[0]); 225 GAS_mlp_address_delete (mlp, addresses, &addr[0]);
226 226
227 GNUNET_assert (mlp->addr_in_problem == 0); 227 GNUNET_assert (mlp->addresses_in_problem == 0);
228 228
229 GAS_mlp_done (mlp); 229 GAS_mlp_done (mlp);
230 230