aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-06-10 10:22:47 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-06-10 10:22:47 +0000
commitcc5a4d5cd7f35b8817a7657e1ebade1ae2137dc0 (patch)
tree03fec8bd3498804f5b8bdea833f8f79f1a8096f0 /src/transport
parent6c64afa2c2309f6b60e5b2207b764e3b2e677ae5 (diff)
downloadgnunet-cc5a4d5cd7f35b8817a7657e1ebade1ae2137dc0.tar.gz
gnunet-cc5a4d5cd7f35b8817a7657e1ebade1ae2137dc0.zip
removing glpk output
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/perf_transport_ats.c390
1 files changed, 194 insertions, 196 deletions
diff --git a/src/transport/perf_transport_ats.c b/src/transport/perf_transport_ats.c
index d95e02d2b..cb895f521 100644
--- a/src/transport/perf_transport_ats.c
+++ b/src/transport/perf_transport_ats.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2010, 2011 Christian Grothoff (and other contributing authors) 3 (C) 2009 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -18,7 +18,7 @@
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20/** 20/**
21 * @file testing/perf_transport_ats.c 21 * @file testing/per_transport_ats.c
22 * @brief testcase for ats functionality 22 * @brief testcase for ats functionality
23 */ 23 */
24#include "platform.h" 24#include "platform.h"
@@ -48,202 +48,186 @@ static struct GNUNET_TIME_Absolute start;
48static struct GNUNET_TIME_Absolute end; 48static struct GNUNET_TIME_Absolute end;
49 49
50 50
51static void 51void solve_mlp(int presolve)
52solve_mlp(int presolve)
53{ 52{
54 int result, solution; 53 int result, solution;
55 54
56 glp_iocp opt_mlp; 55 glp_iocp opt_mlp;
57 glp_init_iocp(&opt_mlp); 56 glp_init_iocp(&opt_mlp);
58 opt_mlp.msg_lev = GLP_MSG_OFF; 57 opt_mlp.msg_lev = GLP_MSG_OFF;
59 opt_mlp.presolve = GLP_OFF; 58 opt_mlp.presolve = GLP_OFF;
60 59
61 result = glp_intopt (prob, &opt_mlp); 60 result = glp_intopt (prob, &opt_mlp);
62 solution = glp_mip_status (prob); 61 solution = glp_mip_status (prob);
63 GNUNET_assert ((solution == 5) && (result==0)); 62 GNUNET_assert ((solution == 5) && (result==0));
64} 63}
65 64
66static void 65void solve_lp(int presolve)
67solve_lp(int presolve)
68{ 66{
69 int result, solution; 67 int result, solution;
70 68
71 glp_smcp opt_lp; 69 glp_smcp opt_lp;
72 glp_init_smcp(&opt_lp); 70 glp_init_smcp(&opt_lp);
73 71
74 opt_lp.msg_lev = GLP_MSG_OFF; 72 opt_lp.msg_lev = GLP_MSG_OFF;
75 if (presolve==GNUNET_YES) opt_lp.presolve = GLP_ON; 73 if (presolve==GNUNET_YES) opt_lp.presolve = GLP_ON;
76 else opt_lp.presolve = GLP_OFF; 74 else opt_lp.presolve = GLP_OFF;
77 75
78 result = glp_simplex(prob, &opt_lp); 76 result = glp_simplex(prob, &opt_lp);
79 solution = glp_get_status (prob); 77 solution = glp_get_status (prob);
80 GNUNET_assert ((solution == 5) && (result==0)); 78 GNUNET_assert ((solution == 5) && (result==0));
81} 79}
82 80
83#if 0
84/* Modify quality constraint */ 81/* Modify quality constraint */
85static void 82void modify_qm(int start, int length, int values_to_change)
86modify_qm(int start, int length, int values_to_change)
87{ 83{
88 //int * ind = GNUNET_malloc (length * sizeof (int)); 84 //int * ind = GNUNET_malloc (length * sizeof (int));
89 //double *val = GNUNET_malloc (length * sizeof (double)); 85 //double *val = GNUNET_malloc (length * sizeof (double));
90 int ind[1000]; 86 int ind[1000];
91 double val[1000]; 87 double val[1000];
92 88
93 int res = 0; 89 int res = 0;
94 int c = start, c2=1; 90 int c = start, c2=1;
95 while (c<=(start+values_to_change)) 91 while (c<=(start+values_to_change))
96 {
97 res = glp_get_mat_row(prob, c, ind, val);
98
99 printf("%i %i \n", c, res);
100 for (c2=0; c2<res; c2++)
101 { 92 {
102 printf("%i = %f \n", ind[c2], val[c2]); 93 res = glp_get_mat_row(prob, c, ind, val);
94
95 printf("%i %i \n", c, res);
96 for (c2=0; c2<res; c2++)
97 {
98 printf("%i = %f \n", ind[c2], val[c2]);
99 }
100
101 c++;
103 } 102 }
104 103 //glp_set_mat_row(prob, start, length, ind, val);
105 c++;
106 }
107 //glp_set_mat_row(prob, start, length, ind, val);
108} 104}
109#endif
110 105
111 106
112static void 107
113bench_simplex_optimization(char * file, int executions) 108void bench_simplex_optimization(char * file, int executions)
114{ 109{
115 110
116 int c; 111 int c;
117 prob = glp_create_prob(); 112 prob = glp_create_prob();
118 glp_read_lp(prob, NULL, file); 113 glp_read_lp(prob, NULL, file);
119 114
120 solve_lp(GNUNET_YES); 115 solve_lp(GNUNET_YES);
121 116
122 for (c=0; c<executions;c++) 117 for (c=0; c<executions;c++)
123 { 118 {
124 start = GNUNET_TIME_absolute_get(); 119 start = GNUNET_TIME_absolute_get();
125 solve_lp(GNUNET_NO); 120 solve_lp(GNUNET_NO);
126 end = GNUNET_TIME_absolute_get(); 121 end = GNUNET_TIME_absolute_get();
127 122
128 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; 123 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
129 124
130 sim_with_opt_avg += exec_time[c]; 125 sim_with_opt_avg += exec_time[c];
131 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 126 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex /w optimization iterations %i: %llu \n", c, exec_time[c]);
132 "Simplex /w optimization iterations %i: %llu \n", 127 }
133 c, exec_time[c]); 128
134 } 129 glp_delete_prob(prob);
135
136 glp_delete_prob(prob);
137} 130}
138 131
139 132
140static void 133void bench_simplex_no_optimization(char * file, int executions)
141bench_simplex_no_optimization(char * file, int executions)
142{ 134{
143
144 int c;
145 prob = glp_create_prob();
146 glp_read_lp(prob, NULL, file);
147
148 for (c=0; c<executions;c++)
149 {
150 start = GNUNET_TIME_absolute_get();
151 solve_lp(GNUNET_YES);
152 end = GNUNET_TIME_absolute_get();
153
154 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
155
156 sim_no_opt_avg += exec_time[c];
157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
158 "Simplex iterations %i: %llu \n",
159 c, exec_time[c]);
160 }
161
162 glp_delete_prob(prob);
163}
164 135
136 int c;
137 prob = glp_create_prob();
138 glp_read_lp(prob, NULL, file);
139
140 for (c=0; c<executions;c++)
141 {
142 start = GNUNET_TIME_absolute_get();
143 solve_lp(GNUNET_YES);
144 end = GNUNET_TIME_absolute_get();
145
146 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
165 147
166static void 148 sim_no_opt_avg += exec_time[c];
167bench_mlp_no_optimization(char * file, int executions) 149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex iterations %i: %llu \n", c, exec_time[c]);
150 }
151
152 glp_delete_prob(prob);
153}
154
155void bench_mlp_no_optimization(char * file, int executions)
168{ 156{
169 157
170 int c; 158 int c;
171 prob = glp_create_prob(); 159 prob = glp_create_prob();
172 glp_read_lp(prob, NULL, file); 160 glp_read_lp(prob, NULL, file);
173 161
174 for (c=0; c<executions;c++) 162 for (c=0; c<executions;c++)
175 { 163 {
176 start = GNUNET_TIME_absolute_get(); 164 start = GNUNET_TIME_absolute_get();
177 solve_lp(GNUNET_YES); 165 solve_lp(GNUNET_YES);
178 solve_mlp (GNUNET_NO); 166 solve_mlp (GNUNET_NO);
179 end = GNUNET_TIME_absolute_get(); 167 end = GNUNET_TIME_absolute_get();
180 168
181 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; 169 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
182 170
183 mlp_no_opt_avg += exec_time[c]; 171 mlp_no_opt_avg += exec_time[c];
184 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP iterations no optimization %i: %llu \n", c, exec_time[c]); 172 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP iterations no optimization %i: %llu \n", c, exec_time[c]);
185 } 173 }
186 174
187 glp_delete_prob(prob); 175 glp_delete_prob(prob);
188} 176}
189 177
190 178
191static void 179void bench_mlp_with_optimization(char * file, int executions, int changes)
192bench_mlp_with_optimization(char * file, int executions, int changes)
193{ 180{
194 int c; 181 int c;
195 prob = glp_create_prob(); 182 prob = glp_create_prob();
196 glp_read_lp(prob, NULL, file); 183 glp_read_lp(prob, NULL, file);
197 184
198 solve_lp(GNUNET_YES); 185 solve_lp(GNUNET_YES);
199 186
200 for (c=0; c<executions;c++) 187 for (c=0; c<executions;c++)
201 { 188 {
202 start = GNUNET_TIME_absolute_get(); 189 start = GNUNET_TIME_absolute_get();
203 // modify_qm(906, 0, 0); 190 //modify_qm(906, 0, 0);
204 solve_lp(GNUNET_NO); 191 solve_lp(GNUNET_NO);
205 solve_mlp (GNUNET_NO); 192 solve_mlp (GNUNET_NO);
206 end = GNUNET_TIME_absolute_get(); 193 end = GNUNET_TIME_absolute_get();
207 194
208 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; 195 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
209 196
210 mlp_with_opt_avg += exec_time[c]; 197 mlp_with_opt_avg += exec_time[c];
211 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP /w optimization iterations %i: %llu \n", c, exec_time[c]); 198 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP /w optimization iterations %i: %llu \n", c, exec_time[c]);
212 } 199 }
213 200
214 glp_delete_prob(prob); 201 glp_delete_prob(prob);
215} 202}
216 203
217#if 0 204#if 0
218static void 205void modify_cr (int start, int length, int count)
219modify_cr (int start, int length, int count)
220{ 206{
221 //int * ind = GNUNET_malloc (length * sizeof (int)); 207 //int * ind = GNUNET_malloc (length * sizeof (int));
222 //double *val = GNUNET_malloc (length * sizeof (double)); 208 //double *val = GNUNET_malloc (length * sizeof (double));
223 int ind[500]; 209 int ind[500];
224 double val[500]; 210 double val[500];
225 int res = 0; 211 int res = 0;
226 int c = start, c2=1; 212 int c = start, c2=1;
227 while (c<=(start+count)) 213 while (c<=(start+count))
228 {
229 res = glp_get_mat_row(prob, c, ind, val);
230
231 printf("row index: %i non-zero elements: %i \n", c, res);
232 for (c2=1; c2<=res; c2++)
233 { 214 {
234 printf("%i = %f ", ind[c2], val[c2]); 215 res = glp_get_mat_row(prob, c, ind, val);
216
217 printf("row index: %i non-zero elements: %i \n", c, res);
218 for (c2=1; c2<=res; c2++)
219 {
220 printf("%i = %f ", ind[c2], val[c2]);
221 }
222 c++;
223 printf ("\n----\n");
235 } 224 }
236 c++; 225 //glp_set_mat_row(prob, start, length, ind, val);
237 printf ("\n----\n");
238 }
239 //glp_set_mat_row(prob, start, length, ind, val);
240} 226}
241#endif 227#endif
242#endif 228#endif
243 229
244 230int main (int argc, char *argv[])
245int
246main (int argc, char *argv[])
247{ 231{
248 int ret = 0; 232 int ret = 0;
249 GNUNET_log_setup ("perf-transport-ats", 233 GNUNET_log_setup ("perf-transport-ats",
@@ -253,50 +237,64 @@ main (int argc, char *argv[])
253 "INFO", 237 "INFO",
254#endif 238#endif
255 NULL); 239 NULL);
256 240
257#if !HAVE_LIBGLPK 241#if !HAVE_LIBGLPK
258 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 242 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed, exiting testcase\n");
259 "GLPK not installed, exiting testcase\n"); 243 return 0;
260 return 0;
261#else 244#else
262 245#if 0
246#endif
247 int nullfd = OPEN ("/dev/null", O_RDWR | O_APPEND);
248 if (nullfd < 0)
249 return GNUNET_SYSERR;
250 /* set stdin/stdout to /dev/null */
251 //stdi
252 if (/*(dup2 (nullfd, 0) < 0) || */(dup2 (nullfd, 1) < 0))
253 {
254 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "dup2");
255 (void) CLOSE (nullfd);
256 return GNUNET_SYSERR;
257 }
258
259
263 char * file = "ats_mlp_p100_m400.problem"; 260 char * file = "ats_mlp_p100_m400.problem";
264 // char * file = "mlps/ats_mlp_p500_m2000.problem"; 261
265 bench_simplex_no_optimization (file, executions); 262 bench_simplex_no_optimization (file, executions);
266 bench_simplex_optimization (file, executions); 263 bench_simplex_optimization (file, executions);
267 bench_mlp_no_optimization (file, executions); 264 bench_mlp_no_optimization (file, executions);
268 bench_mlp_with_optimization (file, executions, 0); 265 bench_mlp_with_optimization (file, executions, 0);
269 266
270 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
271 "Simplex no optimization average: %llu\n",
272 sim_no_opt_avg / EXECS);
273 // -> 400 addresses 267 // -> 400 addresses
274 GAUGER ("GLPK", 268 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
275 "GLPK simplex no optimization", 269 "Simplex, no optimization, average per address: %f\n",
276 (sim_no_opt_avg / EXECS) / 400, 270 ((double) sim_no_opt_avg / EXECS) / 400);
277 "ms/address"); 271 GAUGER ("TRANSPORT","GLPK simplex no optimization",
278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 272 ((double) sim_no_opt_avg / EXECS) / 400, "ms/address");
279 "Simplex, no optimization, average per peer: %llu\n", 273
280 (sim_with_opt_avg / EXECS) / 400); 274 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
281 GAUGER ("GLPK", 275 "Simplex, with optimization, average per address: %f\n",
282 "GLPK simplex with optimization", 276 ((double) sim_with_opt_avg / EXECS) / 400);
283 (sim_with_opt_avg / EXECS) / 400, 277 GAUGER ("TRANSPORT",
284 "ms/address"); 278 "GLPK simplex, 100 peers 400 addresses with optimization",
285 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 279 ((double) sim_with_opt_avg / EXECS) / 400, "ms/address");
286 "MLP no optimization average: %llu\n", 280
287 (mlp_no_opt_avg / EXECS) / 400); 281 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
288 GAUGER ("GLPK", 282 "MLP no optimization average per address: %f\n",
289 "GLPK MLP no optimization", 283 ((double) mlp_no_opt_avg / EXECS) / 400);
290 (mlp_no_opt_avg / EXECS) / 400, 284 GAUGER ("TRANSPORT","GLPK MLP 100 peers 400 addresses no optimization",
291 "ms/address"); 285 ((double) mlp_no_opt_avg / EXECS) / 400, "ms/address");
292 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP optimization average: %llu\n", 286
293 (mlp_with_opt_avg/ EXECS) / 400); 287 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
294 GAUGER ("GLPK", 288 "MLP optimization average per address: %f\n",
295 "GLPK MLP with optimization", 289 ((double) mlp_with_opt_avg/ EXECS) / 400);
296 (mlp_with_opt_avg / EXECS) / 400, "ms/address"); 290 GAUGER ("TRANSPORT",
291 "GLPK MLP 100 peers 400 addresses with optimization",
292 ((double) mlp_with_opt_avg / EXECS) / 400, "ms/address");
297 293
298#endif 294#endif
295 (void) CLOSE (nullfd);
299 return ret; 296 return ret;
300} 297}
301 298
302/* end of per_transport_ats.c*/ 299/* end of per_transport_ats.c*/
300