- fix doxygen
[oweals/gnunet.git] / src / ats / gnunet-service-ats_addresses_mlp.h
index f1a045ddab0823129420432225a084d207c9587b..8f60a8598954d9968ec34ad77acc4af11df187b5 100644 (file)
@@ -36,6 +36,8 @@
 
 #define DEBUG_MLP GNUNET_EXTRA_LOGGING
 
+#define MLP_AVERAGING_QUEUE_LENGTH 3
+
 #define MLP_MAX_EXEC_DURATION   GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3)
 #define MLP_MAX_ITERATIONS      INT_MAX
 
@@ -48,11 +50,26 @@ struct ATS_Peer
 
   /* Array of quality preferences */
   double f_q[GNUNET_ATS_QualityPropertiesCount];
+  /* Legacy preference value */
+  double f;
+
+  /* constraint 2: 1 address per peer*/
+  unsigned int r_c2;
+
+  /* constraint 9: relativity */
+  unsigned int r_c9;
 
   struct ATS_Address *head;
   struct ATS_Address *tail;
 };
 
+struct ATS_PreferedAddress
+{
+  uint32_t bandwidth_out;
+  uint32_t bandwidth_in;
+  struct ATS_Address *address;
+};
+
 /**
  * MLP Handle
  */
@@ -104,6 +121,13 @@ struct GAS_MLP_Handle
    */
   unsigned int max_iterations;
 
+  /**
+   * Solve the problem automatically when updates occur?
+   * Default: GNUNET_YES
+   * Can be disabled for test and measurements
+   */
+  int auto_solve;
+
   /* state information */
 
   /**
@@ -167,10 +191,16 @@ struct GAS_MLP_Handle
   unsigned int cm_size;
   unsigned int ci;
 
+  /* Row index constraint 2: */
+  unsigned int r_c2;
   /* Row index constraint 4: minimum connections */
   unsigned int r_c4;
   /* Row index constraint 6: maximize diversity */
   unsigned int r_c6;
+  /* Row index constraint 8: utilization*/
+  unsigned int r_c8;
+  /* Row index constraint 9: relativity*/
+  unsigned int r_c9;
 
   /* column index Diversity (D) column */
   int c_d;
@@ -193,12 +223,22 @@ struct GAS_MLP_Handle
   /* column index quality metrics  */
   int c_q[GNUNET_ATS_QualityPropertiesCount];
 
+  /* column index quality metrics  */
+  int r_q[GNUNET_ATS_QualityPropertiesCount];
+
   /* quality metric coefficients*/
   double co_Q[GNUNET_ATS_QualityPropertiesCount];
 
   /* number of quality metrics */
   int m_q;
 
+  /* ATS network quotas */
+  int c_quota[GNUNET_ATS_NetworkTypeCount];
+  int r_quota[GNUNET_ATS_NetworkTypeCount];
+  int quota_index [GNUNET_ATS_NetworkTypeCount];
+  unsigned long long quota_out[GNUNET_ATS_NetworkTypeCount];
+  unsigned long long quota_in[GNUNET_ATS_NetworkTypeCount];
+
   /* ATS ressource costs
    *
    * array with GNUNET_ATS_QualityPropertiesCount elements
@@ -227,6 +267,10 @@ struct GAS_MLP_Handle
  */
 struct MLP_information
 {
+  double b;
+
+  int n;
+
   /* bandwidth column index */
   signed int c_b;
 
@@ -240,6 +284,18 @@ struct MLP_information
 
   /* constraint 3: minimum bandwidth */
   unsigned int r_c3;
+
+  /* Quality information row indices */
+  unsigned int r_q[GNUNET_ATS_QualityPropertiesCount];
+
+  /* Quality information */
+  double q[GNUNET_ATS_QualityPropertiesCount][MLP_AVERAGING_QUEUE_LENGTH];
+
+  /* Quality information averaged */
+  double q_averaged[GNUNET_ATS_QualityPropertiesCount];
+
+  /* Averaging index */
+  int q_avg_i[GNUNET_ATS_QualityPropertiesCount];
 };
 
 
@@ -258,6 +314,15 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
               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);
+
 
 /**
  * Updates a single address in the MLP problem
@@ -297,7 +362,7 @@ GAS_mlp_address_delete (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult
  * @param mlp the MLP Handle
  * @param peer the peer
  * @param kind the kind to change the preference
- * @param float the score
+ * @param score the score
  */
 void
 GAS_mlp_address_change_preference (struct GAS_MLP_Handle *mlp,
@@ -306,6 +371,19 @@ GAS_mlp_address_change_preference (struct GAS_MLP_Handle *mlp,
                                    float score);
 
 
+/**
+ * Get the preferred address for a specific peer
+ *
+ * @param mlp 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,
+                               struct GNUNET_CONTAINER_MultiHashMap * addresses,
+                               const struct GNUNET_PeerIdentity *peer);
+
 /**
  * Shutdown the MLP problem solving component
  */