Should be compilable without libglpk again
[oweals/gnunet.git] / src / ats / gnunet-service-ats_addresses_mlp.h
index e8db35c27ed4a057160f90fc2d30d90905fbbba8..f0af97dd6b17ec47572b9a78f6dd8a4a3876b4cb 100644 (file)
@@ -20,7 +20,7 @@
 
 /**
  * @file ats/gnunet-service-ats_addresses_mlp.h
- * @brief ats mlp problem solver
+ * @brief ats MLP problem solver
  * @author Matthias Wachs
  * @author Christian Grothoff
  */
@@ -34,8 +34,6 @@
 #ifndef GNUNET_SERVICE_ATS_ADDRESSES_MLP_H
 #define GNUNET_SERVICE_ATS_ADDRESSES_MLP_H
 
-#define DEBUG_MLP GNUNET_EXTRA_LOGGING
-
 #define BIG_M_VALUE (UINT32_MAX) /10
 #define BIG_M_STRING "unlimited"
 
@@ -66,11 +64,12 @@ struct ATS_Peer
   struct ATS_Address *tail;
 };
 
-struct ATS_PreferedAddress
+struct GAS_MLP_SolutionContext
 {
-  uint32_t bandwidth_out;
-  uint32_t bandwidth_in;
-  struct ATS_Address *address;
+  int lp_result;
+  int mlp_result;
+  struct GNUNET_TIME_Relative lp_duration;
+  struct GNUNET_TIME_Relative mlp_duration;
 };
 
 /**
@@ -97,12 +96,20 @@ struct GAS_MLP_Handle
   /**
    * GLPK LP control parameter
    */
+#if HAVE_LIBGLPK
   glp_smcp control_param_lp;
+#else
+  void *control_param_lp;
+#endif
 
   /**
    * GLPK LP control parameter
    */
+#if HAVE_LIBGLPK
   glp_iocp control_param_mlp;
+#else
+  void *control_param_mlp;
+#endif
 
   /**
    * Solves the task in an regular interval
@@ -131,6 +138,8 @@ struct GAS_MLP_Handle
    */
   int auto_solve;
 
+  int semaphore;
+
   /* state information */
 
   /**
@@ -307,24 +316,13 @@ struct MLP_information
  *
  * @param cfg configuration handle
  * @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 struct GAS_MLP_Handle * on success, NULL on fail
+ * @return struct GAS_MLP_Handle on success, NULL on fail
  */
-struct GAS_MLP_Handle *
+void *
 GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
               const struct GNUNET_STATISTICS_Handle *stats,
-              struct GNUNET_TIME_Relative max_duration,
-              unsigned int max_iterations);
-
-/**
- * Solves the MLP problem on demand
- *
- * @param mlp the MLP Handle
- * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
- */
-int
-GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp);
+              int *network,
+              unsigned long long *out_dest, unsigned long long *in_dest, int dest_length);
 
 
 /**
@@ -336,13 +334,15 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp);
  * Otherwise the addresses' values can be updated and the existing base can
  * be reused
  *
- * @param mlp the MLP Handle
+ * @param solver the MLP Handle
  * @param addresses the address hashmap
  *        the address has to be already added from the hashmap
  * @param address the address to update
  */
 void
-GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address);
+GAS_mlp_address_update (void *solver,
+                        struct GNUNET_CONTAINER_MultiHashMap * addresses,
+                        struct ATS_Address *address);
 
 
 /**
@@ -350,25 +350,27 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult
  *
  * The MLP problem has to be recreated and the problem has to be resolved
  *
- * @param mlp the MLP Handle
+ * @param solver the MLP Handle
  * @param addresses the address hashmap
  *        the address has to be already removed from the hashmap
  * @param address the address to delete
  */
 void
-GAS_mlp_address_delete (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address);
+GAS_mlp_address_delete (void *solver,
+                        struct GNUNET_CONTAINER_MultiHashMap *addresses,
+                        struct ATS_Address *address);
 
 
 /**
  * Changes the preferences for a peer in the MLP problem
  *
- * @param mlp the MLP Handle
+ * @param solver the MLP Handle
  * @param peer the peer
  * @param kind the kind to change the preference
  * @param score the score
  */
 void
-GAS_mlp_address_change_preference (struct GAS_MLP_Handle *mlp,
+GAS_mlp_address_change_preference (void *solver,
                                    const struct GNUNET_PeerIdentity *peer,
                                    enum GNUNET_ATS_PreferenceKind kind,
                                    float score);
@@ -377,21 +379,23 @@ GAS_mlp_address_change_preference (struct GAS_MLP_Handle *mlp,
 /**
  * Get the preferred address for a specific peer
  *
- * @param mlp the MLP Handle
+ * @param solver the MLP Handle
  * @param addresses address hashmap
  * @param peer the peer
  * @return suggested address
  */
-struct ATS_PreferedAddress *
-GAS_mlp_get_preferred_address (struct GAS_MLP_Handle *mlp,
+const struct ATS_Address *
+GAS_mlp_get_preferred_address (void *solver,
                                struct GNUNET_CONTAINER_MultiHashMap * addresses,
                                const struct GNUNET_PeerIdentity *peer);
 
 /**
  * Shutdown the MLP problem solving component
+ *
+ * @param solver the solver handle
  */
 void
-GAS_mlp_done ();
+GAS_mlp_done (void *solver);
 
 #endif
 /* end of gnunet-service-ats_addresses_mlp.h */