aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-01-13 16:12:56 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-01-13 16:12:56 +0000
commitd318e7403926cdf6f672c493be043ef923ada719 (patch)
treebb409e34bf126fe7850282af53e06623660a061a
parent6e19faa688d79c28b21d2e7382019148421dabf5 (diff)
downloadgnunet-d318e7403926cdf6f672c493be043ef923ada719.tar.gz
gnunet-d318e7403926cdf6f672c493be043ef923ada719.zip
- more ats
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c50
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.h6
2 files changed, 56 insertions, 0 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c
index ca192b8a4..41e96649d 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.c
+++ b/src/ats/gnunet-service-ats_addresses_mlp.c
@@ -144,6 +144,7 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp)
144 144
145 /* solve MLP problem */ 145 /* solve MLP problem */
146 res = glp_intopt(mlp->prob, &mlp->control_param_mlp); 146 res = glp_intopt(mlp->prob, &mlp->control_param_mlp);
147
147 if (res == 0) 148 if (res == 0)
148 { 149 {
149 /* The MLP problem instance has been successfully solved. */ 150 /* The MLP problem instance has been successfully solved. */
@@ -199,6 +200,21 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp)
199} 200}
200 201
201/** 202/**
203 * Solves the MLP problem
204 * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
205 */
206int
207mlp_solve_problem (struct GAS_MLP_Handle *mlp)
208{
209 int res;
210 mlp->last_execution = GNUNET_TIME_absolute_get ();
211 res = mlp_solve_lp_problem (mlp);
212 if (res == GNUNET_OK)
213 res = mlp_solve_mlp_problem (mlp);
214 return res;
215}
216
217/**
202 * Init the MLP problem solving component 218 * Init the MLP problem solving component
203 * 219 *
204 * @param stats the GNUNET_STATISTICS handle 220 * @param stats the GNUNET_STATISTICS handle
@@ -243,6 +259,7 @@ GAS_mlp_init (const struct GNUNET_STATISTICS_Handle *stats,
243#endif 259#endif
244 GAS_mlp->control_param_mlp.tm_lim = max_duration.rel_value; 260 GAS_mlp->control_param_mlp.tm_lim = max_duration.rel_value;
245 261
262 GAS_mlp->last_execution = GNUNET_TIME_absolute_get_forever();
246 return GNUNET_OK; 263 return GNUNET_OK;
247} 264}
248 265
@@ -258,7 +275,25 @@ GAS_mlp_init (const struct GNUNET_STATISTICS_Handle *stats,
258void 275void
259GAS_mlp_address_update (struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address) 276GAS_mlp_address_update (struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address)
260{ 277{
278 int new;
279
280 GNUNET_STATISTICS_update (GAS_mlp->stats,"# LP address updates", 1, GNUNET_NO);
261 281
282 /* We update a new address */
283 if (address->mlp_information == NULL)
284 {
285 new = GNUNET_YES;
286 address->mlp_information = GNUNET_malloc (sizeof (struct MLP_information));
287 }
288 else
289 new = GNUNET_NO;
290
291 /* Do the update */
292
293 /* Recalculate */
294 if (new == GNUNET_YES)
295 GAS_mlp->presolver_required = GNUNET_YES;
296 mlp_solve_problem (GAS_mlp);
262} 297}
263 298
264/** 299/**
@@ -269,7 +304,20 @@ GAS_mlp_address_update (struct GNUNET_CONTAINER_MultiHashMap * addresses, struct
269void 304void
270GAS_mlp_address_delete (struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address) 305GAS_mlp_address_delete (struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address)
271{ 306{
307 GNUNET_STATISTICS_update (GAS_mlp->stats,"# LP address deletions", 1, GNUNET_NO);
272 308
309 /* Free resources */
310 if (address->mlp_information != NULL)
311 {
312 GNUNET_free (address->mlp_information);
313 address->mlp_information = NULL;
314 }
315
316 /* Update problem */
317
318 /* Recalculate */
319 GAS_mlp->presolver_required = GNUNET_YES;
320 mlp_solve_problem (GAS_mlp);
273} 321}
274 322
275/** 323/**
@@ -278,6 +326,8 @@ GAS_mlp_address_delete (struct GNUNET_CONTAINER_MultiHashMap * addresses, struct
278void 326void
279GAS_mlp_address_change_preference (struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address) 327GAS_mlp_address_change_preference (struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address)
280{ 328{
329 GNUNET_STATISTICS_update (GAS_mlp->stats,"# LP address preference changes", 1, GNUNET_NO);
330
281 331
282} 332}
283 333
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h
index 28cffdf36..6f7ee73d5 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.h
+++ b/src/ats/gnunet-service-ats_addresses_mlp.h
@@ -96,6 +96,12 @@ struct GAS_MLP_Handle
96 /* statistics */ 96 /* statistics */
97 97
98 /** 98 /**
99 * Time of last execution
100 */
101 struct GNUNET_TIME_Absolute last_execution;
102
103
104 /**
99 * How often was the LP problem solved 105 * How often was the LP problem solved
100 */ 106 */
101 unsigned int lp_solved; 107 unsigned int lp_solved;