From b435918c10c47f73401a8b93fdb739469b9c7056 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Wed, 18 Jan 2012 13:38:43 +0000 Subject: [PATCH] - constraint min conne --- src/ats/gnunet-service-ats_addresses_mlp.c | 13 +++++++++++++ src/ats/gnunet-service-ats_addresses_mlp.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index 54abd9d89..c3a7cfb5c 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c @@ -249,6 +249,14 @@ create_constraint_it (void *cls, const GNUNET_HashCode * key, void *value) mlp->ar[mlp->ci] = -mlp->b_min; mlp->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++; + return GNUNET_OK; } @@ -322,8 +330,13 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON /* c 1) bandwidth capping */ /* c 3) minimum bandwidth */ + /* c 4) minimum number of connections */ + mlp->r_c4 = glp_add_rows (mlp->prob, 1); + glp_set_row_bnds (mlp->prob, mlp->r_c4, GLP_LO, mlp->n_min, 0.0); + GNUNET_CONTAINER_multihashmap_iterate (addresses, create_constraint_it, mlp); + } /** diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h index bb86d2251..3878b0f5f 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.h +++ b/src/ats/gnunet-service-ats_addresses_mlp.h @@ -146,6 +146,9 @@ struct GAS_MLP_Handle unsigned int cm_size; unsigned int ci; + /* Row index constraint 4: minimum connections */ + unsigned int r_c4; + /* column index Diversity (D) column */ int c_d; double co_D; -- 2.25.1