aboutsummaryrefslogtreecommitdiff
path: root/src/ats/plugin_ats_mlp.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-05-13 11:42:08 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-05-13 11:42:08 +0000
commit9e524a56b9cfd4ea3fadbd62a74a76f4d99092bc (patch)
treebb6a69977ba1e6e4e9873ca104c96b659c2249d1 /src/ats/plugin_ats_mlp.c
parentd703e3932d3d5833d6c70f486fe27c1936775b2e (diff)
downloadgnunet-9e524a56b9cfd4ea3fadbd62a74a76f4d99092bc.tar.gz
gnunet-9e524a56b9cfd4ea3fadbd62a74a76f4d99092bc.zip
increase numerical stability: replace BIG_M with network quota
Diffstat (limited to 'src/ats/plugin_ats_mlp.c')
-rw-r--r--src/ats/plugin_ats_mlp.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c
index 21da08136..f168c08a3 100644
--- a/src/ats/plugin_ats_mlp.c
+++ b/src/ats/plugin_ats_mlp.c
@@ -632,7 +632,9 @@ mlp_create_problem_add_address_information (void *cls,
632 struct MLP_information *mlpi; 632 struct MLP_information *mlpi;
633 char *name; 633 char *name;
634 const double *props; 634 const double *props;
635 double cur_bigm;
635 uint32_t addr_net; 636 uint32_t addr_net;
637 uint32_t addr_net_index;
636 int c; 638 int c;
637 639
638 /* Check if we have to add this peer due to a pending request */ 640 /* Check if we have to add this peer due to a pending request */
@@ -647,6 +649,19 @@ mlp_create_problem_add_address_information (void *cls,
647 return GNUNET_OK; 649 return GNUNET_OK;
648 } 650 }
649 651
652 addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE);
653 for (addr_net_index = 0; addr_net_index < GNUNET_ATS_NetworkTypeCount; addr_net_index++)
654 {
655 if (mlp->pv.quota_index[addr_net_index] == addr_net)
656 break;
657 }
658
659 if (addr_net_index >= GNUNET_ATS_NetworkTypeCount)
660 {
661 GNUNET_break (0);
662 return GNUNET_OK;
663 }
664
650 /* Get peer */ 665 /* Get peer */
651 peer = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, key); 666 peer = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, key);
652 if (peer->processed == GNUNET_NO) 667 if (peer->processed == GNUNET_NO)
@@ -701,7 +716,10 @@ mlp_create_problem_add_address_information (void *cls,
701 /* c1) set b = 1 coefficient */ 716 /* c1) set b = 1 coefficient */
702 mlp_create_problem_set_value (p, mlpi->r_c1, mlpi->c_b, 1, __LINE__); 717 mlp_create_problem_set_value (p, mlpi->r_c1, mlpi->c_b, 1, __LINE__);
703 /* c1) set n = -M coefficient */ 718 /* c1) set n = -M coefficient */
704 mlp_create_problem_set_value (p, mlpi->r_c1, mlpi->c_n, -mlp->pv.BIG_M, __LINE__); 719 cur_bigm = (double) mlp->pv.quota_out[addr_net_index];
720 if (cur_bigm > mlp->pv.BIG_M)
721 cur_bigm = (double) mlp->pv.BIG_M;
722 mlp_create_problem_set_value (p, mlpi->r_c1, mlpi->c_n, -cur_bigm, __LINE__);
705 723
706 /* Add constraint c 3) minimum bandwidth 724 /* Add constraint c 3) minimum bandwidth
707 * b_t + (-n_t * b_min) >= 0 725 * b_t + (-n_t * b_min) >= 0
@@ -727,6 +745,9 @@ mlp_create_problem_add_address_information (void *cls,
727 /* c 10) obey network specific quotas 745 /* c 10) obey network specific quotas
728 * (1)*b_1 + ... + (1)*b_m <= quota_n 746 * (1)*b_1 + ... + (1)*b_m <= quota_n
729 */ 747 */
748 mlp_create_problem_set_value (p, p->r_quota[addr_net_index], mlpi->c_b, 1, __LINE__);
749
750#if 0
730 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) 751 for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
731 { 752 {
732 addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE); 753 addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE);
@@ -742,6 +763,7 @@ mlp_create_problem_add_address_information (void *cls,
742 break; 763 break;
743 } 764 }
744 } 765 }
766#endif
745 767
746 /* Optimality */ 768 /* Optimality */
747 if (GNUNET_NO == mlp->opt_dbg_feasibility_only) 769 if (GNUNET_NO == mlp->opt_dbg_feasibility_only)
@@ -1251,8 +1273,6 @@ GAS_mlp_solve_problem (void *solver)
1251 mlp->control_param_mlp.presolve = GNUNET_YES; 1273 mlp->control_param_mlp.presolve = GNUNET_YES;
1252 res_mip = mlp_solve_mlp_problem(mlp); 1274 res_mip = mlp_solve_mlp_problem(mlp);
1253 1275
1254 fprintf (stderr, "%u\n", res_mip);
1255
1256 dur_mlp = GNUNET_TIME_absolute_get_duration (start_cur_op); 1276 dur_mlp = GNUNET_TIME_absolute_get_duration (start_cur_op);
1257 dur_total = GNUNET_TIME_absolute_get_duration (start_total); 1277 dur_total = GNUNET_TIME_absolute_get_duration (start_total);
1258 1278
@@ -1307,8 +1327,8 @@ GAS_mlp_solve_problem (void *solver)
1307 GAS_INFO_NONE); 1327 GAS_INFO_NONE);
1308 1328
1309 struct GNUNET_TIME_Absolute time = GNUNET_TIME_absolute_get(); 1329 struct GNUNET_TIME_Absolute time = GNUNET_TIME_absolute_get();
1310 if ( (GNUNET_YES == mlp->opt_dump_solution_all) || 1330 if ( (GNUNET_YES == mlp->opt_dump_problem_all) ||
1311 (mlp->opt_dump_solution_on_fail && ((GNUNET_OK != res_lp) || (GNUNET_OK != res_mip))) ) 1331 (mlp->opt_dump_problem_on_fail && ((GNUNET_OK != res_lp) || (GNUNET_OK != res_mip))) )
1312 { 1332 {
1313 /* Write problem to disk */ 1333 /* Write problem to disk */
1314 GNUNET_asprintf(&filename, "problem_p_%u_a%u_%llu.lp", mlp->p.num_peers, 1334 GNUNET_asprintf(&filename, "problem_p_%u_a%u_%llu.lp", mlp->p.num_peers,
@@ -2043,6 +2063,9 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2043 "ats", "MLP_DUMP_PROBLEM_ALL"); 2063 "ats", "MLP_DUMP_PROBLEM_ALL");
2044 if (GNUNET_SYSERR == mlp->opt_dump_problem_all) 2064 if (GNUNET_SYSERR == mlp->opt_dump_problem_all)
2045 mlp->opt_dump_problem_all = GNUNET_NO; 2065 mlp->opt_dump_problem_all = GNUNET_NO;
2066 if (GNUNET_YES == mlp->opt_dump_problem_all)
2067 GNUNET_break (0);
2068
2046 2069
2047 mlp->opt_dump_solution_all = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, 2070 mlp->opt_dump_solution_all = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
2048 "ats", "MLP_DUMP_SOLUTION_ALL"); 2071 "ats", "MLP_DUMP_SOLUTION_ALL");
@@ -2185,13 +2208,15 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2185 mlp->pv.quota_index[c] = env->networks[c2]; 2208 mlp->pv.quota_index[c] = env->networks[c2];
2186 mlp->pv.quota_out[c] = env->out_quota[c2]; 2209 mlp->pv.quota_out[c] = env->out_quota[c2];
2187 mlp->pv.quota_in[c] = env->in_quota[c2]; 2210 mlp->pv.quota_in[c] = env->in_quota[c2];
2211
2188 found = GNUNET_YES; 2212 found = GNUNET_YES;
2189 LOG (GNUNET_ERROR_TYPE_DEBUG, 2213 LOG (GNUNET_ERROR_TYPE_ERROR,
2190 "Quota for network `%s' (in/out) %llu/%llu\n", 2214 "Quota for network `%s' (in/out) %llu/%llu\n",
2191 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]), 2215 GNUNET_ATS_print_network_type(mlp->pv.quota_index[c]),
2192 mlp->pv.quota_out[c], 2216 mlp->pv.quota_out[c],
2193 mlp->pv.quota_in[c]); 2217 mlp->pv.quota_in[c]);
2194 break; 2218 break;
2219
2195 } 2220 }
2196 } 2221 }
2197 2222