diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-06-10 10:26:52 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-06-10 10:26:52 +0000 |
commit | eabaf5496c54475d87406df0b0ff9c3ae4e1a163 (patch) | |
tree | f0495b28b3d8e2c265cfca27206a28d2576daed7 /src/transport | |
parent | cc5a4d5cd7f35b8817a7657e1ebade1ae2137dc0 (diff) | |
download | gnunet-eabaf5496c54475d87406df0b0ff9c3ae4e1a163.tar.gz gnunet-eabaf5496c54475d87406df0b0ff9c3ae4e1a163.zip |
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/perf_transport_ats.c | 237 |
1 files changed, 122 insertions, 115 deletions
diff --git a/src/transport/perf_transport_ats.c b/src/transport/perf_transport_ats.c index cb895f521..eaec70c7b 100644 --- a/src/transport/perf_transport_ats.c +++ b/src/transport/perf_transport_ats.c | |||
@@ -50,179 +50,186 @@ static struct GNUNET_TIME_Absolute end; | |||
50 | 50 | ||
51 | void solve_mlp(int presolve) | 51 | void solve_mlp(int presolve) |
52 | { | 52 | { |
53 | int result, solution; | 53 | int result, solution; |
54 | 54 | ||
55 | glp_iocp opt_mlp; | 55 | glp_iocp opt_mlp; |
56 | glp_init_iocp(&opt_mlp); | 56 | glp_init_iocp(&opt_mlp); |
57 | opt_mlp.msg_lev = GLP_MSG_OFF; | 57 | opt_mlp.msg_lev = GLP_MSG_OFF; |
58 | opt_mlp.presolve = GLP_OFF; | 58 | opt_mlp.presolve = GLP_OFF; |
59 | 59 | ||
60 | result = glp_intopt (prob, &opt_mlp); | 60 | result = glp_intopt (prob, &opt_mlp); |
61 | solution = glp_mip_status (prob); | 61 | solution = glp_mip_status (prob); |
62 | GNUNET_assert ((solution == 5) && (result==0)); | 62 | GNUNET_assert ((solution == 5) && (result==0)); |
63 | } | 63 | } |
64 | 64 | ||
65 | void solve_lp(int presolve) | 65 | void solve_lp(int presolve) |
66 | { | 66 | { |
67 | int result, solution; | 67 | int result, solution; |
68 | 68 | ||
69 | glp_smcp opt_lp; | 69 | glp_smcp opt_lp; |
70 | glp_init_smcp(&opt_lp); | 70 | glp_init_smcp(&opt_lp); |
71 | 71 | ||
72 | opt_lp.msg_lev = GLP_MSG_OFF; | 72 | opt_lp.msg_lev = GLP_MSG_OFF; |
73 | if (presolve==GNUNET_YES) opt_lp.presolve = GLP_ON; | 73 | if (presolve==GNUNET_YES) opt_lp.presolve = GLP_ON; |
74 | else opt_lp.presolve = GLP_OFF; | 74 | else opt_lp.presolve = GLP_OFF; |
75 | 75 | ||
76 | result = glp_simplex(prob, &opt_lp); | 76 | result = glp_simplex(prob, &opt_lp); |
77 | solution = glp_get_status (prob); | 77 | solution = glp_get_status (prob); |
78 | GNUNET_assert ((solution == 5) && (result==0)); | 78 | GNUNET_assert ((solution == 5) && (result==0)); |
79 | } | 79 | } |
80 | 80 | ||
81 | /* Modify quality constraint */ | 81 | /* Modify quality constraint */ |
82 | void modify_qm(int start, int length, int values_to_change) | 82 | void modify_qm(int start, int length, int values_to_change) |
83 | { | 83 | { |
84 | //int * ind = GNUNET_malloc (length * sizeof (int)); | 84 | //int * ind = GNUNET_malloc (length * sizeof (int)); |
85 | //double *val = GNUNET_malloc (length * sizeof (double)); | 85 | //double *val = GNUNET_malloc (length * sizeof (double)); |
86 | int ind[1000]; | 86 | int ind[1000]; |
87 | double val[1000]; | 87 | double val[1000]; |
88 | 88 | ||
89 | int res = 0; | 89 | int res = 0; |
90 | int c = start, c2=1; | 90 | int c = start, c2=1; |
91 | while (c<=(start+values_to_change)) | 91 | while (c<=(start+values_to_change)) |
92 | { | 92 | { |
93 | res = glp_get_mat_row(prob, c, ind, val); | 93 | res = glp_get_mat_row(prob, c, ind, val); |
94 | 94 | ||
95 | printf("%i %i \n", c, res); | 95 | printf("%i %i \n", c, res); |
96 | for (c2=0; c2<res; c2++) | 96 | for (c2=0; c2<res; c2++) |
97 | { | 97 | { |
98 | printf("%i = %f \n", ind[c2], val[c2]); | 98 | printf("%i = %f \n", ind[c2], val[c2]); |
99 | } | 99 | } |
100 | 100 | ||
101 | c++; | 101 | c++; |
102 | } | 102 | } |
103 | //glp_set_mat_row(prob, start, length, ind, val); | 103 | //glp_set_mat_row(prob, start, length, ind, val); |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
107 | 107 | ||
108 | void bench_simplex_optimization(char * file, int executions) | 108 | void bench_simplex_optimization(char * file, int executions) |
109 | { | 109 | { |
110 | int c; | ||
110 | 111 | ||
111 | int c; | 112 | prob = glp_create_prob(); |
112 | prob = glp_create_prob(); | 113 | glp_read_lp(prob, NULL, file); |
113 | glp_read_lp(prob, NULL, file); | ||
114 | 114 | ||
115 | solve_lp(GNUNET_YES); | 115 | solve_lp(GNUNET_YES); |
116 | 116 | ||
117 | for (c=0; c<executions;c++) | 117 | for (c=0; c<executions;c++) |
118 | { | 118 | { |
119 | start = GNUNET_TIME_absolute_get(); | 119 | start = GNUNET_TIME_absolute_get(); |
120 | solve_lp(GNUNET_NO); | 120 | solve_lp(GNUNET_NO); |
121 | end = GNUNET_TIME_absolute_get(); | 121 | end = GNUNET_TIME_absolute_get(); |
122 | 122 | ||
123 | 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; |
124 | 124 | ||
125 | sim_with_opt_avg += exec_time[c]; | 125 | sim_with_opt_avg += exec_time[c]; |
126 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex /w optimization iterations %i: %llu \n", c, exec_time[c]); | 126 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
127 | } | 127 | "Simplex /w optimization iterations %i: %llu \n", c, exec_time[c]); |
128 | } | ||
128 | 129 | ||
129 | glp_delete_prob(prob); | 130 | glp_delete_prob(prob); |
130 | } | 131 | } |
131 | 132 | ||
132 | 133 | ||
133 | void bench_simplex_no_optimization(char * file, int executions) | 134 | void bench_simplex_no_optimization(char * file, int executions) |
134 | { | 135 | { |
136 | int c; | ||
135 | 137 | ||
136 | int c; | 138 | prob = glp_create_prob(); |
137 | prob = glp_create_prob(); | 139 | glp_read_lp(prob, NULL, file); |
138 | glp_read_lp(prob, NULL, file); | ||
139 | 140 | ||
140 | for (c=0; c<executions;c++) | 141 | for (c=0; c<executions;c++) |
141 | { | 142 | { |
142 | start = GNUNET_TIME_absolute_get(); | 143 | start = GNUNET_TIME_absolute_get(); |
143 | solve_lp(GNUNET_YES); | 144 | solve_lp(GNUNET_YES); |
144 | end = GNUNET_TIME_absolute_get(); | 145 | end = GNUNET_TIME_absolute_get(); |
145 | 146 | ||
146 | exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; | 147 | exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; |
147 | 148 | ||
148 | sim_no_opt_avg += exec_time[c]; | 149 | sim_no_opt_avg += exec_time[c]; |
149 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex iterations %i: %llu \n", c, exec_time[c]); | 150 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
150 | } | 151 | "Simplex iterations %i: %llu \n", |
152 | c, exec_time[c]); | ||
153 | } | ||
151 | 154 | ||
152 | glp_delete_prob(prob); | 155 | glp_delete_prob(prob); |
153 | } | 156 | } |
154 | 157 | ||
155 | void bench_mlp_no_optimization(char * file, int executions) | 158 | void bench_mlp_no_optimization(char * file, int executions) |
156 | { | 159 | { |
160 | int c; | ||
157 | 161 | ||
158 | int c; | 162 | prob = glp_create_prob(); |
159 | prob = glp_create_prob(); | 163 | glp_read_lp(prob, NULL, file); |
160 | glp_read_lp(prob, NULL, file); | ||
161 | 164 | ||
162 | for (c=0; c<executions;c++) | 165 | for (c=0; c<executions;c++) |
163 | { | 166 | { |
164 | start = GNUNET_TIME_absolute_get(); | 167 | start = GNUNET_TIME_absolute_get(); |
165 | solve_lp(GNUNET_YES); | 168 | solve_lp(GNUNET_YES); |
166 | solve_mlp (GNUNET_NO); | 169 | solve_mlp (GNUNET_NO); |
167 | end = GNUNET_TIME_absolute_get(); | 170 | end = GNUNET_TIME_absolute_get(); |
168 | 171 | ||
169 | exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; | 172 | exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; |
170 | 173 | ||
171 | mlp_no_opt_avg += exec_time[c]; | 174 | mlp_no_opt_avg += exec_time[c]; |
172 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP iterations no optimization %i: %llu \n", c, exec_time[c]); | 175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
173 | } | 176 | "MLP iterations no optimization %i: %llu \n", |
177 | c, exec_time[c]); | ||
178 | } | ||
174 | 179 | ||
175 | glp_delete_prob(prob); | 180 | glp_delete_prob(prob); |
176 | } | 181 | } |
177 | 182 | ||
178 | 183 | ||
179 | void bench_mlp_with_optimization(char * file, int executions, int changes) | 184 | void bench_mlp_with_optimization(char * file, int executions, int changes) |
180 | { | 185 | { |
181 | int c; | 186 | int c; |
182 | prob = glp_create_prob(); | 187 | prob = glp_create_prob(); |
183 | glp_read_lp(prob, NULL, file); | 188 | glp_read_lp(prob, NULL, file); |
184 | |||
185 | solve_lp(GNUNET_YES); | ||
186 | |||
187 | for (c=0; c<executions;c++) | ||
188 | { | ||
189 | start = GNUNET_TIME_absolute_get(); | ||
190 | //modify_qm(906, 0, 0); | ||
191 | solve_lp(GNUNET_NO); | ||
192 | solve_mlp (GNUNET_NO); | ||
193 | end = GNUNET_TIME_absolute_get(); | ||
194 | 189 | ||
195 | exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; | 190 | solve_lp(GNUNET_YES); |
196 | 191 | ||
197 | mlp_with_opt_avg += exec_time[c]; | 192 | for (c=0; c<executions;c++) |
198 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP /w optimization iterations %i: %llu \n", c, exec_time[c]); | 193 | { |
199 | } | 194 | start = GNUNET_TIME_absolute_get(); |
195 | //modify_qm(906, 0, 0); | ||
196 | solve_lp(GNUNET_NO); | ||
197 | solve_mlp (GNUNET_NO); | ||
198 | end = GNUNET_TIME_absolute_get(); | ||
199 | |||
200 | exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; | ||
201 | |||
202 | mlp_with_opt_avg += exec_time[c]; | ||
203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
204 | "MLP /w optimization iterations %i: %llu \n", | ||
205 | c, exec_time[c]); | ||
206 | } | ||
200 | 207 | ||
201 | glp_delete_prob(prob); | 208 | glp_delete_prob(prob); |
202 | } | 209 | } |
203 | 210 | ||
204 | #if 0 | 211 | #if 0 |
205 | void modify_cr (int start, int length, int count) | 212 | void modify_cr (int start, int length, int count) |
206 | { | 213 | { |
207 | //int * ind = GNUNET_malloc (length * sizeof (int)); | 214 | //int * ind = GNUNET_malloc (length * sizeof (int)); |
208 | //double *val = GNUNET_malloc (length * sizeof (double)); | 215 | //double *val = GNUNET_malloc (length * sizeof (double)); |
209 | int ind[500]; | 216 | int ind[500]; |
210 | double val[500]; | 217 | double val[500]; |
211 | int res = 0; | 218 | int res = 0; |
212 | int c = start, c2=1; | 219 | int c = start, c2=1; |
213 | while (c<=(start+count)) | 220 | while (c<=(start+count)) |
214 | { | 221 | { |
215 | res = glp_get_mat_row(prob, c, ind, val); | 222 | res = glp_get_mat_row(prob, c, ind, val); |
216 | 223 | ||
217 | printf("row index: %i non-zero elements: %i \n", c, res); | 224 | printf("row index: %i non-zero elements: %i \n", c, res); |
218 | for (c2=1; c2<=res; c2++) | 225 | for (c2=1; c2<=res; c2++) |
219 | { | 226 | { |
220 | printf("%i = %f ", ind[c2], val[c2]); | 227 | printf("%i = %f ", ind[c2], val[c2]); |
221 | } | 228 | } |
222 | c++; | 229 | c++; |
223 | printf ("\n----\n"); | 230 | printf ("\n----\n"); |
224 | } | 231 | } |
225 | //glp_set_mat_row(prob, start, length, ind, val); | 232 | //glp_set_mat_row(prob, start, length, ind, val); |
226 | } | 233 | } |
227 | #endif | 234 | #endif |
228 | #endif | 235 | #endif |