fixing mantis 2098:
[oweals/gnunet.git] / src / ats / gnunet-service-ats_addresses_mlp.h
index 4d55ff6e15076da626e0b8cd752708bfa83d5aa9..43c2b66adfd09e36e954e69f3452c59d1835e006 100644 (file)
@@ -34,7 +34,6 @@
 #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)
@@ -49,6 +48,14 @@ 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;
@@ -73,6 +80,8 @@ struct GAS_MLP_Handle
   void *prob;
 #endif
 
+  double BIG_M;
+
   /**
    * GLPK LP control parameter
    */
@@ -103,6 +112,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 */
 
   /**
@@ -166,8 +182,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;
@@ -190,6 +214,9 @@ 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];
 
@@ -237,6 +264,15 @@ struct MLP_information
 
   /* constraint 3: minimum bandwidth */
   unsigned int r_c3;
+
+  /* Quality information row indices */
+  unsigned int r_q[GNUNET_ATS_QualityPropertiesCount];
+
+  /* Quality information column indices */
+  unsigned int c_q[GNUNET_ATS_QualityPropertiesCount];
+
+  /* Quality information */
+  double q[GNUNET_ATS_QualityPropertiesCount];
 };
 
 
@@ -255,6 +291,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