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",
#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, D, U, R, b_min, n_min);
+ mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
break;
#else
{
int res = GNUNET_OK;
int col;
+ int c;
+ char *name;
/* Set a problem name */
glp_set_prob_name (mlp->prob, "gnunet ats bandwidth distribution");
col = glp_add_cols(mlp->prob, mlp->m);
mlp->c_q_start = col;
mlp->c_q_end = col + mlp->m;
-
- mlp->co_Q = GNUNET_malloc (mlp->m * sizeof (double));
+ for (c = 0; c < mlp->m; c++)
+ {
+ GNUNET_asprintf (&name, "q_%u", mlp->q[c]);
+ glp_set_col_name (mlp->prob, col + c, name);
+ glp_set_col_bnds (mlp->prob, col + c, GLP_LO, 0.0, 0.0);
+ GNUNET_free (name);
+ glp_set_obj_coef (mlp->prob, col + c, mlp->co_Q[c]);
+ }
return res;
}
* @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,
+GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const struct GNUNET_STATISTICS_Handle *stats,
struct GNUNET_TIME_Relative max_duration,
- unsigned int max_iterations,
- double D, double U, double R,
- unsigned int b_min,
- unsigned int n_min)
+ unsigned int max_iterations)
{
struct GAS_MLP_Handle * mlp = GNUNET_malloc (sizeof (struct GAS_MLP_Handle));
+ double D;
+ double R;
+ double U;
+ long long unsigned int tmp;
+ unsigned int b_min;
+ unsigned int n_min;
+
/* Init GLPK environment */
GNUNET_assert (glp_init_env() == 0);
mlp->prob = glp_create_prob();
GNUNET_assert (mlp->prob != NULL);
+ /* 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 quality metric coefficients from configuration */
+ int i_delay = -1;
+ int i_distance = -1;
+ int q[GNUNET_ATS_QualityPropertiesCount] = GNUNET_ATS_QualityProperties;
+ int c;
+ for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
+ {
+ /* initialize quality coefficients with default value 1.0 */
+ mlp->co_Q[c] = 1.0;
+
+ mlp->q[c] = q[c];
+ if (q[c] == GNUNET_ATS_QUALITY_NET_DELAY)
+ i_delay = c;
+ if (q[c] == GNUNET_ATS_QUALITY_NET_DISTANCE)
+ i_distance = c;
+ }
+
+ if ((i_delay != -1) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
+ "COEFFICIENT_QUALITY_DELAY",
+ &tmp)))
+
+ mlp->co_Q[i_delay] = (double) tmp / 100;
+ else
+ mlp->co_Q[i_delay] = 1.0;
+
+ if ((i_distance != -1) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
+ "COEFFICIENT_QUALITY_DISTANCE",
+ &tmp)))
+ mlp->co_Q[i_distance] = (double) tmp / 100;
+ else
+ mlp->co_Q[i_distance] = 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;
+
mlp->stats = (struct GNUNET_STATISTICS_Handle *) stats;
mlp->max_iterations = max_iterations;
mlp->max_exec_duration = max_duration;
mlp->co_U = U;
mlp->b_min = b_min;
mlp->n_min = n_min;
+ mlp->m = GNUNET_ATS_QualityPropertiesCount;
mlp_create_problem (mlp);
return mlp;
if (mlp != NULL)
glp_delete_prob(mlp->prob);
- if (mlp->co_Q != NULL)
- GNUNET_free (mlp->co_Q);
-
/* Clean up GLPK environment */
glp_free_env();
int c_r;
double co_R;
+ /* ATS Quality metrics
+ * array with GNUNET_ATS_QualityPropertiesCount elements
+ * contains mapping to GNUNET_ATS_Property*/
+ int q[GNUNET_ATS_QualityPropertiesCount];
+
/* column index first quality metric (q_1) column */
int c_q_start;
/* column index last quality metric (q_n) column */
int c_q_end;
- /* Array of quality metric coefficients (m elements) */
- double *co_Q;
+ /* quality metric coefficients*/
+ double co_Q[GNUNET_ATS_QualityPropertiesCount];
/* number of quality metrics */
int m;
/**
* Init the MLP problem solving component
*
+ * @param cfg configuration handle
* @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,
+GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const struct GNUNET_STATISTICS_Handle *stats,
struct GNUNET_TIME_Relative max_duration,
- unsigned int max_iterations,
- double D, double U, double R,
- unsigned int b_min,
- unsigned int n_min);
+ unsigned int max_iterations);
/**