gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r20991 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r20991 - gnunet/src/ats
Date: Tue, 17 Apr 2012 12:36:04 +0200

Author: wachs
Date: 2012-04-17 12:36:04 +0200 (Tue, 17 Apr 2012)
New Revision: 20991

Modified:
   gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
   gnunet/src/ats/perf_ats_mlp.c
Log:
- changes


Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.c   2012-04-17 08:42:36 UTC 
(rev 20990)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.c   2012-04-17 10:36:04 UTC 
(rev 20991)
@@ -806,6 +806,14 @@
   return res;
 }
 
+
+struct SolveContext
+{
+  struct GNUNET_TIME_Relative lp_duration;
+  struct GNUNET_TIME_Relative mlp_duration;
+};
+
+
 /**
  * Solves the LP problem
  *
@@ -813,7 +821,7 @@
  * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
  */
 static int
-mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp)
+mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp, struct SolveContext *s_ctx)
 {
   int res;
   struct GNUNET_TIME_Relative duration;
@@ -867,6 +875,7 @@
   duration = GNUNET_TIME_absolute_get_difference (start, end);
   mlp->lp_solved++;
   mlp->lp_total_duration =+ duration.rel_value;
+  s_ctx->lp_duration = duration;
 
   GNUNET_STATISTICS_update (mlp->stats,"# LP problem solved", 1, GNUNET_NO);
   GNUNET_STATISTICS_set (mlp->stats,"# LP execution time (ms)", 
duration.rel_value, GNUNET_NO);
@@ -906,7 +915,7 @@
  * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
  */
 int
-mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp)
+mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp, struct SolveContext *s_ctx)
 {
   int res;
   struct GNUNET_TIME_Relative duration;
@@ -943,6 +952,7 @@
   duration = GNUNET_TIME_absolute_get_difference (start, end);
   mlp->mlp_solved++;
   mlp->mlp_total_duration =+ duration.rel_value;
+  s_ctx->mlp_duration = duration;
 
   GNUNET_STATISTICS_update (mlp->stats,"# MLP problem solved", 1, GNUNET_NO);
   GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time (ms)", 
duration.rel_value, GNUNET_NO);
@@ -989,7 +999,6 @@
     GAS_mlp_solve_problem(mlp);
 }
 
-
 /**
  * Solves the MLP problem
  *
@@ -1000,11 +1009,10 @@
 GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp)
 {
   int res;
+  struct SolveContext s_ctx;
   mlp->last_execution = GNUNET_TIME_absolute_get ();
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solving\n");
-
-
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve LP problem\n");
 #if WRITE_MLP
   char * name;
   static int i;
@@ -1014,39 +1022,34 @@
   GNUNET_free (name);
 # endif
 
-  res = mlp_solve_lp_problem (mlp);
-
+  res = mlp_solve_lp_problem (mlp, &s_ctx);
+  if (res != GNUNET_OK)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "LP Problem solving failed\n");
+    return GNUNET_SYSERR;
+  }
 #if WRITE_MLP
   GNUNET_asprintf(&name, "problem_%i_lp_solution", i);
   glp_print_sol (mlp->prob,  name);
   GNUNET_free (name);
 # endif
 
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve MLP problem\n");
+  res = mlp_solve_mlp_problem (mlp, &s_ctx);
   if (res != GNUNET_OK)
   {
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "LP Problem solving failed\n");
-
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP Problem solving failed\n");
     return GNUNET_SYSERR;
   }
-
-  res = mlp_solve_mlp_problem (mlp);
-
 #if WRITE_MLP
   GNUNET_asprintf(&name, "problem_%i_mlp_solution", i);
   glp_print_mip (mlp->prob, name);
   GNUNET_free (name);
 # endif
-  if (res != GNUNET_OK)
-  {
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP Problem solving failed\n");
-
-    return GNUNET_SYSERR;
-  }
-
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved %s (LP duration %llu / 
MLP duration %llu)\n",
+      (GNUNET_OK == res) ? "successfully" : "failed", s_ctx.lp_duration, 
s_ctx.mlp_duration);
   /* Process result */
   struct ATS_Peer *p = NULL;
   struct ATS_Address *a = NULL;

Modified: gnunet/src/ats/perf_ats_mlp.c
===================================================================
--- gnunet/src/ats/perf_ats_mlp.c       2012-04-17 08:42:36 UTC (rev 20990)
+++ gnunet/src/ats/perf_ats_mlp.c       2012-04-17 10:36:04 UTC (rev 20991)
@@ -88,7 +88,7 @@
   if (addresses == 0)
     addresses = DEF_ADDRESSES_PER_PEER;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up %u peers with %u addresses 
per peer\n", peers, addresses);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up %u peers with %u addresses 
per peer\n", peers, addresses);
 
   struct PeerContext p[peers];
   struct ATS_Address a[addresses * peers];
@@ -99,12 +99,12 @@
   mlp->auto_solve = GNUNET_NO;
   for (c=0; c < peers; c++)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up peer %u\n", c);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up peer %u\n", c);
     GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, 
&p[c].id.hashPubKey);
 
     for (c2=0; c2 < addresses; c2++)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up address %u for peer 
%u\n", c2, c);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up address %u for peer 
%u\n", c2, c);
       /* Setting required information */
       a[ca].mlp_information = NULL;
       a[ca].prev = NULL;
@@ -123,20 +123,25 @@
       a[ca].ats[1].type = GNUNET_ATS_QUALITY_NET_DISTANCE;
       a[ca].ats[1].value = 2;
       a[ca].ats_count = 2;
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up address %u\n", ca);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up address %u\n", ca);
       GNUNET_CONTAINER_multihashmap_put (amap, &a[ca].peer.hashPubKey, &a[ca], 
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
       GAS_mlp_address_update(mlp, amap, &a[ca]);
-
       ca++;
     }
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem contains %u peers and %u 
adresses\n", mlp->c_p, mlp->addr_in_problem);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem contains %u peers and %u 
adresses\n", mlp->c_p, mlp->addr_in_problem);
 
   /* Solving the problem */
-  //GAS_mlp_solve_problem(mlp);
+  if (GNUNET_OK == GAS_mlp_solve_problem(mlp))
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved successfully \n");
+  else
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved failed \n");
 
   GAS_mlp_done (mlp);
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Execution duration %llu\n", 
mlp->max_exec_duration);
+
+
   for (ca=0; ca < (peers * addresses); ca++)
   {
     GNUNET_free (a[ca].plugin);




reply via email to

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