- fundamentals for mlp implementation
authorMatthias Wachs <wachs@net.in.tum.de>
Thu, 12 Jan 2012 13:23:14 +0000 (13:23 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Thu, 12 Jan 2012 13:23:14 +0000 (13:23 +0000)
src/ats/Makefile.am
src/ats/gnunet-service-ats_addresses.c
src/ats/gnunet-service-ats_addresses_mlp.c [new file with mode: 0644]
src/ats/gnunet-service-ats_addresses_mlp.h [new file with mode: 0644]

index f2fe12b44716d3b48b2ee8b9cf8db85e10b1e4bd..912912a8ae11c5da27c540f26c2b9eb0e56058dc 100644 (file)
@@ -15,6 +15,7 @@ endif
 
 if HAVE_LIBGLPK
   GN_LIBGLPK = -lglpk
+  GN_MLP_SRC = gnunet-service-ats_addresses_mlp.c gnunet-service-ats_addresses_mlp.h
 endif
 
 lib_LTLIBRARIES = libgnunetats.la
@@ -37,6 +38,7 @@ bin_PROGRAMS = \
 gnunet_service_ats_SOURCES = \
  gnunet-service-ats.c gnunet-service-ats.h\
  gnunet-service-ats_addresses.c gnunet-service-ats_addresses.h \
+ $(GN_MLP_SRC) \
  gnunet-service-ats_performance.c gnunet-service-ats_performance.h \
  gnunet-service-ats_scheduling.c gnunet-service-ats_scheduling.h \
  gnunet-service-ats_reservations.c gnunet-service-ats_reservations.h
index de62379f601f15f078698d65f22f907b544c7d94..5837260b86c6ef941dae461421be8f48070f86a5 100644 (file)
@@ -28,6 +28,7 @@
 #include "gnunet_ats_service.h"
 #include "gnunet-service-ats.h"
 #include "gnunet-service-ats_addresses.h"
+#include "gnunet-service-ats_addresses_mlp.h"
 #include "gnunet-service-ats_performance.h"
 #include "gnunet-service-ats_scheduling.h"
 #include "gnunet-service-ats_reservations.h"
@@ -506,6 +507,7 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
                break;
 #else
                ats_mode = MLP;
+               GAS_mlp_init ();
 #endif
                break;
        /* MLP = NO */
@@ -560,6 +562,10 @@ GAS_addresses_done ()
   GAS_addresses_destroy_all ();
   GNUNET_CONTAINER_multihashmap_destroy (addresses);
   addresses = NULL;
+  if (ats_mode == MLP)
+  {
+    GAS_mlp_done ();
+  }
 }
 
 
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c
new file mode 100644 (file)
index 0000000..6352412
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+     This file is part of GNUnet.
+     (C) 2011 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file ats/gnunet-service-ats_addresses_mlp.c
+ * @brief ats mlp problem solver
+ * @author Matthias Wachs
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet-service-ats_addresses_mlp.h"
+#if HAVE_LIBGLPK
+#include "glpk.h"
+#endif
+
+struct GAS_MLP_Handle *GAS_mlp;
+
+/**
+ * Init the MLP problem solving component
+ */
+void
+GAS_mlp_init ()
+{
+  GAS_mlp = GNUNET_malloc (sizeof (struct GAS_MLP_Handle));
+  GAS_mlp->prob = NULL;
+}
+
+/**
+ * Shutdown the MLP problem solving component
+ */
+void
+GAS_mlp_done ()
+{
+  GNUNET_free (GAS_mlp);
+}
+
+
+/* end of gnunet-service-ats_addresses_mlp.c */
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h
new file mode 100644 (file)
index 0000000..3351ca5
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+     This file is part of GNUnet.
+     (C) 2011 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file ats/gnunet-service-ats_addresses_mlp.h
+ * @brief ats mlp problem solver
+ * @author Matthias Wachs
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#if HAVE_LIBGLPK
+#include "glpk.h"
+#endif
+
+#ifndef GNUNET_SERVICE_ATS_ADDRESSES_MLP_H
+#define GNUNET_SERVICE_ATS_ADDRESSES_MLP_H
+
+struct GAS_MLP_Handle
+{
+  /**
+   * GLPK (MLP) problem object
+   */
+#if HAVE_LIBGLPK
+  glp_prob *prob;
+#else
+  void *prob;
+#endif
+
+};
+
+/**
+ * Init the MLP problem solving component
+ */
+void
+GAS_mlp_init ();
+
+/**
+ * Shutdown the MLP problem solving component
+ */
+void
+GAS_mlp_done ();
+
+#endif
+/* end of gnunet-service-ats_addresses_mlp.h */