aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-02-20 20:45:19 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-02-20 20:45:19 +0000
commit333a74f3b7237f79a7120f65348ad6326500202c (patch)
tree153ea611899f11d932aed761d0b67fb63f5eb5b5 /src/ats
parent3be7c8d9183f4608aa670646053dc73666276e38 (diff)
downloadgnunet-333a74f3b7237f79a7120f65348ad6326500202c.tar.gz
gnunet-333a74f3b7237f79a7120f65348ad6326500202c.zip
- choosing BIG_M and default quota is crucial to get a solvable constraint system (hours of debugging!)
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c18
-rw-r--r--src/ats/test_ats_mlp.c8
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 @@
35#define DEBUG_ATS GNUNET_NO 35#define DEBUG_ATS GNUNET_NO
36#define VERBOSE_GLPK GNUNET_NO 36#define VERBOSE_GLPK GNUNET_NO
37 37
38#define ENABLE_C8 GNUNET_YES
39#define ENABLE_C9 GNUNET_YES
38/** 40/**
39 * Translate glpk solver error codes to text 41 * Translate glpk solver error codes to text
40 * @param retcode return code 42 * @param retcode return code
@@ -577,6 +579,7 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
577 glp_set_row_bnds (mlp->prob, peer->r_c2, GLP_FX, 1.0, 1.0); 579 glp_set_row_bnds (mlp->prob, peer->r_c2, GLP_FX, 1.0, 1.0);
578 580
579 /* Adding rows for c 9) */ 581 /* Adding rows for c 9) */
582#if ENABLE_C9
580 peer->r_c9 = glp_add_rows (mlp->prob, 1); 583 peer->r_c9 = glp_add_rows (mlp->prob, 1);
581 GNUNET_asprintf(&name, "c9_%s", GNUNET_i2s(&peer->id)); 584 GNUNET_asprintf(&name, "c9_%s", GNUNET_i2s(&peer->id));
582 glp_set_row_name (mlp->prob, peer->r_c9, name); 585 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
589 ja[mlp->ci] = mlp->c_r; 592 ja[mlp->ci] = mlp->c_r;
590 ar[mlp->ci] = -1; 593 ar[mlp->ci] = -1;
591 mlp->ci++; 594 mlp->ci++;
592 595#endif
593
594 596
595 while (addr != NULL) 597 while (addr != NULL)
596 { 598 {
@@ -609,11 +611,13 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON
609 ar[mlp->ci] = peer->f; 611 ar[mlp->ci] = peer->f;
610 mlp->ci++; 612 mlp->ci++;
611 613
614#if ENABLE_C9
612 /* coefficient for c 9) */ 615 /* coefficient for c 9) */
613 ia[mlp->ci] = peer->r_c9; 616 ia[mlp->ci] = peer->r_c9;
614 ja[mlp->ci] = mlpi->c_b; 617 ja[mlp->ci] = mlpi->c_b;
615 ar[mlp->ci] = 1; 618 ar[mlp->ci] = 1;
616 mlp->ci++; 619 mlp->ci++;
620#endif
617 621
618 addr = addr->next; 622 addr = addr->next;
619 } 623 }
@@ -782,6 +786,7 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas
782 /* Column lower bound = 0.0 */ 786 /* Column lower bound = 0.0 */
783 glp_set_col_bnds (mlp->prob, col, GLP_LO, 0.0, 0.0); 787 glp_set_col_bnds (mlp->prob, col, GLP_LO, 0.0, 0.0);
784 788
789#if ENABLE_C9
785 /* Relativity r column */ 790 /* Relativity r column */
786 col = glp_add_cols (mlp->prob, 1); 791 col = glp_add_cols (mlp->prob, 1);
787 mlp->c_r = col; 792 mlp->c_r = col;
@@ -791,6 +796,7 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas
791 glp_set_obj_coef (mlp->prob, col, mlp->co_R); 796 glp_set_obj_coef (mlp->prob, col, mlp->co_R);
792 /* Column lower bound = 0.0 */ 797 /* Column lower bound = 0.0 */
793 glp_set_col_bnds (mlp->prob, col, GLP_LO, 0.0, 0.0); 798 glp_set_col_bnds (mlp->prob, col, GLP_LO, 0.0, 0.0);
799#endif
794 800
795 /* Quality metric columns */ 801 /* Quality metric columns */
796 col = glp_add_cols(mlp->prob, mlp->m_q); 802 col = glp_add_cols(mlp->prob, mlp->m_q);
@@ -1131,6 +1137,8 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1131 mlp->prob = glp_create_prob(); 1137 mlp->prob = glp_create_prob();
1132 GNUNET_assert (mlp->prob != NULL); 1138 GNUNET_assert (mlp->prob != NULL);
1133 1139
1140 mlp->BIG_M = (double) (UINT32_MAX) /10;
1141
1134 /* Get diversity coefficient from configuration */ 1142 /* Get diversity coefficient from configuration */
1135 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", 1143 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
1136 "COEFFICIENT_D", 1144 "COEFFICIENT_D",
@@ -1244,11 +1252,11 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1244 1252
1245 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", entry_out, &quota_out)) 1253 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", entry_out, &quota_out))
1246 { 1254 {
1247 quota_out = UINT32_MAX; 1255 quota_out = mlp->BIG_M;
1248 } 1256 }
1249 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", entry_in, &quota_in)) 1257 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", entry_in, &quota_in))
1250 { 1258 {
1251 quota_in = UINT32_MAX; 1259 quota_in = mlp->BIG_M;
1252 } 1260 }
1253 /* Check if defined quota could make problem unsolvable */ 1261 /* Check if defined quota could make problem unsolvable */
1254 if ((n_min * b_min) > quota_out) 1262 if ((n_min * b_min) > quota_out)
@@ -1315,8 +1323,6 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1315 1323
1316 mlp->last_execution = GNUNET_TIME_absolute_get_forever(); 1324 mlp->last_execution = GNUNET_TIME_absolute_get_forever();
1317 1325
1318
1319 mlp->BIG_M = (double) UINT32_MAX;
1320 mlp->co_D = D; 1326 mlp->co_D = D;
1321 mlp->co_R = R; 1327 mlp->co_R = R;
1322 mlp->co_U = U; 1328 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,
94 addr[0].peer.hashPubKey = p[0].hashPubKey; 94 addr[0].peer.hashPubKey = p[0].hashPubKey;
95 struct GNUNET_ATS_Information a1_ats[3]; 95 struct GNUNET_ATS_Information a1_ats[3];
96 set_ats (&a1_ats[0], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); 96 set_ats (&a1_ats[0], GNUNET_ATS_QUALITY_NET_DISTANCE, 1);
97 set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 32); 97 set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 2);
98 set_ats (&a1_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); 98 set_ats (&a1_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0);
99 create_address (&addr[0], "dummy", 3, &a1_ats[0]); 99 create_address (&addr[0], "dummy", 3, &a1_ats[0]);
100 addr[0].atsp_network_type = GNUNET_ATS_NET_WAN; 100 addr[0].atsp_network_type = GNUNET_ATS_NET_LOOPBACK;
101 101
102 102
103 /* Creating peer 1 address 2 */ 103 /* Creating peer 1 address 2 */
@@ -107,7 +107,7 @@ check (void *cls, char *const *args, const char *cfgfile,
107 set_ats (&a2_ats[1], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); 107 set_ats (&a2_ats[1], GNUNET_ATS_QUALITY_NET_DISTANCE, 1);
108 set_ats (&a2_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); 108 set_ats (&a2_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0);
109 create_address (&addr[1], "dummy2", 3, &a2_ats[0]); 109 create_address (&addr[1], "dummy2", 3, &a2_ats[0]);
110 addr[1].atsp_network_type = GNUNET_ATS_NET_WAN; 110 addr[1].atsp_network_type = GNUNET_ATS_NET_LAN;
111 111
112 /* Creating peer 2 address 1 */ 112 /* Creating peer 2 address 1 */
113 addr[2].peer.hashPubKey = p[1].hashPubKey; 113 addr[2].peer.hashPubKey = p[1].hashPubKey;
@@ -116,7 +116,7 @@ check (void *cls, char *const *args, const char *cfgfile,
116 set_ats (&a3_ats[1], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); 116 set_ats (&a3_ats[1], GNUNET_ATS_QUALITY_NET_DISTANCE, 1);
117 set_ats (&a3_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); 117 set_ats (&a3_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0);
118 create_address (&addr[2], "dummy3", 3, &a3_ats[0]); 118 create_address (&addr[2], "dummy3", 3, &a3_ats[0]);
119 addr[2].atsp_network_type = GNUNET_ATS_NET_LAN; 119 addr[2].atsp_network_type = GNUNET_ATS_NET_WAN;
120 120
121 GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[0], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 121 GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[0], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
122 122