X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fats%2Fgnunet-service-ats_addresses_mlp.h;h=6f7ee73d5b351d1c74040981e61ccb1ef84202ec;hb=f181f6eaf8cdb1fdb47dc98cf171ad1be842b441;hp=3351ca54154b548d0124b3443214e855e6f3c1a2;hpb=82892f3f69a9d5ba51dc7acc17b4680292b85f5a;p=oweals%2Fgnunet.git diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h index 3351ca541..6f7ee73d5 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.h +++ b/src/ats/gnunet-service-ats_addresses_mlp.h @@ -25,6 +25,8 @@ * @author Christian Grothoff */ #include "platform.h" +#include "gnunet_statistics_service.h" +#include "gnunet-service-ats_addresses.h" #if HAVE_LIBGLPK #include "glpk.h" #endif @@ -32,8 +34,22 @@ #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 */ @@ -43,13 +59,120 @@ 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; + + /* 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 (const struct GNUNET_STATISTICS_Handle *stats, + struct GNUNET_TIME_Relative max_duration, + unsigned int max_iterations); + +/** + * 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_init (); +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