[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19261 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19261 - gnunet/src/ats |
Date: |
Thu, 19 Jan 2012 17:01:21 +0100 |
Author: wachs
Date: 2012-01-19 17:01:21 +0100 (Thu, 19 Jan 2012)
New Revision: 19261
Modified:
gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
gnunet/src/ats/test_ats_mlp.c
Log:
- more working constraints
Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2012-01-19 15:20:17 UTC
(rev 19260)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.c 2012-01-19 16:01:21 UTC
(rev 19261)
@@ -32,7 +32,8 @@
#include "glpk.h"
#define WRITE_MLP GNUNET_NO
-#define DEBUG_ATS GNUNET_EXTRA_LOGGING
+#define DEBUG_ATS GNUNET_YES
+#define VERBOSE_GLPK GNUNET_NO
/**
* Translate glpk solver error codes to text
@@ -313,7 +314,6 @@
mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct
GNUNET_CONTAINER_MultiHashMap * addresses)
{
unsigned int n_addresses;
- int row_index;
//int c;
char *name;
@@ -357,9 +357,17 @@
* c 7) quality
* #rows: |quality properties|
* #indices:|quality properties| + |n_addresses|
+ *
+ * c 8) utilization
+ * #rows: 1
+ * #indices: |n_addresses| + 1
+ *
+ * c 9) relativity
+ * #rows: |peers|
+ * #indices: |n_addresses| + |peers|
* */
- int pi = ((7 * n_addresses) + (2 * n_addresses + mlp->m_q + 1));
+ int pi = ((7 * n_addresses) + (3 * n_addresses + mlp->m_q + 2));
mlp->cm_size = pi;
mlp->ci = 1;
@@ -412,30 +420,73 @@
*
* c 2) 1 address per peer
* sum (n_p1_1 + ... + n_p1_n) = 1
- */
+ *
+ * c 8) utilization
+ * sum (f_p * b_p1_1 + ... + f_p * b_p1_n) - u = 0
+ *
+ * c 9) relativity
+ * V p : sum (bt_1 + ... +bt_n) - f_p * r = 0
+ * */
- /* Adding rows for c 2) */
- row_index = glp_add_rows (mlp->prob, mlp->c_p);
+ /* Adding rows for c 8) */
+ mlp->r_c8 = glp_add_rows (mlp->prob, mlp->c_p);
+ glp_set_row_name (mlp->prob, mlp->r_c8, "c8");
+ /* Set row bound == 0 */
+ glp_set_row_bnds (mlp->prob, mlp->r_c8, GLP_FX, 0.0, 0.0);
+ /* -u */
+ ia[mlp->ci] = mlp->r_c8;
+ ja[mlp->ci] = mlp->c_u;
+ ar[mlp->ci] = -1;
+ mlp->ci++;
struct ATS_Peer * peer = mlp->peer_head;
while (peer != NULL)
{
struct ATS_Address *addr = peer->head;
struct MLP_information *mlpi = NULL;
- /* Adding row for c 2) */
+
+ /* Adding rows for c 2) */
+ peer->r_c2 = glp_add_rows (mlp->prob, 1);
GNUNET_asprintf(&name, "c2_%s", GNUNET_i2s(&peer->id));
- glp_set_row_name (mlp->prob, row_index, name);
+ glp_set_row_name (mlp->prob, peer->r_c2, name);
GNUNET_free (name);
/* Set row bound == 1 */
- glp_set_row_bnds (mlp->prob, row_index, GLP_FX, 1.0, 1.0);
+ glp_set_row_bnds (mlp->prob, peer->r_c2, GLP_FX, 1.0, 1.0);
+
+ /* Adding rows for c 9) */
+ peer->r_c9 = glp_add_rows (mlp->prob, 1);
+ GNUNET_asprintf(&name, "c9_%s", GNUNET_i2s(&peer->id));
+ glp_set_row_name (mlp->prob, peer->r_c9, name);
+ GNUNET_free (name);
+ /* Set row bound == 0 */
+ glp_set_row_bnds (mlp->prob, peer->r_c9, GLP_LO, 0.0, 0.0);
+
+ /* Set -r */
+ ia[mlp->ci] = peer->r_c9;
+ ja[mlp->ci] = mlp->c_r;
+ ar[mlp->ci] = -1;
+ mlp->ci++;
+
while (addr != NULL)
{
mlpi = (struct MLP_information *) addr->mlp_information;
- ia[mlp->ci] = row_index;
+
+ ia[mlp->ci] = peer->r_c2;
ja[mlp->ci] = mlpi->c_n;
ar[mlp->ci] = 1;
mlp->ci++;
+
+ ia[mlp->ci] = mlp->r_c8;
+ ja[mlp->ci] = mlpi->c_b;
+ ar[mlp->ci] = peer->f;
+ mlp->ci++;
+
+ ia[mlp->ci] = peer->r_c9;
+ ja[mlp->ci] = mlpi->c_b;
+ ar[mlp->ci] = 1;
+ mlp->ci++;
+
addr = addr->next;
}
peer = peer->next;
@@ -553,7 +604,7 @@
glp_set_obj_coef (mlp->prob, col, mlp->co_D);
/* Column lower bound = 0.0 */
glp_set_col_bnds (mlp->prob, col, GLP_LO, 0.0, 0.0);
-#if 0
+
/* Utilization u column */
col = glp_add_cols (mlp->prob, 1);
@@ -574,7 +625,7 @@
glp_set_obj_coef (mlp->prob, col, mlp->co_R);
/* Column lower bound = 0.0 */
glp_set_col_bnds (mlp->prob, col, GLP_LO, 0.0, 0.0);
-
+#if 0
/* Quality metric columns */
col = glp_add_cols(mlp->prob, mlp->m_q);
for (c = 0; c < mlp->m_q; c++)
@@ -841,7 +892,7 @@
}
#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved: %i %s\n", res,
mlp_status_to_string(res));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved\n");
#endif
/* Process result */
@@ -975,7 +1026,7 @@
/* Init LP solving parameters */
glp_init_smcp(&mlp->control_param_lp);
-#if DEBUG_ATS
+#if VERBOSE_GLPK
mlp->control_param_lp.msg_lev = GLP_MSG_ALL;
#else
mlp->control_param_lp.msg_lev = GLP_MSG_OFF;
@@ -985,7 +1036,7 @@
/* Init MLP solving parameters */
glp_init_iocp(&mlp->control_param_mlp);
-#if DEBUG_ATS
+#if VERBOSE_GLPK
mlp->control_param_mlp.msg_lev = GLP_MSG_ALL;
#else
mlp->control_param_mlp.msg_lev = GLP_MSG_OFF;
@@ -1057,6 +1108,7 @@
{
peer->f_q[c] = 1.0;
}
+ peer->f = 1.0;
memcpy (&peer->id, &address->peer, sizeof (struct GNUNET_PeerIdentity));
GNUNET_assert(address->prev == NULL);
Modified: gnunet/src/ats/gnunet-service-ats_addresses_mlp.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses_mlp.h 2012-01-19 15:20:17 UTC
(rev 19260)
+++ gnunet/src/ats/gnunet-service-ats_addresses_mlp.h 2012-01-19 16:01:21 UTC
(rev 19261)
@@ -48,7 +48,15 @@
/* 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;
};
@@ -167,10 +175,16 @@
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;
Modified: gnunet/src/ats/test_ats_mlp.c
===================================================================
--- gnunet/src/ats/test_ats_mlp.c 2012-01-19 15:20:17 UTC (rev 19260)
+++ gnunet/src/ats/test_ats_mlp.c 2012-01-19 16:01:21 UTC (rev 19261)
@@ -29,7 +29,7 @@
#include "gnunet_statistics_service.h"
#include "gnunet-service-ats_addresses_mlp.h"
-#define VERBOSE GNUNET_EXTRA_LOGGING
+#define VERBOSE GNUNET_YES
#define VERBOSE_ARM GNUNET_EXTRA_LOGGING
#define MLP_MAX_EXEC_DURATION
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3)
@@ -53,38 +53,52 @@
ret = 1;
return;
#endif
- struct ATS_Address addr;
+ struct ATS_Address addr[10];
stats = GNUNET_STATISTICS_create("ats", cfg);
addresses = GNUNET_CONTAINER_multihashmap_create (10);
- GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK,
&addr.peer.hashPubKey);
- addr.mlp_information = NULL;
- addr.next = NULL;
- addr.prev = NULL;
- addr.plugin = strdup ("dummy");
- GNUNET_CONTAINER_multihashmap_put(addresses, &addr.peer.hashPubKey, &addr,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK,
&addr[0].peer.hashPubKey);
+ addr[0].mlp_information = NULL;
+ addr[0].next = NULL;
+ addr[0].prev = NULL;
+ addr[0].plugin = strdup ("dummy");
+ addr[1].peer = addr[0].peer;
+ addr[1].mlp_information = NULL;
+ addr[1].next = NULL;
+ addr[1].prev = NULL;
+ addr[1].plugin = strdup ("dummy2");
+
+ GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey,
&addr[0], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+
mlp = GAS_mlp_init (cfg, NULL, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
/* Add a new address */
- GAS_mlp_address_update (mlp, addresses, &addr);
+ GAS_mlp_address_update (mlp, addresses, &addr[0]);
GNUNET_assert (mlp != NULL);
GNUNET_assert (mlp->addr_in_problem == 1);
/* Update an new address */
- GAS_mlp_address_update (mlp, addresses, &addr);
+ GAS_mlp_address_update (mlp, addresses, &addr[0]);
GNUNET_assert (mlp->addr_in_problem == 1);
+ /* Add a second address for same peer */
+ GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey,
&addr[1], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ GAS_mlp_address_update (mlp, addresses, &addr[1]);
+ GNUNET_assert (mlp->addr_in_problem == 2);
+
/* Delete an address */
- GNUNET_CONTAINER_multihashmap_remove (addresses, &addr.peer.hashPubKey,
&addr);
- GAS_mlp_address_delete (mlp, addresses, &addr);
+ GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[0].peer.hashPubKey,
&addr[0]);
+ GAS_mlp_address_delete (mlp, addresses, &addr[0]);
+ GAS_mlp_address_delete (mlp, addresses, &addr[1]);
GAS_mlp_done (mlp);
- GNUNET_free (addr.plugin);
+ GNUNET_free (addr[0].plugin);
+ GNUNET_free (addr[1].plugin);
GNUNET_CONTAINER_multihashmap_destroy (addresses);
GNUNET_STATISTICS_destroy(stats, GNUNET_NO);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19261 - gnunet/src/ats,
gnunet <=