From 82892f3f69a9d5ba51dc7acc17b4680292b85f5a Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 12 Jan 2012 13:23:14 +0000 Subject: [PATCH] - fundamentals for mlp implementation --- src/ats/Makefile.am | 2 + src/ats/gnunet-service-ats_addresses.c | 6 +++ src/ats/gnunet-service-ats_addresses_mlp.c | 56 ++++++++++++++++++++ src/ats/gnunet-service-ats_addresses_mlp.h | 61 ++++++++++++++++++++++ 4 files changed, 125 insertions(+) create mode 100644 src/ats/gnunet-service-ats_addresses_mlp.c create mode 100644 src/ats/gnunet-service-ats_addresses_mlp.h diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am index f2fe12b44..912912a8a 100644 --- a/src/ats/Makefile.am +++ b/src/ats/Makefile.am @@ -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 diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index de62379f6..5837260b8 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c @@ -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 index 000000000..6352412f4 --- /dev/null +++ b/src/ats/gnunet-service-ats_addresses_mlp.c @@ -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 index 000000000..3351ca541 --- /dev/null +++ b/src/ats/gnunet-service-ats_addresses_mlp.h @@ -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 */ -- 2.25.1