From: Matthias Wachs Date: Mon, 16 Jan 2012 15:05:45 +0000 (+0000) Subject: - configuration for mlp coefficients X-Git-Tag: initial-import-from-subversion-38251~15285 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=733fd9a46618ac78fd4255fccec6a207e93c8f26;p=oweals%2Fgnunet.git - configuration for mlp coefficients --- 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 GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_STATISTICS_Handle *stats) { +#if HAVE_LIBGLPK + double D; + double R; + double U; + long long unsigned int tmp; + unsigned int b_min; + unsigned int n_min; + + /* Get diversity coefficient from configuration */ + if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", + "COEFFICIENT_D", + &tmp)) + D = (double) tmp / 100; + else + D = 1.0; + + /* Get proportionality coefficient from configuration */ + if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", + "COEFFICIENT_R", + &tmp)) + R = (double) tmp / 100; + else + R = 1.0; + + /* Get utilization coefficient from configuration */ + if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", + "COEFFICIENT_U", + &tmp)) + U = (double) tmp / 100; + else + U = 1.0; + + /* Get minimum bandwidth per used address from configuration */ + if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", + "MIN_BANDWIDTH", + &tmp)) + b_min = tmp; + else + b_min = 64000; + + /* Get minimum number of connections from configuration */ + if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", + "MIN_CONNECTIONS", + &tmp)) + n_min = tmp; + else + n_min = 4; +#endif + GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", "WAN_QUOTA_IN", @@ -545,8 +594,6 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, "WAN_QUOTA_OUT", &wan_quota_out)); - - switch (GNUNET_CONFIGURATION_get_value_yesno (cfg, "ats", "MLP")) { /* MLP = YES */ @@ -554,9 +601,10 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, #if HAVE_LIBGLPK ats_mode = MLP; /* Init the MLP solver with default values */ - mlp = GAS_mlp_init (stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); + mlp = GAS_mlp_init (stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS, D, U, R, b_min, n_min); break; #else + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but libglpk is not installed, switching to simple mode"); ats_mode = SIMPLE; 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) * @param stats the GNUNET_STATISTICS handle * @param max_duration maximum numbers of iterations for the LP/MLP Solver * @param max_iterations maximum time limit for the LP/MLP Solver + * @param D Diversity coefficient + * @param U Utilization coefficient + * @param R Proportionality coefficient + * @param b_min minimum bandwidth assigned to an address + * @param n_min minimum number of addresses with bandwidth assigned + * * @return struct GAS_MLP_Handle * on success, NULL on fail */ struct GAS_MLP_Handle * GAS_mlp_init (const struct GNUNET_STATISTICS_Handle *stats, struct GNUNET_TIME_Relative max_duration, - unsigned int max_iterations) + unsigned int max_iterations, + double D, double U, double R, + unsigned int b_min, + unsigned int n_min) { struct GAS_MLP_Handle * mlp = GNUNET_malloc (sizeof (struct GAS_MLP_Handle)); @@ -326,6 +335,11 @@ GAS_mlp_init (const struct GNUNET_STATISTICS_Handle *stats, mlp->last_execution = GNUNET_TIME_absolute_get_forever(); + mlp->co_D = D; + mlp->co_R = R; + mlp->co_U = U; + mlp->b_min = b_min; + mlp->n_min = n_min; mlp_create_problem (mlp); 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 /* number of quality metrics */ int m; + /* minimum bandwidth assigned to an address */ + unsigned int b_min; + + /* minimum number of addresses with bandwidth assigned */ + unsigned int n_min; }; @@ -170,12 +175,21 @@ struct MLP_information * @param stats the GNUNET_STATISTICS handle * @param max_duration maximum numbers of iterations for the LP/MLP Solver * @param max_iterations maximum time limit for the LP/MLP Solver + * @param D Diversity coefficient + * @param U Utilization coefficient + * @param R Proportionality coefficient + * @param b_min minimum bandwidth assigned to an address + * @param n_min minimum number of addresses with bandwidth assigned + * * @return struct GAS_MLP_Handle * on success, NULL on fail */ struct GAS_MLP_Handle * GAS_mlp_init (const struct GNUNET_STATISTICS_Handle *stats, struct GNUNET_TIME_Relative max_duration, - unsigned int max_iterations); + unsigned int max_iterations, + double D, double U, double R, + unsigned int b_min, + unsigned int n_min); /**