aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-04-17 10:36:04 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-04-17 10:36:04 +0000
commit716899950996602e7bc249b2a752032272b5ec00 (patch)
tree9d988f103dcc5a4db5402e131595f3f9ad87351f /src/ats
parentdb854346c14f08d5cb53912c352af94b022ae572 (diff)
downloadgnunet-716899950996602e7bc249b2a752032272b5ec00.tar.gz
gnunet-716899950996602e7bc249b2a752032272b5ec00.zip
- changes
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c49
-rw-r--r--src/ats/perf_ats_mlp.c19
2 files changed, 38 insertions, 30 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c
index 33b7e32e5..9f0c6c6cd 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.c
+++ b/src/ats/gnunet-service-ats_addresses_mlp.c
@@ -806,6 +806,14 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas
806 return res; 806 return res;
807} 807}
808 808
809
810struct SolveContext
811{
812 struct GNUNET_TIME_Relative lp_duration;
813 struct GNUNET_TIME_Relative mlp_duration;
814};
815
816
809/** 817/**
810 * Solves the LP problem 818 * Solves the LP problem
811 * 819 *
@@ -813,7 +821,7 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas
813 * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure 821 * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
814 */ 822 */
815static int 823static int
816mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp) 824mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp, struct SolveContext *s_ctx)
817{ 825{
818 int res; 826 int res;
819 struct GNUNET_TIME_Relative duration; 827 struct GNUNET_TIME_Relative duration;
@@ -867,6 +875,7 @@ lp_solv:
867 duration = GNUNET_TIME_absolute_get_difference (start, end); 875 duration = GNUNET_TIME_absolute_get_difference (start, end);
868 mlp->lp_solved++; 876 mlp->lp_solved++;
869 mlp->lp_total_duration =+ duration.rel_value; 877 mlp->lp_total_duration =+ duration.rel_value;
878 s_ctx->lp_duration = duration;
870 879
871 GNUNET_STATISTICS_update (mlp->stats,"# LP problem solved", 1, GNUNET_NO); 880 GNUNET_STATISTICS_update (mlp->stats,"# LP problem solved", 1, GNUNET_NO);
872 GNUNET_STATISTICS_set (mlp->stats,"# LP execution time (ms)", duration.rel_value, GNUNET_NO); 881 GNUNET_STATISTICS_set (mlp->stats,"# LP execution time (ms)", duration.rel_value, GNUNET_NO);
@@ -906,7 +915,7 @@ lp_solv:
906 * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure 915 * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
907 */ 916 */
908int 917int
909mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp) 918mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp, struct SolveContext *s_ctx)
910{ 919{
911 int res; 920 int res;
912 struct GNUNET_TIME_Relative duration; 921 struct GNUNET_TIME_Relative duration;
@@ -943,6 +952,7 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp)
943 duration = GNUNET_TIME_absolute_get_difference (start, end); 952 duration = GNUNET_TIME_absolute_get_difference (start, end);
944 mlp->mlp_solved++; 953 mlp->mlp_solved++;
945 mlp->mlp_total_duration =+ duration.rel_value; 954 mlp->mlp_total_duration =+ duration.rel_value;
955 s_ctx->mlp_duration = duration;
946 956
947 GNUNET_STATISTICS_update (mlp->stats,"# MLP problem solved", 1, GNUNET_NO); 957 GNUNET_STATISTICS_update (mlp->stats,"# MLP problem solved", 1, GNUNET_NO);
948 GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time (ms)", duration.rel_value, GNUNET_NO); 958 GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time (ms)", duration.rel_value, GNUNET_NO);
@@ -989,7 +999,6 @@ mlp_scheduler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
989 GAS_mlp_solve_problem(mlp); 999 GAS_mlp_solve_problem(mlp);
990} 1000}
991 1001
992
993/** 1002/**
994 * Solves the MLP problem 1003 * Solves the MLP problem
995 * 1004 *
@@ -1000,11 +1009,10 @@ int
1000GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp) 1009GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp)
1001{ 1010{
1002 int res; 1011 int res;
1012 struct SolveContext s_ctx;
1003 mlp->last_execution = GNUNET_TIME_absolute_get (); 1013 mlp->last_execution = GNUNET_TIME_absolute_get ();
1004 1014
1005 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solving\n"); 1015 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve LP problem\n");
1006
1007
1008#if WRITE_MLP 1016#if WRITE_MLP
1009 char * name; 1017 char * name;
1010 static int i; 1018 static int i;
@@ -1014,39 +1022,34 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp)
1014 GNUNET_free (name); 1022 GNUNET_free (name);
1015# endif 1023# endif
1016 1024
1017 res = mlp_solve_lp_problem (mlp); 1025 res = mlp_solve_lp_problem (mlp, &s_ctx);
1018 1026 if (res != GNUNET_OK)
1027 {
1028 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "LP Problem solving failed\n");
1029 return GNUNET_SYSERR;
1030 }
1019#if WRITE_MLP 1031#if WRITE_MLP
1020 GNUNET_asprintf(&name, "problem_%i_lp_solution", i); 1032 GNUNET_asprintf(&name, "problem_%i_lp_solution", i);
1021 glp_print_sol (mlp->prob, name); 1033 glp_print_sol (mlp->prob, name);
1022 GNUNET_free (name); 1034 GNUNET_free (name);
1023# endif 1035# endif
1024 1036
1037
1038 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve MLP problem\n");
1039 res = mlp_solve_mlp_problem (mlp, &s_ctx);
1025 if (res != GNUNET_OK) 1040 if (res != GNUNET_OK)
1026 { 1041 {
1027 1042 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP Problem solving failed\n");
1028 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "LP Problem solving failed\n");
1029
1030 return GNUNET_SYSERR; 1043 return GNUNET_SYSERR;
1031 } 1044 }
1032
1033 res = mlp_solve_mlp_problem (mlp);
1034
1035#if WRITE_MLP 1045#if WRITE_MLP
1036 GNUNET_asprintf(&name, "problem_%i_mlp_solution", i); 1046 GNUNET_asprintf(&name, "problem_%i_mlp_solution", i);
1037 glp_print_mip (mlp->prob, name); 1047 glp_print_mip (mlp->prob, name);
1038 GNUNET_free (name); 1048 GNUNET_free (name);
1039# endif 1049# endif
1040 if (res != GNUNET_OK)
1041 {
1042
1043 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP Problem solving failed\n");
1044
1045 return GNUNET_SYSERR;
1046 }
1047
1048 1050
1049 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved\n"); 1051 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved %s (LP duration %llu / MLP duration %llu)\n",
1052 (GNUNET_OK == res) ? "successfully" : "failed", s_ctx.lp_duration, s_ctx.mlp_duration);
1050 /* Process result */ 1053 /* Process result */
1051 struct ATS_Peer *p = NULL; 1054 struct ATS_Peer *p = NULL;
1052 struct ATS_Address *a = NULL; 1055 struct ATS_Address *a = NULL;
diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c
index 115fbf01a..f536419a7 100644
--- a/src/ats/perf_ats_mlp.c
+++ b/src/ats/perf_ats_mlp.c
@@ -88,7 +88,7 @@ check (void *cls, char *const *args, const char *cfgfile,
88 if (addresses == 0) 88 if (addresses == 0)
89 addresses = DEF_ADDRESSES_PER_PEER; 89 addresses = DEF_ADDRESSES_PER_PEER;
90 90
91 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up %u peers with %u addresses per peer\n", peers, addresses); 91 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up %u peers with %u addresses per peer\n", peers, addresses);
92 92
93 struct PeerContext p[peers]; 93 struct PeerContext p[peers];
94 struct ATS_Address a[addresses * peers]; 94 struct ATS_Address a[addresses * peers];
@@ -99,12 +99,12 @@ check (void *cls, char *const *args, const char *cfgfile,
99 mlp->auto_solve = GNUNET_NO; 99 mlp->auto_solve = GNUNET_NO;
100 for (c=0; c < peers; c++) 100 for (c=0; c < peers; c++)
101 { 101 {
102 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up peer %u\n", c); 102 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up peer %u\n", c);
103 GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[c].id.hashPubKey); 103 GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[c].id.hashPubKey);
104 104
105 for (c2=0; c2 < addresses; c2++) 105 for (c2=0; c2 < addresses; c2++)
106 { 106 {
107 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up address %u for peer %u\n", c2, c); 107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up address %u for peer %u\n", c2, c);
108 /* Setting required information */ 108 /* Setting required information */
109 a[ca].mlp_information = NULL; 109 a[ca].mlp_information = NULL;
110 a[ca].prev = NULL; 110 a[ca].prev = NULL;
@@ -123,20 +123,25 @@ check (void *cls, char *const *args, const char *cfgfile,
123 a[ca].ats[1].type = GNUNET_ATS_QUALITY_NET_DISTANCE; 123 a[ca].ats[1].type = GNUNET_ATS_QUALITY_NET_DISTANCE;
124 a[ca].ats[1].value = 2; 124 a[ca].ats[1].value = 2;
125 a[ca].ats_count = 2; 125 a[ca].ats_count = 2;
126 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up address %u\n", ca); 126 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up address %u\n", ca);
127 GNUNET_CONTAINER_multihashmap_put (amap, &a[ca].peer.hashPubKey, &a[ca], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 127 GNUNET_CONTAINER_multihashmap_put (amap, &a[ca].peer.hashPubKey, &a[ca], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
128 GAS_mlp_address_update(mlp, amap, &a[ca]); 128 GAS_mlp_address_update(mlp, amap, &a[ca]);
129
130 ca++; 129 ca++;
131 } 130 }
132 } 131 }
133 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem contains %u peers and %u adresses\n", mlp->c_p, mlp->addr_in_problem); 132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem contains %u peers and %u adresses\n", mlp->c_p, mlp->addr_in_problem);
134 133
135 /* Solving the problem */ 134 /* Solving the problem */
136 //GAS_mlp_solve_problem(mlp); 135 if (GNUNET_OK == GAS_mlp_solve_problem(mlp))
136 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved successfully \n");
137 else
138 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved failed \n");
137 139
138 GAS_mlp_done (mlp); 140 GAS_mlp_done (mlp);
139 141
142 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Execution duration %llu\n", mlp->max_exec_duration);
143
144
140 for (ca=0; ca < (peers * addresses); ca++) 145 for (ca=0; ca < (peers * addresses); ca++)
141 { 146 {
142 GNUNET_free (a[ca].plugin); 147 GNUNET_free (a[ca].plugin);