mlp_term_hook (void *info, const char *s)
{
/* Not needed atm struct MLP_information *mlp = info; */
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", s);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s", s);
return 1;
}
if (index != GNUNET_SYSERR)
{
value = (double) addr->ats[index].value;
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Quality %i with ATS property `%s' has index %i in addresses ats information has value %f\n", c, mlp_ats_to_string(mlp->q[c]), index, (double) addr->ats[index].value);
-#endif
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Quality %i with ATS property `%s' has index %i in addresses ats information has value %f\n", c, mlp_ats_to_string(mlp->q[c]), index, (double) addr->ats[index].value);
+
}
-#if DEBUG_ATS
+
else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Quality %i with ATS property `%s' not existing\n", c, mlp_ats_to_string(mlp->q[c]), index);
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Quality %i with ATS property `%s' not existing\n", c, mlp_ats_to_string(mlp->q[c]), index);
+
mlpi = addr->mlp_information;
mlpi->r_q[c] = mlp->r_q[c];
else
{
/* Problem was ill-defined, no way to handle that */
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
"ats-mlp",
"Solving LP problem failed: %i %s\n", res, mlp_solve_to_string(res));
return GNUNET_SYSERR;
/* Problem was ill-defined, no way to handle that */
default:
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
"ats-mlp",
"Solving LP problem failed, no solution: %s\n", mlp_status_to_string(res));
return GNUNET_SYSERR;
else
{
/* Problem was ill-defined, no way to handle that */
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
"ats-mlp",
"Solving MLP problem failed: %s\n", mlp_solve_to_string(res));
return GNUNET_SYSERR;
/* Problem was ill-defined, no way to handle that */
default:
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
"ats-mlp",
"Solving MLP problem failed, %s\n\n", mlp_status_to_string(res));
return GNUNET_SYSERR;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
-#if DEBUG_ATS
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduled problem solving\n");
-#endif
+
if (mlp->addr_in_problem != 0)
GAS_mlp_solve_problem(mlp);
}
{
int res;
mlp->last_execution = GNUNET_TIME_absolute_get ();
-#if DEBUG_ATS
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solving\n");
-#endif
+
#if WRITE_MLP
char * name;
if (res != GNUNET_OK)
{
-#if DEBUG_ATS
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "LP Problem solving failed\n");
-#endif
+
return GNUNET_SYSERR;
}
# endif
if (res != GNUNET_OK)
{
-#if DEBUG_ATS
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP Problem solving failed\n");
-#endif
+
return GNUNET_SYSERR;
}
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved\n");
-#endif
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved\n");
/* Process result */
+ struct ATS_Peer *p = NULL;
+ struct ATS_Address *a = NULL;
+ struct MLP_information *mlpi = NULL;
+
+ for (p = mlp->peer_head; p != NULL; p = p->next)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s'\n", GNUNET_i2s (&p->id));
+ for (a = p->head; a != NULL; a = a->next)
+ {
+ double b = 0.0;
+ double n = 0.0;
+
+ mlpi = a->mlp_information;
+
+ b = glp_mip_col_val(mlp->prob, mlpi->c_b);
+ n = glp_mip_col_val(mlp->prob, mlpi->c_n);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tAddress %f %f\n", n, b);
+
+ }
+
+ }
+
+
+
if (mlp->mlp_task != GNUNET_SCHEDULER_NO_TASK)
{
/* Init LP solving parameters */
glp_init_smcp(&mlp->control_param_lp);
+
+ mlp->control_param_lp.msg_lev = GLP_MSG_OFF;
#if VERBOSE_GLPK
mlp->control_param_lp.msg_lev = GLP_MSG_ALL;
-#else
- mlp->control_param_lp.msg_lev = GLP_MSG_OFF;
#endif
+
mlp->control_param_lp.it_lim = max_iterations;
mlp->control_param_lp.tm_lim = max_duration.rel_value;
/* Init MLP solving parameters */
glp_init_iocp(&mlp->control_param_mlp);
+
+ mlp->control_param_mlp.msg_lev = GLP_MSG_OFF;
#if VERBOSE_GLPK
mlp->control_param_mlp.msg_lev = GLP_MSG_ALL;
-#else
- mlp->control_param_mlp.msg_lev = GLP_MSG_OFF;
#endif
mlp->control_param_mlp.tm_lim = max_duration.rel_value;
struct ATS_Peer *peer = mlp_find_peer (mlp, &address->peer);
if (peer == NULL)
{
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Adding new peer `%s'\n",
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding new peer `%s'\n",
GNUNET_i2s (&address->peer));
-#endif
+
peer = GNUNET_malloc (sizeof (struct ATS_Peer));
peer->head = NULL;
peer->tail = NULL;
}
else
{
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Adding address to peer `%s'\n",
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding address to peer `%s'\n",
GNUNET_i2s (&address->peer));
-#endif
+
GNUNET_CONTAINER_DLL_insert (peer->head, peer->tail, address);
}
}
else
{
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating existing address to peer `%s'\n",
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating existing address to peer `%s'\n",
GNUNET_i2s (&address->peer));
-#endif
+
mlpi = address->mlp_information;
int c;
for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
{
if (mlpi->q[c] == (double) address->ats[index].value)
break;
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating address for peer `%s' value `%s'from %f to %f\n",
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating address for peer `%s' value `%s'from %f to %f\n",
GNUNET_i2s (&address->peer),
mlp_ats_to_string(mlp->q[c]),
mlpi->q[c],
(double) address->ats[index].value);
-#endif
+
switch (mlp->q[c])
{
case GNUNET_ATS_QUALITY_NET_DELAY:
/* Get the index if matrix row of quality */
for (c2 = 1; c2 <= cols; c2++ )
{
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Existing element column %i : %f\n",
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Existing element column %i : %f\n",
ind[c2], val[c2]);
-#endif
+
if ((mlpi->c_b == ind[c2]) && (val[c2] != mlpi->q[c]))
{
/* Update the value */
val[c2] = mlpi->q[c];
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "New element column %i : %f\n",
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New element column %i : %f\n",
ind[c2], val[c2]);
-#endif
+
}
}
/* Remove from peer list */
struct ATS_Peer *head = mlp_find_peer (mlp, &address->peer);
GNUNET_assert (head != NULL);
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Deleting address for `%s'\n", GNUNET_i2s (&address->peer));
-#endif
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting address for `%s'\n", GNUNET_i2s (&address->peer));
+
GNUNET_CONTAINER_DLL_remove (head->head, head->tail, address);
if ((head->head == NULL) && (head->tail == NULL))
{
/* No address for peer left, remove peer */
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Deleting peer `%s'\n", GNUNET_i2s (&address->peer));
-#endif
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting peer `%s'\n", GNUNET_i2s (&address->peer));
+
GNUNET_CONTAINER_DLL_remove (mlp->peer_head, mlp->peer_tail, head);
GNUNET_free (head);
mlp->c_p --;
addresses = GNUNET_CONTAINER_multihashmap_create (10);
- /* Creating address 1 */
- GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &addr[0].peer.hashPubKey);
+ mlp = GAS_mlp_init (cfg, NULL, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
+ mlp->auto_solve = GNUNET_NO;
+
+ struct GNUNET_PeerIdentity p[10];
+
+ /* Creating peer 1 */
+ GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[0].hashPubKey);
+ /* Creating peer 2 */
+ GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[1].hashPubKey);
+
+ /* Creating peer 1 address 1 */
+ addr[0].peer.hashPubKey = p[0].hashPubKey;
struct GNUNET_ATS_Information a1_ats[3];
set_ats (&a1_ats[0], GNUNET_ATS_QUALITY_NET_DISTANCE, 1);
set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 32);
set_ats (&a1_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0);
create_address (&addr[0], "dummy", 3, &a1_ats[0]);
- GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &addr[1].peer.hashPubKey);
+
+ /* Creating peer 1 address 2 */
+ addr[1].peer.hashPubKey = p[0].hashPubKey;
struct GNUNET_ATS_Information a2_ats[3];
set_ats (&a2_ats[0], GNUNET_ATS_ARRAY_TERMINATOR, 0);
set_ats (&a2_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 32);
set_ats (&a2_ats[2], GNUNET_ATS_QUALITY_NET_DISTANCE, 1);
-
create_address (&addr[1], "dummy2", 3, &a2_ats[0]);
- GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[0], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ /* Creating peer 2 address 1 */
+ addr[2].peer.hashPubKey = p[1].hashPubKey;
+ struct GNUNET_ATS_Information a3_ats[3];
+ set_ats (&a3_ats[0], GNUNET_ATS_ARRAY_TERMINATOR, 0);
+ set_ats (&a3_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 32);
+ set_ats (&a3_ats[2], GNUNET_ATS_QUALITY_NET_DISTANCE, 1);
+ create_address (&addr[2], "dummy3", 3, &a3_ats[0]);
- mlp = GAS_mlp_init (cfg, NULL, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
- mlp->auto_solve = GNUNET_NO;
+ GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[0], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
- /* Add a new address */
+ /* Add peer 1 address 1 */
GAS_mlp_address_update (mlp, addresses, &addr[0]);
GNUNET_assert (mlp != NULL);
GNUNET_assert (mlp->addr_in_problem == 1);
- /* Update an new address */
+ /* Update an peer 1 address 1 */
set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 20);
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[1].peer.hashPubKey, &addr[1], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ /* Add peer 1 address 2 */
+ 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);
+ /* Add peer 2 address 1 */
+ GNUNET_CONTAINER_multihashmap_put(addresses, &addr[2].peer.hashPubKey, &addr[2], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ GAS_mlp_address_update (mlp, addresses, &addr[2]);
+ GNUNET_assert (mlp->addr_in_problem == 3);
+
GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp));
/* Delete an address */
GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[0].peer.hashPubKey, &addr[0]);
GAS_mlp_address_delete (mlp, addresses, &addr[0]);
+ GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[1].peer.hashPubKey, &addr[1]);
GAS_mlp_address_delete (mlp, addresses, &addr[1]);
+ GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[2].peer.hashPubKey, &addr[2]);
+ GAS_mlp_address_delete (mlp, addresses, &addr[2]);
+
+ GNUNET_assert (mlp->addr_in_problem == 0);
GAS_mlp_done (mlp);