[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r26172 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r26172 - gnunet/src/ats |
Date: |
Thu, 21 Feb 2013 11:51:49 +0100 |
Author: wachs
Date: 2013-02-21 11:51:49 +0100 (Thu, 21 Feb 2013)
New Revision: 26172
Modified:
gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
gnunet/src/ats/perf_ats_mlp.c
gnunet/src/ats/test_ats_mlp.c
gnunet/src/ats/test_ats_mlp_averaging.c
Log:
clean up of MLP_Handle
Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2013-02-20 18:02:38 UTC
(rev 26171)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2013-02-21 10:51:49 UTC
(rev 26172)
@@ -136,7 +136,7 @@
#define LOG(kind,...) GNUNET_log_from (kind, "ats-mlp",__VA_ARGS__)
#define WRITE_MLP GNUNET_NO
-#define DEBUG_ATS GNUNET_NO
+#define DEBUG_MLP_PROBLEM_CREATION GNUNET_YES
#define VERBOSE_GLPK GNUNET_NO
/**
@@ -166,31 +166,31 @@
{
if (mlp != NULL)
{
- if (mlp->prob != NULL)
- glp_delete_prob(mlp->prob);
+ if (mlp->p.prob != NULL)
+ glp_delete_prob(mlp->p.prob);
/* delete row index */
- if (mlp->ia != NULL)
+ if (mlp->p.ia != NULL)
{
- GNUNET_free (mlp->ia);
- mlp->ia = NULL;
+ GNUNET_free (mlp->p.ia);
+ mlp->p.ia = NULL;
}
/* delete column index */
- if (mlp->ja != NULL)
+ if (mlp->p.ja != NULL)
{
- GNUNET_free (mlp->ja);
- mlp->ja = NULL;
+ GNUNET_free (mlp->p.ja);
+ mlp->p.ja = NULL;
}
/* delete coefficients */
- if (mlp->ar != NULL)
+ if (mlp->p.ar != NULL)
{
- GNUNET_free (mlp->ar);
- mlp->ar = NULL;
+ GNUNET_free (mlp->p.ar);
+ mlp->p.ar = NULL;
}
- mlp->ci = 0;
- mlp->prob = NULL;
+ mlp->p.ci = 0;
+ mlp->p.prob = NULL;
}
}
@@ -549,7 +549,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduled problem solving\n");
- if (mlp->addr_in_problem != 0)
+ if (mlp->addresses_in_problem != 0)
GAS_mlp_solve_problem(mlp, &ctx);
}
@@ -733,6 +733,7 @@
create_constraint_it (void *cls, const struct GNUNET_HashCode * key, void
*value)
{
struct GAS_MLP_Handle *mlp = cls;
+ struct MLP_Problem *p = &mlp->p;
struct ATS_Address *address = value;
struct MLP_information *mlpi;
unsigned int row_index;
@@ -744,62 +745,62 @@
/* c 1) bandwidth capping
* b_t + (-M) * n_t <= 0
*/
- row_index = glp_add_rows (mlp->prob, 1);
+ row_index = glp_add_rows (p->prob, 1);
mlpi->r_c1 = row_index;
/* set row name */
GNUNET_asprintf(&name, "c1_%s_%s", GNUNET_i2s(&address->peer),
address->plugin);
- glp_set_row_name (mlp->prob, row_index, name);
+ glp_set_row_name (p->prob, row_index, name);
GNUNET_free (name);
/* set row bounds: <= 0 */
- glp_set_row_bnds (mlp->prob, row_index, GLP_UP, 0.0, 0.0);
- mlp->ia[mlp->ci] = row_index;
- mlp->ja[mlp->ci] = mlpi->c_b;
- mlp->ar[mlp->ci] = 1;
- mlp->ci++;
+ glp_set_row_bnds (p->prob, row_index, GLP_UP, 0.0, 0.0);
+ p->ia[p->ci] = row_index;
+ p->ja[p->ci] = mlpi->c_b;
+ p->ar[p->ci] = 1;
+ p->ci++;
- mlp->ia[mlp->ci] = row_index;
- mlp->ja[mlp->ci] = mlpi->c_n;
- mlp->ar[mlp->ci] = -mlp->BIG_M;
- mlp->ci++;
+ p->ia[p->ci] = row_index;
+ p->ja[p->ci] = mlpi->c_n;
+ p->ar[p->ci] = -mlp->BIG_M;
+ p->ci++;
/* c 3) minimum bandwidth
* b_t + (-n_t * b_min) >= 0
*/
- row_index = glp_add_rows (mlp->prob, 1);
+ row_index = glp_add_rows (p->prob, 1);
/* set row name */
GNUNET_asprintf(&name, "c3_%s_%s", GNUNET_i2s(&address->peer),
address->plugin);
- glp_set_row_name (mlp->prob, row_index, name);
+ glp_set_row_name (p->prob, row_index, name);
GNUNET_free (name);
mlpi->r_c3 = row_index;
/* set row bounds: >= 0 */
- glp_set_row_bnds (mlp->prob, row_index, GLP_LO, 0.0, 0.0);
+ glp_set_row_bnds (p->prob, row_index, GLP_LO, 0.0, 0.0);
- mlp->ia[mlp->ci] = row_index;
- mlp->ja[mlp->ci] = mlpi->c_b;
- mlp->ar[mlp->ci] = 1;
- mlp->ci++;
+ p->ia[p->ci] = row_index;
+ p->ja[p->ci] = mlpi->c_b;
+ p->ar[p->ci] = 1;
+ p->ci++;
- mlp->ia[mlp->ci] = row_index;
- mlp->ja[mlp->ci] = mlpi->c_n;
- mlp->ar[mlp->ci] = - (double) mlp->b_min;
- mlp->ci++;
+ p->ia[p->ci] = row_index;
+ p->ja[p->ci] = mlpi->c_n;
+ p->ar[p->ci] = - (double) mlp->pv.b_min;
+ p->ci++;
/* c 4) minimum connections
* (1)*n_1 + ... + (1)*n_m >= n_min
*/
- mlp->ia[mlp->ci] = mlp->r_c4;
- mlp->ja[mlp->ci] = mlpi->c_n;
- mlp->ar[mlp->ci] = 1;
- mlp->ci++;
+ p->ia[p->ci] = p->r_c4;
+ p->ja[p->ci] = mlpi->c_n;
+ p->ar[p->ci] = 1;
+ p->ci++;
/* c 6) maximize diversity
* (1)*n_1 + ... + (1)*n_m - d == 0
*/
- mlp->ia[mlp->ci] = mlp->r_c6;
- mlp->ja[mlp->ci] = mlpi->c_n;
- mlp->ar[mlp->ci] = 1;
- mlp->ci++;
+ p->ia[p->ci] = p->r_c6;
+ p->ja[p->ci] = mlpi->c_n;
+ p->ar[p->ci] = 1;
+ p->ci++;
/* c 10) obey network specific quotas
* (1)*b_1 + ... + (1)*b_m <= quota_n
@@ -809,19 +810,19 @@
int c;
for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
{
- if (mlp->quota_index[c] == address->atsp_network_type)
+ if (mlp->pv.quota_index[c] == address->atsp_network_type)
{
- cur_row = mlp->r_quota[c];
+ cur_row = p->r_quota[c];
break;
}
}
if (cur_row != 0)
{
- mlp->ia[mlp->ci] = cur_row;
- mlp->ja[mlp->ci] = mlpi->c_b;
- mlp->ar[mlp->ci] = 1;
- mlp->ci++;
+ p->ia[p->ci] = cur_row;
+ p->ja[p->ci] = mlpi->c_b;
+ p->ar[p->ci] = 1;
+ p->ci++;
}
else
{
@@ -844,11 +845,12 @@
mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct
GNUNET_CONTAINER_MultiHashMap * addresses)
{
unsigned int n_addresses;
+ struct MLP_Problem *p = &mlp->p;
int c;
char *name;
/* Problem matrix*/
- n_addresses = GNUNET_CONTAINER_multihashmap_size(addresses);
+ n_addresses = p->addresses_in_problem;
/* Required indices in the constrain matrix
*
@@ -902,21 +904,21 @@
* */
/* last +1 caused by glpk index starting with one: [1..pi]*/
- int pi = ((7 * n_addresses) + (5 * n_addresses + mlp->m_q + mlp->c_p + 2) +
1);
+ int pi = ((7 * n_addresses) + (5 * n_addresses + mlp->pv.m_q + mlp->c_p +
2) + 1);
mlp->cm_size = pi;
- mlp->ci = 1;
+ p->ci = 1;
/* row index */
int *ia = GNUNET_malloc (pi * sizeof (int));
- mlp->ia = ia;
+ p->ia = ia;
/* column index */
int *ja = GNUNET_malloc (pi * sizeof (int));
- mlp->ja = ja;
+ p->ja = ja;
/* coefficient */
double *ar= GNUNET_malloc (pi * sizeof (double));
- mlp->ar = ar;
+ p->ar = ar;
/* Adding constraint rows
* This constraints are kind of "for all addresses"
@@ -930,39 +932,60 @@
*/
/* Row for c4) minimum connection */
- int min = mlp->n_min;
+ name = "c4";
+ int min = mlp->pv.n_min;
/* Number of minimum connections is min(|Peers|, n_min) */
- if (mlp->n_min > mlp->c_p)
+ if (mlp->pv.n_min > mlp->c_p)
min = mlp->c_p;
+ p->r_c4 = glp_add_rows (p->prob, 1);
+ glp_set_row_name (p->prob, p->r_c4, name);
+ glp_set_row_bnds (p->prob, p->r_c4, GLP_LO, min, min);
+#if DEBUG_MLP_PROBLEM_CREATION
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added row [%u] `%s': %s %u\n",
+ p->r_c4, name,
+ ">=", min);
+#endif
- mlp->r_c4 = glp_add_rows (mlp->prob, 1);
- glp_set_row_name (mlp->prob, mlp->r_c4, "c4");
- glp_set_row_bnds (mlp->prob, mlp->r_c4, GLP_LO, min, min);
-
/* Add row for c6) */
-
- mlp->r_c6 = glp_add_rows (mlp->prob, 1);
+ name = "c6";
+ p->r_c6 = glp_add_rows (p->prob, 1);
/* Set type type to fix */
- glp_set_row_bnds (mlp->prob, mlp->r_c6, GLP_FX, 0.0, 0.0);
+ glp_set_row_name (p->prob, p->r_c6, name);
+ glp_set_row_bnds (p->prob, p->r_c6, GLP_FX, 0.0, 0.0);
+#if DEBUG_MLP_PROBLEM_CREATION
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added row [%u] `%s': %s %u\n",
+ p->r_c6, name,
+ "==", 0);
+#endif
/* Setting -D */
- ia[mlp->ci] = mlp->r_c6 ;
- ja[mlp->ci] = mlp->c_d;
- ar[mlp->ci] = -1;
- mlp->ci++;
+ ia[p->ci] = p->r_c6 ;
+ ja[p->ci] = p->c_d;
+ ar[p->ci] = -1;
+ p->ci++;
+#if DEBUG_MLP_PROBLEM_CREATION
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Set value [%u,%u] == %.2f\n",
+ ia[p->ci], ja[p->ci], ar[p->ci]);
+#endif
+
/* Add rows for c 10) */
for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
{
- mlp->r_quota[c] = glp_add_rows (mlp->prob, 1);
+ p->r_quota[c] = glp_add_rows (p->prob, 1);
char * text;
- GNUNET_asprintf(&text, "quota_ats_%i", mlp->quota_index[c]);
- glp_set_row_name (mlp->prob, mlp->r_quota[c], text);
+ GNUNET_asprintf(&text, "quota_ats_%i", mlp->pv.quota_index[c]);
+ glp_set_row_name (p->prob, p->r_quota[c], text);
+ /* Set bounds to 0 <= x <= quota_out */
+ glp_set_row_bnds (p->prob, p->r_quota[c], GLP_UP, 0.0,
mlp->pv.quota_out[c]);
+#if DEBUG_MLP_PROBLEM_CREATION
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added row [%u] `%s': %s
%u\n",
+ p->r_quota[c], name,
+ "<=", mlp->pv.quota_out[c]);
+#endif
GNUNET_free (text);
- /* Set bounds to 0 <= x <= quota_out */
- glp_set_row_bnds (mlp->prob, mlp->r_quota[c], GLP_UP, 0.0,
mlp->quota_out[c]);
}
- GNUNET_CONTAINER_multihashmap_iterate (addresses, create_constraint_it, mlp);
+ //GNUNET_CONTAINER_multihashmap_iterate (addresses, create_constraint_it,
mlp);
/* Adding constraint rows
* This constraints are kind of "for all peers"
@@ -979,17 +1002,27 @@
* */
/* Adding rows for c 8) */
- mlp->r_c8 = glp_add_rows (mlp->prob, mlp->c_p);
- glp_set_row_name (mlp->prob, mlp->r_c8, "c8");
+ p->r_c8 = glp_add_rows (p->prob, mlp->c_p);
+ name = "c8";
+ glp_set_row_name (p->prob, p->r_c8, "c8");
/* Set row bound == 0 */
- glp_set_row_bnds (mlp->prob, mlp->r_c8, GLP_FX, 0.0, 0.0);
+ glp_set_row_bnds (p->prob, p->r_c8, GLP_FX, 0.0, 0.0);
+#if DEBUG_MLP_PROBLEM_CREATION
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added row [%u] `%s': %s
%u\n",
+ p->r_c8, name,
+ "==", 0);
+#endif
+
/* -u */
+ ia[p->ci] = p->r_c8;
+ ja[p->ci] = p->c_u;
+ ar[p->ci] = -1;
+ p->ci++;
+#if DEBUG_MLP_PROBLEM_CREATION
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Set value [%u,%u] == %.2f\n",
+ ia[p->ci], ja[p->ci], ar[p->ci]);
+#endif
- ia[mlp->ci] = mlp->r_c8;
- ja[mlp->ci] = mlp->c_u;
- ar[mlp->ci] = -1;
- mlp->ci++;
-
struct ATS_Peer * peer = mlp->peer_head;
/* For all peers */
while (peer != NULL)
@@ -998,26 +1031,26 @@
struct MLP_information *mlpi = NULL;
/* Adding rows for c 2) */
- peer->r_c2 = glp_add_rows (mlp->prob, 1);
+ peer->r_c2 = glp_add_rows (p->prob, 1);
GNUNET_asprintf(&name, "c2_%s", GNUNET_i2s(&peer->id));
- glp_set_row_name (mlp->prob, peer->r_c2, name);
+ glp_set_row_name (p->prob, peer->r_c2, name);
GNUNET_free (name);
/* Set row bound == 1 */
- glp_set_row_bnds (mlp->prob, peer->r_c2, GLP_FX, 1.0, 1.0);
+ glp_set_row_bnds (p->prob, peer->r_c2, GLP_FX, 1.0, 1.0);
/* Adding rows for c 9) */
- peer->r_c9 = glp_add_rows (mlp->prob, 1);
+ peer->r_c9 = glp_add_rows (p->prob, 1);
GNUNET_asprintf(&name, "c9_%s", GNUNET_i2s(&peer->id));
- glp_set_row_name (mlp->prob, peer->r_c9, name);
+ glp_set_row_name (p->prob, peer->r_c9, name);
GNUNET_free (name);
/* Set row bound == 0 */
- glp_set_row_bnds (mlp->prob, peer->r_c9, GLP_LO, 0.0, 0.0);
+ glp_set_row_bnds (p->prob, peer->r_c9, GLP_LO, 0.0, 0.0);
/* Set -r */
- ia[mlp->ci] = peer->r_c9;
- ja[mlp->ci] = mlp->c_r;
- ar[mlp->ci] = -peer->f;
- mlp->ci++;
+ ia[p->ci] = peer->r_c9;
+ ja[p->ci] = p->c_r;
+ ar[p->ci] = -peer->f;
+ p->ci++;
/* For all addresses of this peer */
while (addr != NULL)
@@ -1025,23 +1058,23 @@
mlpi = (struct MLP_information *) addr->solver_information;
/* coefficient for c 2) */
- ia[mlp->ci] = peer->r_c2;
- ja[mlp->ci] = mlpi->c_n;
- ar[mlp->ci] = 1;
- mlp->ci++;
+ ia[p->ci] = peer->r_c2;
+ ja[p->ci] = mlpi->c_n;
+ ar[p->ci] = 1;
+ p->ci++;
/* coefficient for c 8) */
- ia[mlp->ci] = mlp->r_c8;
- ja[mlp->ci] = mlpi->c_b;
- ar[mlp->ci] = peer->f;
- mlp->ci++;
+ ia[p->ci] = p->r_c8;
+ ja[p->ci] = mlpi->c_b;
+ ar[p->ci] = peer->f;
+ p->ci++;
#if ENABLE_C9
/* coefficient for c 9) */
- ia[mlp->ci] = peer->r_c9;
- ja[mlp->ci] = mlpi->c_b;
- ar[mlp->ci] = 1;
- mlp->ci++;
+ ia[p->ci] = peer->r_c9;
+ ja[p->ci] = mlpi->c_b;
+ ar[p->ci] = 1;
+ p->ci++;
#endif
addr = addr->next;
@@ -1050,7 +1083,7 @@
}
/* c 7) For all quality metrics */
- for (c = 0; c < mlp->m_q; c++)
+ for (c = 0; c < mlp->pv.m_q; c++)
{
struct ATS_Peer *tp;
struct ATS_Address *ta;
@@ -1058,17 +1091,17 @@
double value = 1.0;
/* Adding rows for c 7) */
- mlp->r_q[c] = glp_add_rows (mlp->prob, 1);
- GNUNET_asprintf(&name, "c7_q%i_%s", c, mlp_ats_to_string(mlp->q[c]));
- glp_set_row_name (mlp->prob, mlp->r_q[c], name);
+ p->r_q[c] = glp_add_rows (p->prob, 1);
+ GNUNET_asprintf(&name, "c7_q%i_%s", c, mlp_ats_to_string(mlp->pv.q[c]));
+ glp_set_row_name (p->prob, p->r_q[c], name);
GNUNET_free (name);
/* Set row bound == 0 */
- glp_set_row_bnds (mlp->prob, mlp->r_q[c], GLP_FX, 0.0, 0.0);
+ glp_set_row_bnds (p->prob, p->r_q[c], GLP_FX, 0.0, 0.0);
- ia[mlp->ci] = mlp->r_q[c];
- ja[mlp->ci] = mlp->c_q[c];
- ar[mlp->ci] = -1;
- mlp->ci++;
+ ia[p->ci] = p->r_q[c];
+ ja[p->ci] = p->c_q[c];
+ ar[p->ci] = -1;
+ p->ci++;
for (tp = mlp->peer_head; tp != NULL; tp = tp->next)
for (ta = tp->head; ta != NULL; ta = ta->next)
@@ -1076,12 +1109,12 @@
mlpi = ta->solver_information;
value = mlpi->q_averaged[c];
- mlpi->r_q[c] = mlp->r_q[c];
+ mlpi->r_q[c] = p->r_q[c];
- ia[mlp->ci] = mlp->r_q[c];
- ja[mlp->ci] = mlpi->c_b;
- ar[mlp->ci] = tp->f_q[c] * value;
- mlp->ci++;
+ ia[p->ci] = p->r_q[c];
+ ja[p->ci] = mlpi->c_b;
+ ar[p->ci] = tp->f_q[c] * value;
+ p->ci++;
}
}
}
@@ -1100,6 +1133,7 @@
mlp_create_address_columns_it (void *cls, const struct GNUNET_HashCode * key,
void *value)
{
struct GAS_MLP_Handle *mlp = cls;
+ struct MLP_Problem *p = &mlp->p;
struct ATS_Address *address = value;
struct MLP_information *mlpi;
unsigned int col;
@@ -1115,39 +1149,44 @@
if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(mlp->peers, key))
return GNUNET_OK;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding column for peer %s address %p\n",
- GNUNET_i2s(&address->peer), address);
-
+ p->addresses_in_problem ++;
mlpi = GNUNET_malloc (sizeof (struct MLP_information));
address->solver_information = mlpi;
/* Add bandwidth column */
- col = glp_add_cols (mlp->prob, 2);
+ col = glp_add_cols (p->prob, 2);
mlpi->c_b = col;
mlpi->c_n = col + 1;
GNUNET_asprintf (&name, "b_%s_%s", GNUNET_i2s (&address->peer),
address->plugin);
- glp_set_col_name (mlp->prob, mlpi->c_b , name);
- GNUNET_free (name);
+ glp_set_col_name (p->prob, mlpi->c_b , name);
/* Lower bound == 0 */
- glp_set_col_bnds (mlp->prob, mlpi->c_b , GLP_LO, 0.0, 0.0);
+ glp_set_col_bnds (p->prob, mlpi->c_b , GLP_LO, 0.0, 0.0);
/* Continuous value*/
- glp_set_col_kind (mlp->prob, mlpi->c_b , GLP_CV);
+ glp_set_col_kind (p->prob, mlpi->c_b , GLP_CV);
/* Objective function coefficient == 0 */
- glp_set_obj_coef (mlp->prob, mlpi->c_b , 0);
+ glp_set_obj_coef (p->prob, mlpi->c_b , 0);
+#if DEBUG_MLP_PROBLEM_CREATION
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%u] `%s': `%s'
address %p\n",
+ mlpi->c_b, name, GNUNET_i2s(&address->peer), address);
+#endif
+ GNUNET_free (name);
-
/* Add usage column */
GNUNET_asprintf (&name, "n_%s_%s", GNUNET_i2s (&address->peer),
address->plugin);
- glp_set_col_name (mlp->prob, mlpi->c_n, name);
- GNUNET_free (name);
+ glp_set_col_name (p->prob, mlpi->c_n, name);
/* Limit value : 0 <= value <= 1 */
- glp_set_col_bnds (mlp->prob, mlpi->c_n, GLP_DB, 0.0, 1.0);
+ glp_set_col_bnds (p->prob, mlpi->c_n, GLP_DB, 0.0, 1.0);
/* Integer value*/
- glp_set_col_kind (mlp->prob, mlpi->c_n, GLP_IV);
+ glp_set_col_kind (p->prob, mlpi->c_n, GLP_IV);
/* Objective function coefficient == 0 */
- glp_set_obj_coef (mlp->prob, mlpi->c_n, 0);
+ glp_set_obj_coef (p->prob, mlpi->c_n, 0);
+#if DEBUG_MLP_PROBLEM_CREATION
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%u] `%s': `%s'
address %p\n",
+ mlpi->c_n, name, GNUNET_i2s(&address->peer), address);
+#endif
+ GNUNET_free (name);
return GNUNET_OK;
}
@@ -1162,77 +1201,97 @@
static int
mlp_create_problem (struct GAS_MLP_Handle *mlp, struct
GNUNET_CONTAINER_MultiHashMap * addresses)
{
- int res = GNUNET_OK;
+ struct MLP_Problem *p = &mlp->p;
+ int res = GNUNET_OK;
int c;
int cur_col;
- int elements = 0;
char *name;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Rebuilding problem for %u peer(s) \n",
GNUNET_CONTAINER_multihashmap_size(mlp->peers));
- GNUNET_assert (mlp->prob == NULL);
+ GNUNET_assert (p->prob == NULL);
/* create the glpk problem */
- mlp->prob = glp_create_prob ();
- GNUNET_assert (NULL != mlp->prob);
+ p->prob = glp_create_prob ();
+ p->addresses_in_problem = 0;;
+ GNUNET_assert (NULL != p->prob);
/* Set a problem name */
- glp_set_prob_name (mlp->prob, "GNUnet ats bandwidth distribution");
+ glp_set_prob_name (p->prob, "GNUnet ats bandwidth distribution");
/* Set optimization direction to maximize */
- glp_set_obj_dir (mlp->prob, GLP_MAX);
+ glp_set_obj_dir (p->prob, GLP_MAX);
/* Adding invariant columns */
/* Diversity d column */
- mlp->c_d = glp_add_cols (mlp->prob, 1);
+ p->c_d = glp_add_cols (p->prob, 1);
/* Column name */
- glp_set_col_name (mlp->prob, mlp->c_d, "d");
+ glp_set_col_name (p->prob, p->c_d, "d");
/* Column objective function coefficient */
- glp_set_obj_coef (mlp->prob, mlp->c_d, mlp->co_D);
+ glp_set_obj_coef (p->prob, p->c_d, mlp->pv.co_D);
/* Column lower bound = 0.0 */
- glp_set_col_bnds (mlp->prob, mlp->c_d, GLP_LO, 0.0, 0.0);
+ glp_set_col_bnds (p->prob, p->c_d, GLP_LO, 0.0, 0.0);
+#if DEBUG_MLP_PROBLEM_CREATION
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%i] `%s': %.2f \n",
+ p->c_d, "d", mlp->pv.co_D);
+#endif
+
/* Utilization u column */
- mlp->c_u = glp_add_cols (mlp->prob, 1);
+ p->c_u = glp_add_cols (p->prob, 1);
/* Column name */
- glp_set_col_name (mlp->prob, mlp->c_u, "u");
+ glp_set_col_name (p->prob, p->c_u, "u");
/* Column objective function coefficient */
- glp_set_obj_coef (mlp->prob, mlp->c_u, mlp->co_U);
+ glp_set_obj_coef (p->prob, p->c_u, mlp->pv.co_U);
/* Column lower bound = 0.0 */
- glp_set_col_bnds (mlp->prob, mlp->c_u, GLP_LO, 0.0, 0.0);
+ glp_set_col_bnds (p->prob, p->c_u, GLP_LO, 0.0, 0.0);
+#if DEBUG_MLP_PROBLEM_CREATION
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%i] `%s': %.2f \n",
+ p->c_u, "u", mlp->pv.co_U);
+#endif
/* Relativity r column */
- mlp->c_r = glp_add_cols (mlp->prob, 1);
+ p->c_r = glp_add_cols (p->prob, 1);
/* Column name */
- glp_set_col_name (mlp->prob, mlp->c_r, "r");
+ glp_set_col_name (p->prob, p->c_r, "r");
/* Column objective function coefficient */
- glp_set_obj_coef (mlp->prob, mlp->c_r, mlp->co_R);
+ glp_set_obj_coef (p->prob, p->c_r, mlp->pv.co_R);
/* Column lower bound = 0.0 */
- glp_set_col_bnds (mlp->prob, mlp->c_r, GLP_LO, 0.0, 0.0);
+ glp_set_col_bnds (p->prob, p->c_r, GLP_LO, 0.0, 0.0);
+#if DEBUG_MLP_PROBLEM_CREATION
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%i] `%s': %.2f \n",
+ p->c_r, "r", mlp->pv.co_R);
+#endif
/* Quality metric columns */
- cur_col = glp_add_cols(mlp->prob, mlp->m_q);
- for (c = 0; c < mlp->m_q; c++)
+ cur_col = glp_add_cols(p->prob, mlp->pv.m_q);
+ for (c = 0; c < mlp->pv.m_q; c++)
{
- mlp->c_q[c] = cur_col + c;
- GNUNET_asprintf (&name, "q_%u", mlp->q[c]);
- glp_set_col_name (mlp->prob, mlp->c_q[c], name);
+ p->c_q[c] = cur_col + c;
+ GNUNET_asprintf (&name, "q_%u", mlp->pv.q[c]);
+ glp_set_col_name (p->prob, p->c_q[c], name);
/* Column lower bound = 0.0 */
- glp_set_col_bnds (mlp->prob, mlp->c_q[c], GLP_LO, 0.0, 0.0);
- GNUNET_free (name);
+ glp_set_col_bnds (p->prob, p->c_q[c], GLP_LO, 0.0, 0.0);
/* Coefficient == Qm */
- glp_set_obj_coef (mlp->prob, mlp->c_q[c], mlp->co_Q[c]);
+ glp_set_obj_coef (p->prob, p->c_q[c], mlp->pv.co_Q[c]);
+#if DEBUG_MLP_PROBLEM_CREATION
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%i] `%s': %.2f \n",
+ p->c_q[c], name, mlp->pv.co_Q[c]);
+#endif
+ GNUNET_free (name);
}
/* Add columns for addresses */
GNUNET_CONTAINER_multihashmap_iterate (addresses,
mlp_create_address_columns_it, mlp);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Problems contains %u addresses, %u
addresses skipped \n",
+ p->addresses_in_problem,
GNUNET_CONTAINER_multihashmap_size(addresses)- p->addresses_in_problem);
- /* Add constraints */
+ /* Add constraints rows */
mlp_add_constraints_all_addresses (mlp, addresses);
/* Load the matrix */
- glp_load_matrix(mlp->prob, elements /*(mlp->ci-1)*/, mlp->ia, mlp->ja,
mlp->ar);
+ //glp_load_matrix(mlp->prob, (mlp->ci-1), mlp->ia, mlp->ja, mlp->ar);
return res;
}
@@ -1517,7 +1576,7 @@
}
address->solver_information = mlpi;
- mlp->addr_in_problem ++;
+ mlp->addresses_in_problem ++;
GNUNET_STATISTICS_update (mlp->stats, "# addresses in MLP", 1, GNUNET_NO);
/* Check for and add peer */
@@ -1633,7 +1692,7 @@
GNUNET_free (address->solver_information);
address->solver_information = NULL;
- mlp->addr_in_problem --;
+ mlp->addresses_in_problem --;
GNUNET_STATISTICS_update (mlp->stats, "# addresses in MLP", -1, GNUNET_NO);
}
@@ -1912,14 +1971,6 @@
break;
}
- /* Create initial MLP problem */
- mlp->prob = glp_create_prob();
- if (NULL == mlp->prob)
- {
- LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to create MLP problem!");
- GNUNET_free (mlp);
- return NULL;
- }
mlp->BIG_M = (double) BIG_M_VALUE;
@@ -1966,9 +2017,9 @@
for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
{
/* initialize quality coefficients with default value 1.0 */
- mlp->co_Q[c] = DEFAULT_QUALITY;
+ mlp->pv.co_Q[c] = DEFAULT_QUALITY;
- mlp->q[c] = q[c];
+ mlp->pv.q[c] = q[c];
if (q[c] == GNUNET_ATS_QUALITY_NET_DELAY)
i_delay = c;
if (q[c] == GNUNET_ATS_QUALITY_NET_DISTANCE)
@@ -1979,16 +2030,16 @@
"MLP_COEFFICIENT_QUALITY_DELAY",
&tmp)))
- mlp->co_Q[i_delay] = (double) tmp / 100;
+ mlp->pv.co_Q[i_delay] = (double) tmp / 100;
else
- mlp->co_Q[i_delay] = DEFAULT_QUALITY;
+ mlp->pv.co_Q[i_delay] = DEFAULT_QUALITY;
if ((i_distance != NaN) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size
(cfg, "ats",
"MLP_COEFFICIENT_QUALITY_DISTANCE",
&tmp)))
- mlp->co_Q[i_distance] = (double) tmp / 100;
+ mlp->pv.co_Q[i_distance] = (double) tmp / 100;
else
- mlp->co_Q[i_distance] = DEFAULT_QUALITY;
+ mlp->pv.co_Q[i_distance] = DEFAULT_QUALITY;
/* Get minimum bandwidth per used address from configuration */
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
@@ -2017,62 +2068,62 @@
{
if (quotas[c] == network[c2])
{
- mlp->quota_index[c] = network[c2];
- mlp->quota_out[c] = out_dest[c2];
- mlp->quota_in[c] = in_dest[c2];
+ mlp->pv.quota_index[c] = network[c2];
+ mlp->pv.quota_out[c] = out_dest[c2];
+ mlp->pv.quota_in[c] = in_dest[c2];
found = GNUNET_YES;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Quota for network `%s'
(in/out) %llu/%llu\n",
-
GNUNET_ATS_print_network_type(mlp->quota_index[c]),
-
mlp->quota_out[c],
-
mlp->quota_in[c]);
+
GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
+
mlp->pv.quota_out[c],
+
mlp->pv.quota_in[c]);
break;
}
}
/* Check if defined quota could make problem unsolvable */
- if ((n_min * b_min) > mlp->quota_out[c])
+ if ((n_min * b_min) > mlp->pv.quota_out[c])
{
LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inconsistent outbound quota
configuration for network `%s', is %llu must be at least %llu\n"),
- GNUNET_ATS_print_network_type(mlp->quota_index[c]),
- mlp->quota_out[c],
+ GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
+ mlp->pv.quota_out[c],
(n_min * b_min));
- mlp->quota_out[c] = (n_min * b_min);
+ mlp->pv.quota_out[c] = (n_min * b_min);
}
- if ((n_min * b_min) > mlp->quota_in[c])
+ if ((n_min * b_min) > mlp->pv.quota_in[c])
{
LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inconsistent inbound quota
configuration for network `%s', is %llu must be at least %llu\n"),
- GNUNET_ATS_print_network_type(mlp->quota_index[c]),
- mlp->quota_in[c],
+ GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
+ mlp->pv.quota_in[c],
(n_min * b_min));
- mlp->quota_in[c] = (n_min * b_min);
+ mlp->pv.quota_in[c] = (n_min * b_min);
}
/* Check if bandwidth is too big to make problem solvable */
- if (mlp->BIG_M < mlp->quota_out[c])
+ if (mlp->BIG_M < mlp->pv.quota_out[c])
{
LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting outbound quota configuration
for network `%s'from %llu to %.0f\n"),
- GNUNET_ATS_print_network_type(mlp->quota_index[c]),
- mlp->quota_out[c],
+ GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
+ mlp->pv.quota_out[c],
mlp->BIG_M);
- mlp->quota_out[c] = mlp->BIG_M;
+ mlp->pv.quota_out[c] = mlp->BIG_M;
}
- if (mlp->BIG_M < mlp->quota_in[c])
+ if (mlp->BIG_M < mlp->pv.quota_in[c])
{
LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inbound quota configuration
for network `%s' from %llu to %.0f\n"),
- GNUNET_ATS_print_network_type(mlp->quota_index[c]),
- mlp->quota_in[c],
+ GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
+ mlp->pv.quota_in[c],
mlp->BIG_M);
- mlp->quota_in[c] = mlp->BIG_M;
+ mlp->pv.quota_in[c] = mlp->BIG_M;
}
if (GNUNET_NO == found)
{
- mlp->quota_in[c] =
ntohl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
- mlp->quota_out[c] =
ntohl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
+ mlp->pv.quota_in[c] =
ntohl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
+ mlp->pv.quota_out[c] =
ntohl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
LOG (GNUNET_ERROR_TYPE_INFO, _("Using default
quota configuration for network `%s' (in/out) %llu/%llu\n"),
-
GNUNET_ATS_print_network_type(mlp->quota_index[c]),
- mlp->quota_in[c],
- mlp->quota_out[c]);
+
GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
+ mlp->pv.quota_in[c],
+ mlp->pv.quota_out[c]);
}
}
@@ -2088,12 +2139,14 @@
mlp->stats = (struct GNUNET_STATISTICS_Handle *) stats;
mlp->bw_changed_cb = bw_changed_cb;
mlp->bw_changed_cb_cls = bw_changed_cb_cls;
- mlp->co_D = D;
- mlp->co_R = R;
- mlp->co_U = U;
- mlp->b_min = b_min;
- mlp->n_min = n_min;
- mlp->m_q = GNUNET_ATS_QualityPropertiesCount;
+ /* Setting MLP Input variables */
+ mlp->pv.co_D = D;
+ mlp->pv.co_R = R;
+ mlp->pv.co_U = U;
+ mlp->pv.b_min = b_min;
+ mlp->pv.n_min = n_min;
+ mlp->pv.m_q = GNUNET_ATS_QualityPropertiesCount;
+
mlp->semaphore = GNUNET_NO;
mlp->max_iterations = max_iterations;
mlp->max_exec_duration = max_duration;
Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.h 2013-02-20 18:02:38 UTC
(rev 26171)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.h 2013-02-21 10:51:49 UTC
(rev 26172)
@@ -80,6 +80,109 @@
struct GNUNET_TIME_Relative mlp_duration;
};
+
+
+struct MLP_Problem
+{
+ /**
+ * GLPK (MLP) problem object
+ */
+#if HAVE_LIBGLPK
+ glp_prob *prob;
+#else
+ void *prob;
+#endif
+ unsigned int addresses_in_problem;
+
+ /* Row index constraint 2: */
+ unsigned int r_c2;
+ /* Row index constraint 4: minimum connections */
+ unsigned int r_c4;
+ /* Row index constraint 6: maximize diversity */
+ unsigned int r_c6;
+ /* Row index constraint 8: utilization*/
+ unsigned int r_c8;
+ /* Row index constraint 9: relativity*/
+ unsigned int r_c9;
+ /* Row indices quality metrics */
+ int r_q[GNUNET_ATS_QualityPropertiesCount];
+ /* Row indices ATS network quotas */
+ int r_quota[GNUNET_ATS_NetworkTypeCount];
+
+ /* Column index Diversity (D) column */
+ int c_d;
+ /* Column index Utilization (U) column */
+ int c_u;
+ /* Column index Proportionality (R) column */
+ int c_r;
+ /* Column index quality metrics */
+ int c_q[GNUNET_ATS_QualityPropertiesCount];
+ /* column index ressource costs */
+ int c_rc[GNUNET_ATS_QualityPropertiesCount];
+ /* Column indices ATS network quotas */
+ int c_quota[GNUNET_ATS_NetworkTypeCount];
+
+ /* Problem matrix */
+ /* Current index */
+ unsigned int ci;
+ /* Row index array */
+ int *ia;
+ /* Column index array */
+ int *ja;
+ /* Column index value */
+ double *ar;
+
+
+
+};
+
+struct MLP_Variables
+{
+
+ /* ATS Quality metrics
+ *
+ * Array with GNUNET_ATS_QualityPropertiesCount elements
+ * contains mapping to GNUNET_ATS_Property*/
+ int q[GNUNET_ATS_QualityPropertiesCount];
+
+ /* Number of quality metrics */
+ int m_q;
+
+ /* Number of quality metrics */
+ int m_rc;
+
+ /* Quality metric coefficients*/
+ double co_Q[GNUNET_ATS_QualityPropertiesCount];
+
+ /* Ressource costs coefficients*/
+ double co_RC[GNUNET_ATS_QualityPropertiesCount];
+
+ /* Diversity coefficient */
+ double co_D;
+
+ /* Utility coefficient */
+ double co_U;
+
+ /* Relativity coefficient */
+ double co_R;
+
+ /* Minimum bandwidth assigned to an address */
+ unsigned int b_min;
+
+ /* Minimum number of addresses with bandwidth assigned */
+ unsigned int n_min;
+
+ /* Quotas */
+ /* Array mapping array index to ATS network */
+ int quota_index [GNUNET_ATS_NetworkTypeCount];
+ /* Outbound quotas */
+ unsigned long long quota_out[GNUNET_ATS_NetworkTypeCount];
+ /* Inbound quotas */
+ unsigned long long quota_in[GNUNET_ATS_NetworkTypeCount];
+
+};
+
+
/**
* MLP Handle
*/
@@ -100,17 +203,14 @@
*/
void *bw_changed_cb_cls;
- /**
- * GLPK (MLP) problem object
- */
-#if HAVE_LIBGLPK
- glp_prob *prob;
-#else
- void *prob;
-#endif
+ struct MLP_Problem p;
+ struct MLP_Variables pv;
+
double BIG_M;
+
+
/**
* GLPK LP control parameter
*/
@@ -218,8 +318,8 @@
*/
uint64_t mlp_total_duration;
- unsigned int addr_in_problem;
+
/* Information about the problem */
struct ATS_Peer *peer_head;
@@ -228,85 +328,16 @@
/* Number of peers */
unsigned int c_p;
- /* current problem matrix */
- /* row index array */
- int *ia;
- /* column index array */
- int *ja;
- /* column index array */
- double *ar;
+
/* current size of the constraint matrix |indices| */
unsigned int cm_size;
- unsigned int ci;
- /* Row index constraint 2: */
- unsigned int r_c2;
- /* Row index constraint 4: minimum connections */
- unsigned int r_c4;
- /* Row index constraint 6: maximize diversity */
- unsigned int r_c6;
- /* Row index constraint 8: utilization*/
- unsigned int r_c8;
- /* Row index constraint 9: relativity*/
- unsigned int r_c9;
-
- /* column index Diversity (D) column */
- int c_d;
- double co_D;
-
- /* column index Utilization (U) column */
- int c_u;
- double co_U;
-
- /* column index Proportionality (R) column */
- 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 quality metrics */
- int c_q[GNUNET_ATS_QualityPropertiesCount];
-
- /* column index quality metrics */
- int r_q[GNUNET_ATS_QualityPropertiesCount];
-
- /* quality metric coefficients*/
- double co_Q[GNUNET_ATS_QualityPropertiesCount];
-
- /* number of quality metrics */
- int m_q;
-
- /* ATS network quotas */
- int c_quota[GNUNET_ATS_NetworkTypeCount];
- int r_quota[GNUNET_ATS_NetworkTypeCount];
- int quota_index [GNUNET_ATS_NetworkTypeCount];
- unsigned long long quota_out[GNUNET_ATS_NetworkTypeCount];
- unsigned long long quota_in[GNUNET_ATS_NetworkTypeCount];
-
/* ATS ressource costs
*
* array with GNUNET_ATS_QualityPropertiesCount elements
* contains mapping to GNUNET_ATS_Property*/
int rc[GNUNET_ATS_QualityPropertiesCount];
- /* column index ressource costs */
- int c_rc[GNUNET_ATS_QualityPropertiesCount];
-
- /* ressource costs coefficients*/
- double co_RC[GNUNET_ATS_QualityPropertiesCount];
-
- /* number of quality metrics */
- int m_rc;
-
- /* minimum bandwidth assigned to an address */
- unsigned int b_min;
-
- /* minimum number of addresses with bandwidth assigned */
- unsigned int n_min;
};
Modified: gnunet/src/ats/perf_ats_mlp.c
===================================================================
--- gnunet/src/ats/perf_ats_mlp.c 2013-02-20 18:02:38 UTC (rev 26171)
+++ gnunet/src/ats/perf_ats_mlp.c 2013-02-21 10:51:49 UTC (rev 26172)
@@ -356,12 +356,12 @@
ca++;
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Problem contains %u peers and %u
adresses\n", mlp->c_p, mlp->addr_in_problem);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Problem contains %u peers and %u
adresses\n", mlp->c_p, mlp->addresses_in_problem);
if (((GNUNET_YES == range) && (((start >= 0) && ((c+1) >= start)) && (c <=
end))) || ((c+1) == peers))
{
GNUNET_assert ((c+1) == mlp->c_p);
- GNUNET_assert ((c+1) * addresses == mlp->addr_in_problem);
+ GNUNET_assert ((c+1) * addresses == mlp->addresses_in_problem);
/* Solving the problem */
struct GAS_MLP_SolutionContext ctx;
@@ -375,10 +375,10 @@
GNUNET_assert (GNUNET_OK == ctx.lp_result);
GNUNET_assert (GNUNET_OK == ctx.mlp_result);
if (GNUNET_YES == numeric)
- printf ("%u;%u;%llu;%llu\n",mlp->c_p, mlp->addr_in_problem,
(unsigned long long) ctx.lp_duration.rel_value, (unsigned long long)
ctx.mlp_duration.rel_value);
+ printf ("%u;%u;%llu;%llu\n",mlp->c_p, mlp->addresses_in_problem,
(unsigned long long) ctx.lp_duration.rel_value, (unsigned long long)
ctx.mlp_duration.rel_value);
else
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Problem solved for %u peers
with %u address successfully (LP: %llu ms / MLP: %llu ms)\n",
- mlp->c_p, mlp->addr_in_problem, ctx.lp_duration.rel_value,
ctx.mlp_duration.rel_value);
+ mlp->c_p, mlp->addresses_in_problem,
ctx.lp_duration.rel_value, ctx.mlp_duration.rel_value);
}
else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Solving problem with %u peers
and %u addresses failed\n", c, c2);
@@ -397,12 +397,12 @@
GNUNET_assert (GNUNET_OK == uctx.lp_result);
GNUNET_assert (GNUNET_OK == uctx.mlp_result);
if (GNUNET_YES == numeric)
- printf ("%u;%u;%llu;%llu;%llu;%llu\n",mlp->c_p,
mlp->addr_in_problem,
+ printf ("%u;%u;%llu;%llu;%llu;%llu\n",mlp->c_p,
mlp->addresses_in_problem,
(unsigned long long) ctx.lp_duration.rel_value, (unsigned long
long) ctx.mlp_duration.rel_value,
(unsigned long long) uctx.lp_duration.rel_value, (unsigned
long long) uctx.mlp_duration.rel_value);
else
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Updated problem solved for %u
peers with %u address successfully (Initial: LP/MLP: %llu/%llu ms, Update:
%llu/%llu ms)\n",
- mlp->c_p, mlp->addr_in_problem,
+ mlp->c_p, mlp->addresses_in_problem,
(unsigned long long) ctx.lp_duration.rel_value, (unsigned long
long) ctx.mlp_duration.rel_value,
(unsigned long long) uctx.lp_duration.rel_value, (unsigned
long long) uctx.mlp_duration.rel_value);
}
Modified: gnunet/src/ats/test_ats_mlp.c
===================================================================
--- gnunet/src/ats/test_ats_mlp.c 2013-02-20 18:02:38 UTC (rev 26171)
+++ gnunet/src/ats/test_ats_mlp.c 2013-02-21 10:51:49 UTC (rev 26172)
@@ -55,12 +55,12 @@
/**
* Peer
*/
-struct GNUNET_PeerIdentity p;
+struct GNUNET_PeerIdentity p[2];
/**
* ATS Address
*/
-struct ATS_Address *address[2];
+struct ATS_Address *address[3];
/**
* Timeout task
@@ -136,6 +136,7 @@
end_now (1);
}
+
static void
check (void *cls, char *const *args, const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -183,23 +184,47 @@
return;
}
- /* Create peer */
- if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p.hashPubKey))
+ /* Create peer 0 */
+ if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0,
&p[0].hashPubKey))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
end_now (1);
return;
}
+ /* Create peer 1 */
+ if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1,
&p[1].hashPubKey))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
+ end_now (1);
+ return;
+ }
+
+ /* Create address 3 */
+ address[2] = create_address (&p[1], "test_plugin", "test_addr2",
strlen("test_addr2")+1, 0);
+ if (NULL == address[2])
+ {
+ GNUNET_break (0);
+ end_now (1);
+ return;
+ }
+ GNUNET_CONTAINER_multihashmap_put (addresses, &p[1].hashPubKey, address[2],
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
+
+
+ /* Adding address 1*/
+ GAS_mlp_address_add (mlp, addresses, address[2]);
+
+
/* Create address 0 */
- address[0] = create_address (&p, "test_plugin", "test_addr0",
strlen("test_addr0")+1, 0);
+ address[0] = create_address (&p[0], "test_plugin", "test_addr0",
strlen("test_addr0")+1, 0);
if (NULL == address[0])
{
GNUNET_break (0);
end_now (1);
return;
}
- GNUNET_CONTAINER_multihashmap_put (addresses, &p.hashPubKey, address[0],
+ GNUNET_CONTAINER_multihashmap_put (addresses, &p[0].hashPubKey, address[0],
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
/* Adding address 0 */
@@ -212,17 +237,17 @@
/* Retrieving preferred address for peer and wait for callback */
- GAS_mlp_get_preferred_address (mlp, addresses, &p);
+ GAS_mlp_get_preferred_address (mlp, addresses, &p[0]);
/* Create address 1 */
- address[1] = create_address (&p, "test_plugin", "test_addr1",
strlen("test_addr1")+1, 0);
+ address[1] = create_address (&p[0], "test_plugin", "test_addr1",
strlen("test_addr1")+1, 0);
if (NULL == address[1])
{
GNUNET_break (0);
end_now (1);
return;
}
- GNUNET_CONTAINER_multihashmap_put (addresses, &p.hashPubKey, address[1],
+ GNUNET_CONTAINER_multihashmap_put (addresses, &p[0].hashPubKey, address[1],
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
Modified: gnunet/src/ats/test_ats_mlp_averaging.c
===================================================================
--- gnunet/src/ats/test_ats_mlp_averaging.c 2013-02-20 18:02:38 UTC (rev
26171)
+++ gnunet/src/ats/test_ats_mlp_averaging.c 2013-02-21 10:51:49 UTC (rev
26172)
@@ -189,28 +189,28 @@
// mlpi = addr[0].mlp_information;
GNUNET_assert (mlp != NULL);
- GNUNET_assert (mlp->addr_in_problem == 1);
+ GNUNET_assert (mlp->addresses_in_problem == 1);
/* Update an peer 1 address 1 */
set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 20);
GAS_mlp_address_update (mlp, addresses, &addr[0]);
- GNUNET_assert (mlp->addr_in_problem == 1);
+ GNUNET_assert (mlp->addresses_in_problem == 1);
/* Update an peer 1 address 1 */
set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 10);
GAS_mlp_address_update (mlp, addresses, &addr[0]);
- GNUNET_assert (mlp->addr_in_problem == 1);
+ GNUNET_assert (mlp->addresses_in_problem == 1);
/* Update an peer 1 address 1 */
set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 10);
GAS_mlp_address_update (mlp, addresses, &addr[0]);
- GNUNET_assert (mlp->addr_in_problem == 1);
+ GNUNET_assert (mlp->addresses_in_problem == 1);
/* Update an peer 1 address 1 */
set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 30);
GAS_mlp_address_update (mlp, addresses, &addr[0]);
- GNUNET_assert (mlp->addr_in_problem == 1);
+ GNUNET_assert (mlp->addresses_in_problem == 1);
GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp, &ctx));
@@ -224,7 +224,7 @@
GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[0].peer.hashPubKey,
&addr[0]);
GAS_mlp_address_delete (mlp, addresses, &addr[0]);
- GNUNET_assert (mlp->addr_in_problem == 0);
+ GNUNET_assert (mlp->addresses_in_problem == 0);
GAS_mlp_done (mlp);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r26172 - gnunet/src/ats,
gnunet <=