gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r19109 - gnunet/src/ats
Date: Thu, 12 Jan 2012 15:49:27 +0100

Author: wachs
Date: 2012-01-12 15:49:27 +0100 (Thu, 12 Jan 2012)
New Revision: 19109

Modified:
   gnunet/src/ats/Makefile.am
   gnunet/src/ats/gnunet-service-ats_addresses.c
   gnunet/src/ats/gnunet-service-ats_addresses.h
   gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
   gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
Log:
- mlp


Modified: gnunet/src/ats/Makefile.am
===================================================================
--- gnunet/src/ats/Makefile.am  2012-01-12 13:39:59 UTC (rev 19108)
+++ gnunet/src/ats/Makefile.am  2012-01-12 14:49:27 UTC (rev 19109)
@@ -16,6 +16,7 @@
 if HAVE_LIBGLPK
   GN_LIBGLPK = -lglpk
   GN_MLP_SRC = gnunet-service-ats_addresses_mlp.c 
gnunet-service-ats_addresses_mlp.h
+  GN_MLP_TEST = test_ats_mlp
 endif
 
 lib_LTLIBRARIES = libgnunetats.la
@@ -50,7 +51,8 @@
 
 
 check_PROGRAMS = \
- test_ats_api_scheduling
+ test_ats_api_scheduling \
+ $(GN_MLP_TEST)
 # test_ats_api_scheduling_get_type
 # test_ats_api_bandwidth_consumption
 
@@ -58,6 +60,15 @@
 TESTS = $(check_PROGRAMS)
 endif
 
+if HAVE_LIBGLPK
+test_ats_mlp_SOURCES = \
+ $(GN_MLP_SRC) \
+ test_ats_mlp.c
+test_ats_mlp_LDADD = \
+  $(GN_LIBGLPK) \
+  $(top_builddir)/src/util/libgnunetutil.la
+endif
+
 test_ats_api_scheduling_SOURCES = \
  test_ats_api_scheduling.c
 test_ats_api_scheduling_LDADD = \

Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c       2012-01-12 13:39:59 UTC 
(rev 19108)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c       2012-01-12 14:49:27 UTC 
(rev 19109)
@@ -33,49 +33,6 @@
 #include "gnunet-service-ats_scheduling.h"
 #include "gnunet-service-ats_reservations.h"
 
-struct ATS_Address
-{
-  struct GNUNET_PeerIdentity peer;
-
-  size_t addr_len;
-
-  uint32_t session_id;
-
-  uint32_t ats_count;
-
-  const void *addr;
-
-  char *plugin;
-
-  struct GNUNET_ATS_Information *ats;
-
-  struct GNUNET_TIME_Relative atsp_latency;
-
-  struct GNUNET_BANDWIDTH_Value32NBO atsp_utilization_in;
-
-  struct GNUNET_BANDWIDTH_Value32NBO atsp_utilization_out;
-
-  uint32_t atsp_distance;
-
-  uint32_t atsp_cost_wan;
-
-  uint32_t atsp_cost_lan;
-
-  uint32_t atsp_cost_wlan;
-
-  uint32_t atsp_network_type;
-
-  struct GNUNET_BANDWIDTH_Value32NBO assigned_bw_in;
-
-  struct GNUNET_BANDWIDTH_Value32NBO assigned_bw_out;
-
-  /**
-   * Is this the active address for this peer?
-   */
-  int active;
-
-};
-
 enum ATS_Mode
 {
        SIMPLE,
@@ -501,15 +458,16 @@
   {
        /* MLP = YES */
        case GNUNET_YES:
-#if !HAVE_LIBGLPK
-               GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, 
but libglpk is not installed, switching to simple mode");
-               ats_mode = SIMPLE;
-               break;
+#if HAVE_LIBGLPK
+          ats_mode = MLP;
+          /* Init the MLP solver with default values */
+          GAS_mlp_init (MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
+          break;
 #else
-               ats_mode = MLP;
-               GAS_mlp_init ();
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but 
libglpk is not installed, switching to simple mode");
+          ats_mode = SIMPLE;
+          break;
 #endif
-               break;
        /* MLP = NO */
        case GNUNET_NO:
                ats_mode = SIMPLE;

Modified: gnunet/src/ats/gnunet-service-ats_addresses.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.h       2012-01-12 13:39:59 UTC 
(rev 19108)
+++ gnunet/src/ats/gnunet-service-ats_addresses.h       2012-01-12 14:49:27 UTC 
(rev 19109)
@@ -31,6 +31,49 @@
 #include "gnunet_ats_service.h"
 #include "ats.h"
 
+struct ATS_Address
+{
+  struct GNUNET_PeerIdentity peer;
+
+  size_t addr_len;
+
+  uint32_t session_id;
+
+  uint32_t ats_count;
+
+  const void *addr;
+
+  char *plugin;
+
+  struct GNUNET_ATS_Information *ats;
+
+  struct GNUNET_TIME_Relative atsp_latency;
+
+  struct GNUNET_BANDWIDTH_Value32NBO atsp_utilization_in;
+
+  struct GNUNET_BANDWIDTH_Value32NBO atsp_utilization_out;
+
+  uint32_t atsp_distance;
+
+  uint32_t atsp_cost_wan;
+
+  uint32_t atsp_cost_lan;
+
+  uint32_t atsp_cost_wlan;
+
+  uint32_t atsp_network_type;
+
+  struct GNUNET_BANDWIDTH_Value32NBO assigned_bw_in;
+
+  struct GNUNET_BANDWIDTH_Value32NBO assigned_bw_out;
+
+  /**
+   * Is this the active address for this peer?
+   */
+  int active;
+
+};
+
 /**
  * Initialize address subsystem.
  * @param cfg configuration to use

Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.c   2012-01-12 13:39:59 UTC 
(rev 19108)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.c   2012-01-12 14:49:27 UTC 
(rev 19109)
@@ -26,29 +26,98 @@
  */
 #include "platform.h"
 #include "gnunet_util_lib.h"
+#include "gnunet-service-ats_addresses.h"
 #include "gnunet-service-ats_addresses_mlp.h"
 #if HAVE_LIBGLPK
 #include "glpk.h"
 #endif
 
-struct GAS_MLP_Handle *GAS_mlp;
+/*
+ * The MLP handle
+ */
+static struct GAS_MLP_Handle *GAS_mlp;
 
+
 /**
  * Init the MLP problem solving component
+ *
+ * @param max_duration maximum numbers of iterations for the LP/MLP Solver
+ * @param max_iterations maximum time limit for the LP/MLP Solver
+ * @return GNUNET_OK on success, GNUNET_SYSERR on fail
  */
-void
-GAS_mlp_init ()
+int
+GAS_mlp_init (struct GNUNET_TIME_Relative max_duration, unsigned int 
max_iterations)
 {
   GAS_mlp = GNUNET_malloc (sizeof (struct GAS_MLP_Handle));
-  GAS_mlp->prob = NULL;
+
+  /* Init GLPK environment */
+  GNUNET_assert (glp_init_env() == 0);
+
+  /* Create initial MLP problem */
+  GAS_mlp->prob = glp_create_prob();
+  GNUNET_assert (GAS_mlp->prob != NULL);
+
+  GAS_mlp->max_iterations = max_iterations;
+  GAS_mlp->max_exec_duration = max_duration;
+
+  /* Init LP solving parameters */
+  glp_init_smcp(&GAS_mlp->control_param_lp);
+  GAS_mlp->control_param_lp.it_lim = max_iterations;
+  GAS_mlp->control_param_lp.tm_lim = max_duration.rel_value;
+  /* Init MLP solving parameters */
+  glp_init_iocp(&GAS_mlp->control_param_mlp);
+  GAS_mlp->control_param_mlp.tm_lim = max_duration.rel_value;
+
+  return GNUNET_OK;
 }
 
 /**
+ * Updates a single address in the MLP problem
+ *
+ * If the address did not exist before in the problem:
+ * The MLP problem has to be recreated and the problem has to be resolved
+ *
+ * Otherwise the addresses' values can be updated and the existing base can
+ * be reused
+ */
+void
+GAS_mlp_address_update (struct GNUNET_CONTAINER_MultiHashMap * addresses, 
struct ATS_Address *address)
+{
+
+}
+
+/**
+ * Deletes a single address in the MLP problem
+ *
+ * The MLP problem has to be recreated and the problem has to be resolved
+ */
+void
+GAS_mlp_address_delete (struct GNUNET_CONTAINER_MultiHashMap * addresses, 
struct ATS_Address *address)
+{
+
+}
+
+/**
+ * Deletes a single address in the MLP problem
+ */
+void
+GAS_mlp_address_change_preference (struct GNUNET_CONTAINER_MultiHashMap * 
addresses, struct ATS_Address *address)
+{
+
+}
+
+/**
  * Shutdown the MLP problem solving component
  */
 void
 GAS_mlp_done ()
 {
+  if (GAS_mlp != NULL)
+    glp_delete_prob(GAS_mlp->prob);
+
+  /* Clean up GLPK environment */
+  glp_free_env();
+
   GNUNET_free (GAS_mlp);
 }
 

Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.h   2012-01-12 13:39:59 UTC 
(rev 19108)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.h   2012-01-12 14:49:27 UTC 
(rev 19109)
@@ -25,6 +25,7 @@
  * @author Christian Grothoff
  */
 #include "platform.h"
+#include "gnunet-service-ats_addresses.h"
 #if HAVE_LIBGLPK
 #include "glpk.h"
 #endif
@@ -32,6 +33,10 @@
 #ifndef GNUNET_SERVICE_ATS_ADDRESSES_MLP_H
 #define GNUNET_SERVICE_ATS_ADDRESSES_MLP_H
 
+
+#define MLP_MAX_EXEC_DURATION   
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3)
+#define MLP_MAX_ITERATIONS      INT_MAX
+
 struct GAS_MLP_Handle
 {
   /**
@@ -43,13 +48,42 @@
   void *prob;
 #endif
 
+  /**
+   * GLPK LP control parameter
+   */
+  glp_smcp control_param_lp;
+
+  /**
+   * GLPK LP control parameter
+   */
+  glp_iocp control_param_mlp;
+
+  /**
+   * Maximum execution time per problem solving
+   */
+  struct GNUNET_TIME_Relative max_exec_duration;
+
+  /**
+   * Maximum number of LP iterations per problem solving
+   */
+  unsigned int max_iterations;
+
 };
 
 /**
  * Init the MLP problem solving component
+ * @param max_duration maximum numbers of iterations for the LP/MLP Solver
+ * @param max_iterations maximum time limit for the LP/MLP Solver
+ * @return GNUNET_OK on success, GNUNET_SYSERR on fail
  */
+int
+GAS_mlp_init (struct GNUNET_TIME_Relative max_duration, unsigned int 
max_iterations);
+
+/**
+ * Update address in the MLP problem
+ */
 void
-GAS_mlp_init ();
+GAS_mlp_update (struct ATS_Address *address);
 
 /**
  * Shutdown the MLP problem solving component




reply via email to

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