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
check_PROGRAMS = \
- test_ats_api_scheduling
+ test_ats_api_scheduling \
+ $(GN_MLP_TEST)
# test_ats_api_scheduling_get_type
# test_ats_api_bandwidth_consumption
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 = \
#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,
{
/* 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;
#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
*/
#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)
+{
+
}
/**
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);
}
* @author Christian Grothoff
*/
#include "platform.h"
+#include "gnunet-service-ats_addresses.h"
#if HAVE_LIBGLPK
#include "glpk.h"
#endif
#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
{
/**
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