aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-02-25 10:43:04 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-02-25 10:43:04 +0000
commitc0edc2399fb6153df47c19445b502345524b935a (patch)
treedf304ff4b935e959c77d9c598a6e547ad976170a
parent2a72aaba9f1eab7bff73c67c531c43e8e8562c73 (diff)
downloadgnunet-c0edc2399fb6153df47c19445b502345524b935a.tar.gz
gnunet-c0edc2399fb6153df47c19445b502345524b935a.zip
fixes
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c31
-rw-r--r--src/ats/test_ats_mlp.c6
2 files changed, 15 insertions, 22 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c
index d5ea73519..704062e07 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.c
+++ b/src/ats/gnunet-service-ats_addresses_mlp.c
@@ -931,7 +931,7 @@ mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashC
931 * b_t + (-M) * n_t <= 0 931 * b_t + (-M) * n_t <= 0
932 * */ 932 * */
933 GNUNET_asprintf(&name, "c1_%s_%s", GNUNET_i2s(&address->peer), address->plugin); 933 GNUNET_asprintf(&name, "c1_%s_%s", GNUNET_i2s(&address->peer), address->plugin);
934 mlpi->r_c1 = mlp_create_problem_create_constraint (p, name, GLP_LO, 0.0, 0.0); 934 mlpi->r_c1 = mlp_create_problem_create_constraint (p, name, GLP_UP, 0.0, 0.0);
935 GNUNET_free (name); 935 GNUNET_free (name);
936 936
937 /* c1) set b = 1 coefficient */ 937 /* c1) set b = 1 coefficient */
@@ -949,7 +949,7 @@ mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashC
949 /* c3) set b = 1 coefficient */ 949 /* c3) set b = 1 coefficient */
950 mlp_create_problem_set_value (p, mlpi->r_c3, mlpi->c_b, 1, __LINE__); 950 mlp_create_problem_set_value (p, mlpi->r_c3, mlpi->c_b, 1, __LINE__);
951 /* c3) set n = -b_min coefficient */ 951 /* c3) set n = -b_min coefficient */
952 mlp_create_problem_set_value (p, mlpi->r_c3, mlpi->c_n, -mlp->pv.b_min, __LINE__); 952 mlp_create_problem_set_value (p, mlpi->r_c3, mlpi->c_n, - ((double )mlp->pv.b_min), __LINE__);
953 953
954 954
955 /* Set coefficient entries in invariant rows */ 955 /* Set coefficient entries in invariant rows */
@@ -979,23 +979,7 @@ mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashC
979 /* c 7) Optimize quality */ 979 /* c 7) Optimize quality */
980 /* For all quality metrics, set quality of this address */ 980 /* For all quality metrics, set quality of this address */
981 for (c = 0; c < mlp->pv.m_q; c++) 981 for (c = 0; c < mlp->pv.m_q; c++)
982 {
983#if 0
984 mlpi = ta->solver_information;
985 value = mlpi->q_averaged[c];
986
987 mlpi->r_q[c] = p->r_q[c];
988
989 ia[p->ci] = p->r_q[c];
990 ja[p->ci] = mlpi->c_b;
991 ar[p->ci] = tp->f_q[c] * value;
992#if DEBUG_MLP_PROBLEM_CREATION
993 LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Set value [%u,%u] == %.2f\n",
994 p->ia[p->ci], p->ja[p->ci], p->ar[p->ci]);
995#endif
996#endif
997 mlp_create_problem_set_value (p, p->r_q[c], mlpi->c_b, mlpi->q_averaged[c], __LINE__); 982 mlp_create_problem_set_value (p, p->r_q[c], mlpi->c_b, mlpi->q_averaged[c], __LINE__);
998 }
999 983
1000 984
1001 return GNUNET_OK; 985 return GNUNET_OK;
@@ -1024,7 +1008,7 @@ mlp_create_problem_add_invariant_rows (struct GAS_MLP_Handle *mlp, struct MLP_Pr
1024 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) 1008 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
1025 { 1009 {
1026 char * text; 1010 char * text;
1027 GNUNET_asprintf(&text, "quota_ats_%s", GNUNET_ATS_print_network_type(mlp->pv.quota_index[c])); 1011 GNUNET_asprintf(&text, "c10_quota_ats_%s", GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]));
1028 p->r_quota[c] = mlp_create_problem_create_constraint (p, text, GLP_DB, 0.0, mlp->pv.quota_out[c]); 1012 p->r_quota[c] = mlp_create_problem_create_constraint (p, text, GLP_DB, 0.0, mlp->pv.quota_out[c]);
1029 GNUNET_free (text); 1013 GNUNET_free (text);
1030 } 1014 }
@@ -1102,6 +1086,7 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas
1102 p->num_elements = (10 * p->num_addresses + mlp->pv.m_q * p->num_addresses + mlp->pv.m_q + p->num_peers + 2 + 1); 1086 p->num_elements = (10 * p->num_addresses + mlp->pv.m_q * p->num_addresses + mlp->pv.m_q + p->num_peers + 2 + 1);
1103 LOG (GNUNET_ERROR_TYPE_DEBUG, "Rebuilding problem for %u peer(s) and %u addresse(s) and %u quality metrics == %u elements\n", 1087 LOG (GNUNET_ERROR_TYPE_DEBUG, "Rebuilding problem for %u peer(s) and %u addresse(s) and %u quality metrics == %u elements\n",
1104 p->num_peers, p->num_addresses, mlp->pv.m_q, p->num_elements); 1088 p->num_peers, p->num_addresses, mlp->pv.m_q, p->num_elements);
1089 LOG (GNUNET_ERROR_TYPE_DEBUG, "Rebuilding %u \n", mlp->pv.b_min);
1105 1090
1106 /* Set a problem name */ 1091 /* Set a problem name */
1107 glp_set_prob_name (p->prob, "GNUnet ATS bandwidth distribution"); 1092 glp_set_prob_name (p->prob, "GNUnet ATS bandwidth distribution");
@@ -1324,6 +1309,14 @@ GAS_mlp_solve_problem (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addr
1324 (unsigned long long) duration_lp.rel_value, 1309 (unsigned long long) duration_lp.rel_value,
1325 (unsigned long long) duration_mlp.rel_value); 1310 (unsigned long long) duration_mlp.rel_value);
1326 1311
1312 /* Store LP */
1313#if DUMP_PROBLEM
1314 char *filename;
1315 GNUNET_asprintf (&filename, "problem_%llu.lp", GNUNET_TIME_absolute_get().abs_value);
1316 glp_write_lp (mlp->p.prob, 0, filename);
1317 GNUNET_free (filename);
1318#endif
1319
1327 /* Propagate result*/ 1320 /* Propagate result*/
1328 if (GNUNET_OK == res) 1321 if (GNUNET_OK == res)
1329 { 1322 {
diff --git a/src/ats/test_ats_mlp.c b/src/ats/test_ats_mlp.c
index 7ca8aaaf1..c43f740c3 100644
--- a/src/ats/test_ats_mlp.c
+++ b/src/ats/test_ats_mlp.c
@@ -201,7 +201,7 @@ check (void *cls, char *const *args, const char *cfgfile,
201 } 201 }
202 202
203 /* Create address 3 */ 203 /* Create address 3 */
204 address[2] = create_address (&p[1], "test_plugin", "test_addr2", strlen("test_addr2")+1, 0); 204 address[2] = create_address (&p[1], "test_plugin2", "test_addr2", strlen("test_addr2")+1, 0);
205 if (NULL == address[2]) 205 if (NULL == address[2])
206 { 206 {
207 GNUNET_break (0); 207 GNUNET_break (0);
@@ -217,7 +217,7 @@ check (void *cls, char *const *args, const char *cfgfile,
217 217
218 218
219 /* Create address 0 */ 219 /* Create address 0 */
220 address[0] = create_address (&p[0], "test_plugin", "test_addr0", strlen("test_addr0")+1, 0); 220 address[0] = create_address (&p[0], "test_plugin0", "test_addr0", strlen("test_addr0")+1, 0);
221 if (NULL == address[0]) 221 if (NULL == address[0])
222 { 222 {
223 GNUNET_break (0); 223 GNUNET_break (0);
@@ -240,7 +240,7 @@ check (void *cls, char *const *args, const char *cfgfile,
240 GAS_mlp_get_preferred_address (mlp, addresses, &p[0]); 240 GAS_mlp_get_preferred_address (mlp, addresses, &p[0]);
241 241
242 /* Create address 1 */ 242 /* Create address 1 */
243 address[1] = create_address (&p[0], "test_plugin", "test_addr1", strlen("test_addr1")+1, 0); 243 address[1] = create_address (&p[0], "test_plugin1", "test_addr1", strlen("test_addr1")+1, 0);
244 if (NULL == address[1]) 244 if (NULL == address[1])
245 { 245 {
246 GNUNET_break (0); 246 GNUNET_break (0);