aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-01-16 15:05:45 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-01-16 15:05:45 +0000
commit733fd9a46618ac78fd4255fccec6a207e93c8f26 (patch)
tree47b0b2f86ecff0e3546d65df40154f717a812cb9 /src
parent8a112720529e9ec36e333ff73a7bfc5db791586e (diff)
downloadgnunet-733fd9a46618ac78fd4255fccec6a207e93c8f26.tar.gz
gnunet-733fd9a46618ac78fd4255fccec6a207e93c8f26.zip
- configuration for mlp coefficients
Diffstat (limited to 'src')
-rw-r--r--src/ats/gnunet-service-ats_addresses.c54
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c16
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.h16
3 files changed, 81 insertions, 5 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index 0e5f597ca..8693293d0 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -536,6 +536,55 @@ void
536GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, 536GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
537 const struct GNUNET_STATISTICS_Handle *stats) 537 const struct GNUNET_STATISTICS_Handle *stats)
538{ 538{
539#if HAVE_LIBGLPK
540 double D;
541 double R;
542 double U;
543 long long unsigned int tmp;
544 unsigned int b_min;
545 unsigned int n_min;
546
547 /* Get diversity coefficient from configuration */
548 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
549 "COEFFICIENT_D",
550 &tmp))
551 D = (double) tmp / 100;
552 else
553 D = 1.0;
554
555 /* Get proportionality coefficient from configuration */
556 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
557 "COEFFICIENT_R",
558 &tmp))
559 R = (double) tmp / 100;
560 else
561 R = 1.0;
562
563 /* Get utilization coefficient from configuration */
564 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
565 "COEFFICIENT_U",
566 &tmp))
567 U = (double) tmp / 100;
568 else
569 U = 1.0;
570
571 /* Get minimum bandwidth per used address from configuration */
572 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
573 "MIN_BANDWIDTH",
574 &tmp))
575 b_min = tmp;
576 else
577 b_min = 64000;
578
579 /* Get minimum number of connections from configuration */
580 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
581 "MIN_CONNECTIONS",
582 &tmp))
583 n_min = tmp;
584 else
585 n_min = 4;
586#endif
587
539 GNUNET_assert (GNUNET_OK == 588 GNUNET_assert (GNUNET_OK ==
540 GNUNET_CONFIGURATION_get_value_size (cfg, "ats", 589 GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
541 "WAN_QUOTA_IN", 590 "WAN_QUOTA_IN",
@@ -545,8 +594,6 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
545 "WAN_QUOTA_OUT", 594 "WAN_QUOTA_OUT",
546 &wan_quota_out)); 595 &wan_quota_out));
547 596
548
549
550 switch (GNUNET_CONFIGURATION_get_value_yesno (cfg, "ats", "MLP")) 597 switch (GNUNET_CONFIGURATION_get_value_yesno (cfg, "ats", "MLP"))
551 { 598 {
552 /* MLP = YES */ 599 /* MLP = YES */
@@ -554,9 +601,10 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
554#if HAVE_LIBGLPK 601#if HAVE_LIBGLPK
555 ats_mode = MLP; 602 ats_mode = MLP;
556 /* Init the MLP solver with default values */ 603 /* Init the MLP solver with default values */
557 mlp = GAS_mlp_init (stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); 604 mlp = GAS_mlp_init (stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS, D, U, R, b_min, n_min);
558 break; 605 break;
559#else 606#else
607
560 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but libglpk is not installed, switching to simple mode"); 608 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but libglpk is not installed, switching to simple mode");
561 ats_mode = SIMPLE; 609 ats_mode = SIMPLE;
562 break; 610 break;
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c
index 7277355ac..785cb736b 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.c
+++ b/src/ats/gnunet-service-ats_addresses_mlp.c
@@ -285,12 +285,21 @@ mlp_solve_problem (struct GAS_MLP_Handle *mlp)
285 * @param stats the GNUNET_STATISTICS handle 285 * @param stats the GNUNET_STATISTICS handle
286 * @param max_duration maximum numbers of iterations for the LP/MLP Solver 286 * @param max_duration maximum numbers of iterations for the LP/MLP Solver
287 * @param max_iterations maximum time limit for the LP/MLP Solver 287 * @param max_iterations maximum time limit for the LP/MLP Solver
288 * @param D Diversity coefficient
289 * @param U Utilization coefficient
290 * @param R Proportionality coefficient
291 * @param b_min minimum bandwidth assigned to an address
292 * @param n_min minimum number of addresses with bandwidth assigned
293 *
288 * @return struct GAS_MLP_Handle * on success, NULL on fail 294 * @return struct GAS_MLP_Handle * on success, NULL on fail
289 */ 295 */
290struct GAS_MLP_Handle * 296struct GAS_MLP_Handle *
291GAS_mlp_init (const struct GNUNET_STATISTICS_Handle *stats, 297GAS_mlp_init (const struct GNUNET_STATISTICS_Handle *stats,
292 struct GNUNET_TIME_Relative max_duration, 298 struct GNUNET_TIME_Relative max_duration,
293 unsigned int max_iterations) 299 unsigned int max_iterations,
300 double D, double U, double R,
301 unsigned int b_min,
302 unsigned int n_min)
294{ 303{
295 struct GAS_MLP_Handle * mlp = GNUNET_malloc (sizeof (struct GAS_MLP_Handle)); 304 struct GAS_MLP_Handle * mlp = GNUNET_malloc (sizeof (struct GAS_MLP_Handle));
296 305
@@ -326,6 +335,11 @@ GAS_mlp_init (const struct GNUNET_STATISTICS_Handle *stats,
326 335
327 mlp->last_execution = GNUNET_TIME_absolute_get_forever(); 336 mlp->last_execution = GNUNET_TIME_absolute_get_forever();
328 337
338 mlp->co_D = D;
339 mlp->co_R = R;
340 mlp->co_U = U;
341 mlp->b_min = b_min;
342 mlp->n_min = n_min;
329 343
330 mlp_create_problem (mlp); 344 mlp_create_problem (mlp);
331 return mlp; 345 return mlp;
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h
index 1a478cd00..e604919be 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.h
+++ b/src/ats/gnunet-service-ats_addresses_mlp.h
@@ -148,6 +148,11 @@ struct GAS_MLP_Handle
148 /* number of quality metrics */ 148 /* number of quality metrics */
149 int m; 149 int m;
150 150
151 /* minimum bandwidth assigned to an address */
152 unsigned int b_min;
153
154 /* minimum number of addresses with bandwidth assigned */
155 unsigned int n_min;
151}; 156};
152 157
153 158
@@ -170,12 +175,21 @@ struct MLP_information
170 * @param stats the GNUNET_STATISTICS handle 175 * @param stats the GNUNET_STATISTICS handle
171 * @param max_duration maximum numbers of iterations for the LP/MLP Solver 176 * @param max_duration maximum numbers of iterations for the LP/MLP Solver
172 * @param max_iterations maximum time limit for the LP/MLP Solver 177 * @param max_iterations maximum time limit for the LP/MLP Solver
178 * @param D Diversity coefficient
179 * @param U Utilization coefficient
180 * @param R Proportionality coefficient
181 * @param b_min minimum bandwidth assigned to an address
182 * @param n_min minimum number of addresses with bandwidth assigned
183 *
173 * @return struct GAS_MLP_Handle * on success, NULL on fail 184 * @return struct GAS_MLP_Handle * on success, NULL on fail
174 */ 185 */
175struct GAS_MLP_Handle * 186struct GAS_MLP_Handle *
176GAS_mlp_init (const struct GNUNET_STATISTICS_Handle *stats, 187GAS_mlp_init (const struct GNUNET_STATISTICS_Handle *stats,
177 struct GNUNET_TIME_Relative max_duration, 188 struct GNUNET_TIME_Relative max_duration,
178 unsigned int max_iterations); 189 unsigned int max_iterations,
190 double D, double U, double R,
191 unsigned int b_min,
192 unsigned int n_min);
179 193
180 194
181/** 195/**