From 333a74f3b7237f79a7120f65348ad6326500202c Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Mon, 20 Feb 2012 20:45:19 +0000 Subject: [PATCH] - choosing BIG_M and default quota is crucial to get a solvable constraint system (hours of debugging!) --- src/ats/gnunet-service-ats_addresses_mlp.c | 18 ++++++++++++------ src/ats/test_ats_mlp.c | 8 ++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index e365151ce..b84e671f2 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c @@ -35,6 +35,8 @@ #define DEBUG_ATS GNUNET_NO #define VERBOSE_GLPK GNUNET_NO +#define ENABLE_C8 GNUNET_YES +#define ENABLE_C9 GNUNET_YES /** * Translate glpk solver error codes to text * @param retcode return code @@ -577,6 +579,7 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON glp_set_row_bnds (mlp->prob, peer->r_c2, GLP_FX, 1.0, 1.0); /* Adding rows for c 9) */ +#if ENABLE_C9 peer->r_c9 = glp_add_rows (mlp->prob, 1); GNUNET_asprintf(&name, "c9_%s", GNUNET_i2s(&peer->id)); glp_set_row_name (mlp->prob, peer->r_c9, name); @@ -589,8 +592,7 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON ja[mlp->ci] = mlp->c_r; ar[mlp->ci] = -1; mlp->ci++; - - +#endif while (addr != NULL) { @@ -609,11 +611,13 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON ar[mlp->ci] = peer->f; mlp->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++; +#endif addr = addr->next; } @@ -782,6 +786,7 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas /* Column lower bound = 0.0 */ glp_set_col_bnds (mlp->prob, col, GLP_LO, 0.0, 0.0); +#if ENABLE_C9 /* Relativity r column */ col = glp_add_cols (mlp->prob, 1); mlp->c_r = col; @@ -791,6 +796,7 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas glp_set_obj_coef (mlp->prob, col, mlp->co_R); /* Column lower bound = 0.0 */ glp_set_col_bnds (mlp->prob, col, GLP_LO, 0.0, 0.0); +#endif /* Quality metric columns */ col = glp_add_cols(mlp->prob, mlp->m_q); @@ -1131,6 +1137,8 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, mlp->prob = glp_create_prob(); GNUNET_assert (mlp->prob != NULL); + mlp->BIG_M = (double) (UINT32_MAX) /10; + /* Get diversity coefficient from configuration */ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", "COEFFICIENT_D", @@ -1244,11 +1252,11 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", entry_out, "a_out)) { - quota_out = UINT32_MAX; + quota_out = mlp->BIG_M; } if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", entry_in, "a_in)) { - quota_in = UINT32_MAX; + quota_in = mlp->BIG_M; } /* Check if defined quota could make problem unsolvable */ if ((n_min * b_min) > quota_out) @@ -1315,8 +1323,6 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, mlp->last_execution = GNUNET_TIME_absolute_get_forever(); - - mlp->BIG_M = (double) UINT32_MAX; mlp->co_D = D; mlp->co_R = R; mlp->co_U = U; diff --git a/src/ats/test_ats_mlp.c b/src/ats/test_ats_mlp.c index 9726be38f..8af368c8e 100644 --- a/src/ats/test_ats_mlp.c +++ b/src/ats/test_ats_mlp.c @@ -94,10 +94,10 @@ check (void *cls, char *const *args, const char *cfgfile, addr[0].peer.hashPubKey = p[0].hashPubKey; struct GNUNET_ATS_Information a1_ats[3]; set_ats (&a1_ats[0], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); - set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 32); + set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 2); set_ats (&a1_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); create_address (&addr[0], "dummy", 3, &a1_ats[0]); - addr[0].atsp_network_type = GNUNET_ATS_NET_WAN; + addr[0].atsp_network_type = GNUNET_ATS_NET_LOOPBACK; /* Creating peer 1 address 2 */ @@ -107,7 +107,7 @@ check (void *cls, char *const *args, const char *cfgfile, set_ats (&a2_ats[1], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); set_ats (&a2_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); create_address (&addr[1], "dummy2", 3, &a2_ats[0]); - addr[1].atsp_network_type = GNUNET_ATS_NET_WAN; + addr[1].atsp_network_type = GNUNET_ATS_NET_LAN; /* Creating peer 2 address 1 */ addr[2].peer.hashPubKey = p[1].hashPubKey; @@ -116,7 +116,7 @@ check (void *cls, char *const *args, const char *cfgfile, set_ats (&a3_ats[1], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); set_ats (&a3_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); create_address (&addr[2], "dummy3", 3, &a3_ats[0]); - addr[2].atsp_network_type = GNUNET_ATS_NET_LAN; + addr[2].atsp_network_type = GNUNET_ATS_NET_WAN; GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[0], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); -- 2.25.1