aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-03-29 20:04:43 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-03-29 20:04:43 +0000
commit7b5a560a6b822e8ad2e32fd7e3f0bf0e0030844e (patch)
tree83af1a933f866f1855f2346277ff0d820764389c /src/transport
parentff5e94e712ab79a7c4347450f05f52986a22391a (diff)
downloadgnunet-7b5a560a6b822e8ad2e32fd7e3f0bf0e0030844e.tar.gz
gnunet-7b5a560a6b822e8ad2e32fd7e3f0bf0e0030844e.zip
and executing the MLP
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport.c75
1 files changed, 67 insertions, 8 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 839e3fd38..da563e091 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -5578,7 +5578,7 @@ struct ATS_peer
5578}; 5578};
5579 5579
5580 5580
5581static void ats_create_problem (int max_it, int max_dur ) 5581static int ats_create_problem (int max_it, int max_dur )
5582{ 5582{
5583#if !HAVE_LIBGLPK 5583#if !HAVE_LIBGLPK
5584 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "no glpk installed\n"); 5584 if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "no glpk installed\n");
@@ -5591,6 +5591,7 @@ static void ats_create_problem (int max_it, int max_dur )
5591 5591
5592 int c_peers = 0; 5592 int c_peers = 0;
5593 int c_mechs = 0; 5593 int c_mechs = 0;
5594 int result;
5594 5595
5595 int c_c_ressources = 0; 5596 int c_c_ressources = 0;
5596 int c_q_metrics = 0; 5597 int c_q_metrics = 0;
@@ -5620,7 +5621,7 @@ static void ats_create_problem (int max_it, int max_dur )
5620 if (c_mechs==0) 5621 if (c_mechs==0)
5621 { 5622 {
5622 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No addresses for bw distribution available\n", c_peers); 5623 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No addresses for bw distribution available\n", c_peers);
5623 return; 5624 return 0;
5624 } 5625 }
5625 5626
5626 struct ATS_mechanism * mechanisms = GNUNET_malloc((1+c_mechs) * sizeof (struct ATS_mechanism)); 5627 struct ATS_mechanism * mechanisms = GNUNET_malloc((1+c_mechs) * sizeof (struct ATS_mechanism));
@@ -5696,15 +5697,14 @@ static void ats_create_problem (int max_it, int max_dur )
5696 { 5697 {
5697 GNUNET_asprintf(&name, "n%i",c); 5698 GNUNET_asprintf(&name, "n%i",c);
5698 glp_set_col_name(prob, c, "n1"); 5699 glp_set_col_name(prob, c, "n1");
5699 glp_set_col_bnds(prob, c, GLP_LO, 0.0, 0.0); 5700 glp_set_col_bnds(prob, c, GLP_DB, 0.0, 1.0);
5700 glp_set_col_bnds(prob, c, GLP_LO, 0.0, 1.0);
5701 glp_set_col_kind(prob, c, GLP_IV); 5701 glp_set_col_kind(prob, c, GLP_IV);
5702 glp_set_obj_coef(prob, c, 1.0); 5702 glp_set_obj_coef(prob, c, 1.0);
5703 GNUNET_free (name); 5703 GNUNET_free (name);
5704 } 5704 }
5705 5705
5706 /* feasibility constraints */ 5706 /* feasibility constraints */
5707 /* one address per peer*/ 5707 /* Constraint 1: one address per peer*/
5708 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 1\n"); 5708 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 1\n");
5709 row_index = 1; 5709 row_index = 1;
5710 glp_add_rows(prob, c_peers); 5710 glp_add_rows(prob, c_peers);
@@ -5727,7 +5727,7 @@ static void ats_create_problem (int max_it, int max_dur )
5727 GNUNET_assert (row_index-1==c_peers); 5727 GNUNET_assert (row_index-1==c_peers);
5728 GNUNET_assert (array_index==c_mechs); 5728 GNUNET_assert (array_index==c_mechs);
5729 5729
5730 /* Constraint 1: only active mechanism gets bandwidth assigned */ 5730 /* Constraint 2: only active mechanism gets bandwidth assigned */
5731 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 2\n"); 5731 if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 2\n");
5732 glp_add_rows(prob, c_mechs); 5732 glp_add_rows(prob, c_mechs);
5733 for (c=1; c<=c_mechs; c++) 5733 for (c=1; c<=c_mechs; c++)
@@ -5822,6 +5822,62 @@ static void ats_create_problem (int max_it, int max_dur )
5822 5822
5823 glp_load_matrix(prob, array_index-1, ia, ja, ar); 5823 glp_load_matrix(prob, array_index-1, ia, ja, ar);
5824 5824
5825 /* Solve the LP problem */
5826 glp_smcp opt ;
5827 glp_init_smcp(&opt);
5828
5829 /* maximum iterations */
5830 opt.it_lim = max_it;
5831 /* maximum duration */
5832 opt.tm_lim = max_dur;
5833 opt.presolve = GLP_ON;
5834 /* output level */
5835 if (DEBUG_ATS)
5836 opt.msg_lev = GLP_MSG_ALL;
5837 else
5838 opt.msg_lev = GLP_MSG_OFF;
5839
5840 result = glp_simplex(prob, &opt);
5841
5842 switch (result) {
5843 case GLP_ESTOP : /* search terminated by application */
5844 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Search terminated by application ");
5845 break;
5846 case GLP_EITLIM : /* iteration limit exceeded */
5847 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Iteration limit exceeded ");
5848 break;
5849 break;
5850 case GLP_ETMLIM : /* time limit exceeded */
5851 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Time limit exceeded ");
5852 break;
5853 case GLP_ENOFEAS: /* no primal/dual feasible solution */
5854 case GLP_ENOCVG : /* no convergence */
5855 case GLP_ERANGE : /* result out of range */
5856 case GLP_ENOPFS : /* no primal feasible solution */
5857 case GLP_ENODFS : /* no dual feasible solution */
5858 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No feasible solution");
5859 break;
5860
5861 case GLP_EBADB : /* invalid basis */
5862 case GLP_ESING : /* singular matrix */
5863 case GLP_ECOND : /* ill-conditioned matrix */
5864 case GLP_EBOUND : /* invalid bounds */
5865 case GLP_EFAIL : /* solver failed */
5866 case GLP_EOBJLL : /* objective lower limit reached */
5867 case GLP_EOBJUL : /* objective upper limit reached */
5868 case GLP_EROOT : /* root LP optimum not provided */
5869 case GLP_EMIPGAP: /* relative mip gap tolerance reached */
5870 case GLP_EINSTAB: /* numerical instability */
5871 case GLP_EDATA : /* invalid data */
5872 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid Input data\n");
5873 break;
5874
5875 break;
5876 default:
5877 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Optimal solution\n");
5878 break;
5879 }
5880
5825 glp_delete_prob(prob); 5881 glp_delete_prob(prob);
5826 5882
5827 /* clean up */ 5883 /* clean up */
@@ -5832,6 +5888,8 @@ static void ats_create_problem (int max_it, int max_dur )
5832 5888
5833 GNUNET_free(mechanisms); 5889 GNUNET_free(mechanisms);
5834 GNUNET_free(peers); 5890 GNUNET_free(peers);
5891
5892 return c_mechs;
5835} 5893}
5836 5894
5837/* To remove: just for testing */ 5895/* To remove: just for testing */
@@ -5892,12 +5950,13 @@ void ats_benchmark (int peers, int transports, int start_peers, int end_peers)
5892 // test // 5950 // test //
5893 * 5951 *
5894 */ 5952 */
5953 int c_mechs = 0;
5895 start = GNUNET_TIME_absolute_get(); 5954 start = GNUNET_TIME_absolute_get();
5896 ats_create_problem(5000,5000); 5955 c_mechs = ats_create_problem(5000,5000);
5897 5956
5898 duration = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); 5957 duration = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get());
5899 5958
5900 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "benchmark result: %llu\n", duration); 5959 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "benchmark execution time in [ms] for %i mechanisms: %llu\n", c_mechs, duration.rel_value);
5901 5960
5902 GNUNET_STATISTICS_set (stats, "ATS execution time 100 peers", duration.rel_value, GNUNET_NO); 5961 GNUNET_STATISTICS_set (stats, "ATS execution time 100 peers", duration.rel_value, GNUNET_NO);
5903} 5962}