* @author Christian Grothoff
*/
#include "platform.h"
-
+#include "gnunet_statistics_service.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 VERBOSE GNUNET_EXTRA_LOGGING
+#define DEBUG_MLP GNUNET_EXTRA_LOGGING
#define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3)
#define MLP_MAX_ITERATIONS INT_MAX
+/**
+ * MLP Handle
+ */
struct GAS_MLP_Handle
{
+ /**
+ * Statistics handle
+ */
+ struct GNUNET_STATISTICS_Handle *stats;
+
/**
* GLPK (MLP) problem object
*/
*/
unsigned int max_iterations;
+ /* state information */
+
+ /**
+ * Do we need to use the LP presolver?
+ *
+ * If the problem addresses were added or removed and the last basis was we
+ * need to use the presolver.
+ * presolver_required == GNUNET_YES
+ *
+ * If values were modified, we can reuse a valid basis
+ * presolver_required == GNUNET_NO
+ */
+ int presolver_required;
+
+ /* statistics */
+
+ /**
+ * Time of last execution
+ */
+ struct GNUNET_TIME_Absolute last_execution;
+
+
+ /**
+ * How often was the LP problem solved
+ */
+ unsigned int lp_solved;
+
+ /**
+ * total duration of all lp solver executions
+ */
+ uint64_t lp_total_duration;
+
+ /**
+ * How often was the MLP problem solved
+ */
+ unsigned int mlp_solved;
+
+ /**
+ * total duration of all mlp solver executions
+ */
+ uint64_t mlp_total_duration;
};
+
+/**
+ * Address specific MLP information
+ */
+struct MLP_information
+{
+
+};
+
+
/**
* Init the MLP problem solving component
+ *
+ * @param stats the GNUNET_STATISTICS handle
* @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);
+GAS_mlp_init (const struct GNUNET_STATISTICS_Handle *stats,
+ struct GNUNET_TIME_Relative max_duration,
+ unsigned int max_iterations);
/**
- * Update address in the MLP problem
+ * 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_update (struct ATS_Address *address);
+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