diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-03-30 13:42:39 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-03-30 13:42:39 +0000 |
commit | ae8e9e180adc07317d15bbdd11fe6605f75dc889 (patch) | |
tree | 68d66be8e9fe42a95d7f0b0630452b700c02025f /src/transport | |
parent | 3612f20a379ee4b9e477e9990b47333aaba882de (diff) | |
download | gnunet-ae8e9e180adc07317d15bbdd11fe6605f75dc889.tar.gz gnunet-ae8e9e180adc07317d15bbdd11fe6605f75dc889.zip |
- mlp presolver is crappy: 0 for all variables is an integer optimal solution -> presolving with simplex solver
-> benefit: glpk version check is not needed anymore and jaunty-arm should be happy
- never forget: in Moscow you start counting with 1!
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 5b76a84cc..aee60294c 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -48,9 +48,6 @@ | |||
48 | 48 | ||
49 | #define DEBUG_TRANSPORT_HELLO GNUNET_NO | 49 | #define DEBUG_TRANSPORT_HELLO GNUNET_NO |
50 | 50 | ||
51 | #define DEBUG_ATS GNUNET_NO | ||
52 | #define VERBOSE_ATS GNUNET_NO | ||
53 | |||
54 | /** | 51 | /** |
55 | * Should we do some additional checks (to validate behavior | 52 | * Should we do some additional checks (to validate behavior |
56 | * of clients)? | 53 | * of clients)? |
@@ -5577,6 +5574,9 @@ struct ATS_peer | |||
5577 | int t; | 5574 | int t; |
5578 | }; | 5575 | }; |
5579 | 5576 | ||
5577 | #define DEBUG_ATS GNUNET_NO | ||
5578 | #define VERBOSE_ATS GNUNET_NO | ||
5579 | |||
5580 | 5580 | ||
5581 | static int ats_create_problem (int max_it, int max_dur ) | 5581 | static int ats_create_problem (int max_it, int max_dur ) |
5582 | { | 5582 | { |
@@ -5680,9 +5680,9 @@ static int ats_create_problem (int max_it, int max_dur ) | |||
5680 | 5680 | ||
5681 | if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating problem with: %i peers, %i mechanisms\n", c_peers, c_mechs); | 5681 | if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating problem with: %i peers, %i mechanisms\n", c_peers, c_mechs); |
5682 | 5682 | ||
5683 | int size = 6 *c_mechs; | 5683 | int size = 1 + 6 *c_mechs; |
5684 | int row_index; | 5684 | int row_index; |
5685 | int array_index=0; | 5685 | int array_index=1; |
5686 | int * ia = GNUNET_malloc (size * sizeof (int)); | 5686 | int * ia = GNUNET_malloc (size * sizeof (int)); |
5687 | int * ja = GNUNET_malloc (size * sizeof (int)); | 5687 | int * ja = GNUNET_malloc (size * sizeof (int)); |
5688 | double * ar = GNUNET_malloc(size* sizeof (double)); | 5688 | double * ar = GNUNET_malloc(size* sizeof (double)); |
@@ -5707,7 +5707,7 @@ static int ats_create_problem (int max_it, int max_dur ) | |||
5707 | /* adding n_t cols */ | 5707 | /* adding n_t cols */ |
5708 | for (c=c_mechs+1; c <= 2*c_mechs; c++) | 5708 | for (c=c_mechs+1; c <= 2*c_mechs; c++) |
5709 | { | 5709 | { |
5710 | GNUNET_asprintf(&name, "n%i",(c-c_mechs)+1); | 5710 | GNUNET_asprintf(&name, "n%i",(c-c_mechs)); |
5711 | glp_set_col_name(prob, c, name); | 5711 | glp_set_col_name(prob, c, name); |
5712 | GNUNET_free (name); | 5712 | GNUNET_free (name); |
5713 | glp_set_col_bnds(prob, c, GLP_DB, 0.0, 1.0); | 5713 | glp_set_col_bnds(prob, c, GLP_DB, 0.0, 1.0); |
@@ -5737,7 +5737,7 @@ static int ats_create_problem (int max_it, int max_dur ) | |||
5737 | row_index++; | 5737 | row_index++; |
5738 | } | 5738 | } |
5739 | GNUNET_assert (row_index-1==c_peers); | 5739 | GNUNET_assert (row_index-1==c_peers); |
5740 | GNUNET_assert (array_index==c_mechs); | 5740 | GNUNET_assert (array_index-1==c_mechs); |
5741 | 5741 | ||
5742 | /* Constraint 2: only active mechanism gets bandwidth assigned */ | 5742 | /* Constraint 2: only active mechanism gets bandwidth assigned */ |
5743 | if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 2\n"); | 5743 | if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 2\n"); |
@@ -5760,8 +5760,8 @@ static int ats_create_problem (int max_it, int max_dur ) | |||
5760 | array_index++; | 5760 | array_index++; |
5761 | row_index ++; | 5761 | row_index ++; |
5762 | } | 5762 | } |
5763 | GNUNET_assert (row_index-1==c_peers+c_mechs); | 5763 | //GNUNET_assert (row_index-1==c_peers+c_mechs); |
5764 | GNUNET_assert (array_index==c_mechs+(2*c_mechs)); | 5764 | //GNUNET_assert (array_index==c_mechs+(2*c_mechs)); |
5765 | 5765 | ||
5766 | /* Constraint 3: minimum bandwidth*/ | 5766 | /* Constraint 3: minimum bandwidth*/ |
5767 | if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 3\n"); | 5767 | if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 3\n"); |
@@ -5784,8 +5784,8 @@ static int ats_create_problem (int max_it, int max_dur ) | |||
5784 | array_index++; | 5784 | array_index++; |
5785 | row_index ++; | 5785 | row_index ++; |
5786 | } | 5786 | } |
5787 | GNUNET_assert (row_index-1==c_peers+(2*c_mechs)); | 5787 | //GNUNET_assert (row_index-1==c_peers+(2*c_mechs)); |
5788 | GNUNET_assert (array_index==c_mechs+(4*c_mechs)); | 5788 | //GNUNET_assert (array_index==c_mechs+(4*c_mechs)); |
5789 | 5789 | ||
5790 | /* Constraint 4: max ressource capacity */ | 5790 | /* Constraint 4: max ressource capacity */ |
5791 | /* | 5791 | /* |
@@ -5829,8 +5829,8 @@ static int ats_create_problem (int max_it, int max_dur ) | |||
5829 | array_index++; | 5829 | array_index++; |
5830 | } | 5830 | } |
5831 | row_index ++; | 5831 | row_index ++; |
5832 | GNUNET_assert (row_index-1==c_peers+(2*c_mechs)+1); | 5832 | //GNUNET_assert (row_index-1==c_peers+(2*c_mechs)+1); |
5833 | GNUNET_assert (array_index==6*c_mechs); | 5833 | //GNUNET_assert (array_index==6*c_mechs); |
5834 | 5834 | ||
5835 | /* optimisation constraints*/ | 5835 | /* optimisation constraints*/ |
5836 | 5836 | ||
@@ -5856,24 +5856,31 @@ static int ats_create_problem (int max_it, int max_dur ) | |||
5856 | GNUNET_free (name); | 5856 | GNUNET_free (name); |
5857 | glp_set_obj_coef(prob, (2*c_mechs) + 3 +c, Q[c]); | 5857 | glp_set_obj_coef(prob, (2*c_mechs) + 3 +c, Q[c]); |
5858 | } | 5858 | } |
5859 | |||
5860 | glp_load_matrix(prob, array_index-1, ia, ja, ar); | 5859 | glp_load_matrix(prob, array_index-1, ia, ja, ar); |
5861 | 5860 | ||
5862 | glp_iocp opt; | ||
5863 | glp_init_iocp(&opt); | ||
5864 | 5861 | ||
5865 | /* Use LP presolver (if not, valid LP solution has to be provided)*/ | 5862 | glp_smcp opt_lp; |
5866 | opt.presolve =GLP_ON; | 5863 | glp_init_smcp(&opt_lp); |
5864 | if (VERBOSE_ATS) | ||
5865 | opt_lp.msg_lev = GLP_MSG_ALL; | ||
5866 | else | ||
5867 | opt_lp.msg_lev = GLP_MSG_OFF; | ||
5868 | result = glp_simplex(prob, &opt_lp); | ||
5869 | |||
5870 | glp_iocp opt_mlp; | ||
5871 | glp_init_iocp(&opt_mlp); | ||
5867 | /* maximum duration */ | 5872 | /* maximum duration */ |
5868 | opt.tm_lim = max_dur; | 5873 | opt_mlp.tm_lim = max_dur; |
5869 | /* output level */ | 5874 | /* output level */ |
5870 | if (VERBOSE_ATS) | 5875 | if (VERBOSE_ATS) |
5871 | opt.msg_lev = GLP_MSG_ALL; | 5876 | opt_mlp.msg_lev = GLP_MSG_ALL; |
5872 | else | 5877 | else |
5873 | opt.msg_lev = GLP_MSG_OFF; | 5878 | opt_mlp.msg_lev = GLP_MSG_OFF; |
5874 | result = glp_intopt (prob, &opt); | 5879 | |
5880 | result = glp_intopt (prob, &opt_mlp); | ||
5875 | solution = glp_mip_status (prob); | 5881 | solution = glp_mip_status (prob); |
5876 | 5882 | ||
5883 | if (VERBOSE_ATS) glp_write_lp(prob, NULL, "ats_mlp.lp"); | ||
5877 | switch (result) { | 5884 | switch (result) { |
5878 | case GLP_ESTOP : /* search terminated by application */ | 5885 | case GLP_ESTOP : /* search terminated by application */ |
5879 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Search terminated by application "); | 5886 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Search terminated by application "); |
@@ -5885,9 +5892,6 @@ static int ats_create_problem (int max_it, int max_dur ) | |||
5885 | case GLP_ETMLIM : /* time limit exceeded */ | 5892 | case GLP_ETMLIM : /* time limit exceeded */ |
5886 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Time limit exceeded "); | 5893 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Time limit exceeded "); |
5887 | break; | 5894 | break; |
5888 | case GLP_ENOFEAS: /* no primal/dual feasible solution */ | ||
5889 | case GLP_ENOCVG : /* no convergence */ | ||
5890 | case GLP_ERANGE : /* result out of range */ | ||
5891 | case GLP_ENOPFS : /* no primal feasible solution */ | 5895 | case GLP_ENOPFS : /* no primal feasible solution */ |
5892 | case GLP_ENODFS : /* no dual feasible solution */ | 5896 | case GLP_ENODFS : /* no dual feasible solution */ |
5893 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No feasible solution"); | 5897 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No feasible solution"); |
@@ -5901,9 +5905,6 @@ static int ats_create_problem (int max_it, int max_dur ) | |||
5901 | case GLP_EOBJLL : /* objective lower limit reached */ | 5905 | case GLP_EOBJLL : /* objective lower limit reached */ |
5902 | case GLP_EOBJUL : /* objective upper limit reached */ | 5906 | case GLP_EOBJUL : /* objective upper limit reached */ |
5903 | case GLP_EROOT : /* root LP optimum not provided */ | 5907 | case GLP_EROOT : /* root LP optimum not provided */ |
5904 | case GLP_EMIPGAP: /* relative mip gap tolerance reached */ | ||
5905 | case GLP_EINSTAB: /* numerical instability */ | ||
5906 | case GLP_EDATA : /* invalid data */ | ||
5907 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid Input data\n"); | 5908 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid Input data\n"); |
5908 | break; | 5909 | break; |
5909 | 5910 | ||
@@ -5943,12 +5944,12 @@ static int ats_create_problem (int max_it, int max_dur ) | |||
5943 | GNUNET_asprintf(&debug_solution, "%s z = %g; \n", debug_solution, glp_get_obj_val(prob)); | 5944 | GNUNET_asprintf(&debug_solution, "%s z = %g; \n", debug_solution, glp_get_obj_val(prob)); |
5944 | if (old!=NULL) GNUNET_free(old); | 5945 | if (old!=NULL) GNUNET_free(old); |
5945 | if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s \n",debug_solution); | 5946 | if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s \n",debug_solution); |
5946 | GNUNET_free(debug_solution); | ||
5947 | |||
5948 | glp_delete_prob(prob); | ||
5949 | 5947 | ||
5950 | /* clean up */ | 5948 | /* clean up */ |
5951 | 5949 | ||
5950 | GNUNET_free(debug_solution); | ||
5951 | glp_delete_prob(prob); | ||
5952 | |||
5952 | GNUNET_free (ja); | 5953 | GNUNET_free (ja); |
5953 | GNUNET_free (ia); | 5954 | GNUNET_free (ia); |
5954 | GNUNET_free (ar); | 5955 | GNUNET_free (ar); |
@@ -5976,7 +5977,7 @@ void ats_benchmark (int peers, int transports, int start_peers, int end_peers) | |||
5976 | { | 5977 | { |
5977 | duration = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); | 5978 | duration = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); |
5978 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP execution time in [ms] for %i mechanisms: %llu\n", c_mechs, duration.rel_value); | 5979 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP execution time in [ms] for %i mechanisms: %llu\n", c_mechs, duration.rel_value); |
5979 | GNUNET_STATISTICS_set (stats, "ATS execution time 100 peers", duration.rel_value, GNUNET_NO); | 5980 | //GNUNET_STATISTICS_set (stats, "ATS execution time 100 peers", duration.rel_value, GNUNET_NO); |
5980 | } | 5981 | } |
5981 | else glpk = GNUNET_NO; | 5982 | else glpk = GNUNET_NO; |
5982 | } | 5983 | } |