[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19238 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19238 - gnunet/src/ats |
Date: |
Wed, 18 Jan 2012 14:28:03 +0100 |
Author: wachs
Date: 2012-01-18 14:28:03 +0100 (Wed, 18 Jan 2012)
New Revision: 19238
Modified:
gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
Log:
- constraint 1 & 3
Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2012-01-18 13:08:02 UTC
(rev 19237)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2012-01-18 13:28:03 UTC
(rev 19238)
@@ -32,10 +32,13 @@
#if HAVE_LIBGLPK
#include "glpk.h"
#endif
+#include "float.h"
#define DEBUG_ATS GNUNET_YES
-#define VERY_BIG_DOUBLE_VALUE DBL_MAX
+/* A very big value */
+#define M DBL_MAX
+
/**
* Translate glpk solver error codes to text
* @param retcode return code
@@ -189,6 +192,68 @@
}
/**
+ * Add constraints that are iterating over "forall addresses"
+ * and collects all existing peers for "forall peers" constraints
+ *
+ * @param cls GAS_MLP_Handle
+ * @param key Hashcode
+ * @param value ATS_Address
+ *
+ * @return GNUNET_OK to continue
+ */
+static int
+create_constraint_it (void *cls, const GNUNET_HashCode * key, void *value)
+{
+ struct GAS_MLP_Handle *mlp = cls;
+ struct ATS_Address *address = value;
+ struct MLP_information *mlpi;
+ unsigned int row_index;
+
+ GNUNET_assert (address->mlp_information != NULL);
+ mlpi = (struct MLP_information *) address->mlp_information;
+
+ /* c 1) bandwidth capping
+ * b_t + (-M) * n_t <= 0
+ */
+ row_index = glp_add_rows (mlp->prob, 1);
+ mlpi->r_c1 = row_index;
+ /* set row bounds: <= 0 */
+ glp_set_row_bnds (mlp->prob, row_index, GLP_UP, 0.0, 0.0);
+
+ mlp->ia[mlp->ci] = row_index;
+ mlp->ja[mlp->ci] = mlpi->c_b;
+ mlp->ar[mlp->ci] = 1;
+ mlp->ci++;
+
+ mlp->ia[mlp->ci] = row_index;
+ mlp->ja[mlp->ci] = mlpi->c_b;
+ mlp->ar[mlp->ci] = -M;
+ mlp->ci++;
+
+ /* c 3) minimum bandwidth
+ * b_t + (-n_t * b_min) >= 0
+ */
+
+ row_index = glp_add_rows (mlp->prob, 1);
+ mlpi->r_c3 = row_index;
+ /* set row bounds: >= 0 */
+ glp_set_row_bnds (mlp->prob, row_index, GLP_LO, 0.0, 0.0);
+
+ mlp->ia[mlp->ci] = row_index;
+ mlp->ja[mlp->ci] = mlpi->c_b;
+ mlp->ar[mlp->ci] = 1;
+ mlp->ci++;
+
+ mlp->ia[mlp->ci] = row_index;
+ mlp->ja[mlp->ci] = mlpi->c_b;
+ mlp->ar[mlp->ci] = -mlp->b_min;
+ mlp->ci++;
+
+ return GNUNET_OK;
+}
+
+
+/**
* Adds the problem constraints for all addresses
* Required for problem recreation after address deletion
*
@@ -238,6 +303,7 @@
int pi = (7 * n_addresses);
mlp->cm_size = pi;
+ mlp->ci = 0;
/* row index */
int *ia = GNUNET_malloc (pi * sizeof (int));
@@ -251,11 +317,12 @@
double *ar= GNUNET_malloc (pi * sizeof (double));
mlp->ar = ar;
-
/* Adding constraint rows */
/* Feasibility constraints */
/* c 1) bandwidth capping */
+ /* c 3) minimum bandwidth */
+ GNUNET_CONTAINER_multihashmap_iterate (addresses, create_constraint_it, mlp);
}
Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.h 2012-01-18 13:08:02 UTC
(rev 19237)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.h 2012-01-18 13:28:03 UTC
(rev 19238)
@@ -144,6 +144,7 @@
double *ar;
/* current size of the constraint matrix |indices| */
unsigned int cm_size;
+ unsigned int ci;
/* column index Diversity (D) column */
int c_d;
@@ -189,6 +190,14 @@
/* address usage column */
signed int c_n;
+
+ /* row indexes */
+
+ /* constraint 1: bandwidth capping */
+ unsigned int r_c1;
+
+ /* constraint 3: minimum bandwidth */
+ unsigned int r_c3;
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19238 - gnunet/src/ats,
gnunet <=