gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r14783 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r14783 - gnunet/src/transport
Date: Wed, 30 Mar 2011 15:42:39 +0200

Author: wachs
Date: 2011-03-30 15:42:39 +0200 (Wed, 30 Mar 2011)
New Revision: 14783

Modified:
   gnunet/src/transport/gnunet-service-transport.c
Log:
- 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!


Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2011-03-30 12:26:58 UTC 
(rev 14782)
+++ gnunet/src/transport/gnunet-service-transport.c     2011-03-30 13:42:39 UTC 
(rev 14783)
@@ -48,9 +48,6 @@
 
 #define DEBUG_TRANSPORT_HELLO GNUNET_NO
 
-#define DEBUG_ATS GNUNET_NO
-#define VERBOSE_ATS GNUNET_NO
-
 /**
  * Should we do some additional checks (to validate behavior
  * of clients)?
@@ -5577,7 +5574,10 @@
        int     t;
 };
 
+#define DEBUG_ATS GNUNET_NO
+#define VERBOSE_ATS GNUNET_NO
 
+
 static int ats_create_problem (int max_it, int max_dur )
 {
 #if !HAVE_LIBGLPK
@@ -5680,9 +5680,9 @@
 
        if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating problem 
with: %i peers, %i mechanisms\n", c_peers, c_mechs);
 
-       int size = 6 *c_mechs;
+       int size = 1 + 6 *c_mechs;
        int row_index;
-       int array_index=0;
+       int array_index=1;
        int * ia = GNUNET_malloc (size * sizeof (int));
        int * ja = GNUNET_malloc (size * sizeof (int));
        double * ar = GNUNET_malloc(size* sizeof (double));
@@ -5707,7 +5707,7 @@
        /* adding n_t cols */
        for (c=c_mechs+1; c <= 2*c_mechs; c++)
        {
-               GNUNET_asprintf(&name, "n%i",(c-c_mechs)+1);
+               GNUNET_asprintf(&name, "n%i",(c-c_mechs));
                glp_set_col_name(prob, c, name);
                GNUNET_free (name);
                glp_set_col_bnds(prob, c, GLP_DB, 0.0, 1.0);
@@ -5737,7 +5737,7 @@
                row_index++;
        }
        GNUNET_assert (row_index-1==c_peers);
-       GNUNET_assert (array_index==c_mechs);
+       GNUNET_assert (array_index-1==c_mechs);
 
        /* Constraint 2: only active mechanism gets bandwidth assigned */
        if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 2\n");
@@ -5760,8 +5760,8 @@
                array_index++;
                row_index ++;
        }
-       GNUNET_assert (row_index-1==c_peers+c_mechs);
-       GNUNET_assert (array_index==c_mechs+(2*c_mechs));
+       //GNUNET_assert (row_index-1==c_peers+c_mechs);
+       //GNUNET_assert (array_index==c_mechs+(2*c_mechs));
 
        /* Constraint 3: minimum bandwidth*/
        if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 3\n");
@@ -5784,8 +5784,8 @@
                array_index++;
                row_index ++;
        }
-       GNUNET_assert (row_index-1==c_peers+(2*c_mechs));
-       GNUNET_assert (array_index==c_mechs+(4*c_mechs));
+       //GNUNET_assert (row_index-1==c_peers+(2*c_mechs));
+       //GNUNET_assert (array_index==c_mechs+(4*c_mechs));
 
        /* Constraint 4: max ressource capacity */
        /*
@@ -5829,8 +5829,8 @@
                array_index++;
        }
        row_index ++;
-       GNUNET_assert (row_index-1==c_peers+(2*c_mechs)+1);
-       GNUNET_assert (array_index==6*c_mechs);
+       //GNUNET_assert (row_index-1==c_peers+(2*c_mechs)+1);
+       //GNUNET_assert (array_index==6*c_mechs);
 
        /* optimisation constraints*/
 
@@ -5856,24 +5856,31 @@
                GNUNET_free (name);
                glp_set_obj_coef(prob, (2*c_mechs) + 3 +c, Q[c]);
        }
-
        glp_load_matrix(prob, array_index-1, ia, ja, ar);
 
-       glp_iocp opt;
-       glp_init_iocp(&opt);
 
-       /* Use LP presolver (if not, valid LP solution has to be provided)*/
-       opt.presolve =GLP_ON;
+       glp_smcp opt_lp;
+       glp_init_smcp(&opt_lp);
+       if (VERBOSE_ATS)
+               opt_lp.msg_lev = GLP_MSG_ALL;
+       else
+               opt_lp.msg_lev = GLP_MSG_OFF;
+       result = glp_simplex(prob, &opt_lp);
+
+       glp_iocp opt_mlp;
+       glp_init_iocp(&opt_mlp);
        /* maximum duration */
-       opt.tm_lim = max_dur;
+       opt_mlp.tm_lim = max_dur;
        /* output level */
        if (VERBOSE_ATS)
-               opt.msg_lev = GLP_MSG_ALL;
+               opt_mlp.msg_lev = GLP_MSG_ALL;
        else
-               opt.msg_lev = GLP_MSG_OFF;
-       result = glp_intopt (prob, &opt);
+               opt_mlp.msg_lev = GLP_MSG_OFF;
+
+       result = glp_intopt (prob, &opt_mlp);
        solution =  glp_mip_status (prob);
 
+       if (VERBOSE_ATS) glp_write_lp(prob, NULL, "ats_mlp.lp");
        switch (result) {
        case GLP_ESTOP  :    /* search terminated by application */
                GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Search terminated by 
application ");
@@ -5885,9 +5892,6 @@
        case GLP_ETMLIM :    /* time limit exceeded */
                GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Time limit exceeded ");
        break;
-       case GLP_ENOFEAS:    /* no primal/dual feasible solution */
-       case GLP_ENOCVG :    /* no convergence */
-       case GLP_ERANGE :        /* result out of range */
        case GLP_ENOPFS :    /* no primal feasible solution */
        case GLP_ENODFS :    /* no dual feasible solution */
                GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No feasible solution");
@@ -5901,9 +5905,6 @@
        case GLP_EOBJLL :    /* objective lower limit reached */
        case GLP_EOBJUL :    /* objective upper limit reached */
        case GLP_EROOT  :    /* root LP optimum not provided */
-       case GLP_EMIPGAP:    /* relative mip gap tolerance reached */
-       case GLP_EINSTAB:    /* numerical instability */
-       case GLP_EDATA  :    /* invalid data */
                GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid Input data\n");
        break;
 
@@ -5943,12 +5944,12 @@
        GNUNET_asprintf(&debug_solution, "%s z = %g; \n", debug_solution,  
glp_get_obj_val(prob));
        if (old!=NULL) GNUNET_free(old);
        if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s 
\n",debug_solution);
+
+       /* clean up */
+
        GNUNET_free(debug_solution);
-
        glp_delete_prob(prob);
 
-       /* clean up */
-
        GNUNET_free (ja);
        GNUNET_free (ia);
        GNUNET_free (ar);
@@ -5976,7 +5977,7 @@
                {
                duration = 
GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get());
                GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP execution time in 
[ms] for %i mechanisms: %llu\n", c_mechs, duration.rel_value);
-               GNUNET_STATISTICS_set (stats, "ATS execution time 100 peers", 
duration.rel_value, GNUNET_NO);
+               //GNUNET_STATISTICS_set (stats, "ATS execution time 100 peers", 
duration.rel_value, GNUNET_NO);
                }
                else glpk = GNUNET_NO;
        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]