return res;
}
+
+struct SolveContext
+{
+ struct GNUNET_TIME_Relative lp_duration;
+ struct GNUNET_TIME_Relative mlp_duration;
+};
+
+
/**
* Solves the LP problem
*
* @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
*/
static int
-mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp)
+mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp, struct SolveContext *s_ctx)
{
int res;
struct GNUNET_TIME_Relative duration;
duration = GNUNET_TIME_absolute_get_difference (start, end);
mlp->lp_solved++;
mlp->lp_total_duration =+ duration.rel_value;
+ s_ctx->lp_duration = duration;
GNUNET_STATISTICS_update (mlp->stats,"# LP problem solved", 1, GNUNET_NO);
GNUNET_STATISTICS_set (mlp->stats,"# LP execution time (ms)", duration.rel_value, GNUNET_NO);
* @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
*/
int
-mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp)
+mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp, struct SolveContext *s_ctx)
{
int res;
struct GNUNET_TIME_Relative duration;
duration = GNUNET_TIME_absolute_get_difference (start, end);
mlp->mlp_solved++;
mlp->mlp_total_duration =+ duration.rel_value;
+ s_ctx->mlp_duration = duration;
GNUNET_STATISTICS_update (mlp->stats,"# MLP problem solved", 1, GNUNET_NO);
GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time (ms)", duration.rel_value, GNUNET_NO);
GAS_mlp_solve_problem(mlp);
}
-
/**
* Solves the MLP problem
*
GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp)
{
int res;
+ struct SolveContext s_ctx;
mlp->last_execution = GNUNET_TIME_absolute_get ();
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solving\n");
-
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve LP problem\n");
#if WRITE_MLP
char * name;
static int i;
GNUNET_free (name);
# endif
- res = mlp_solve_lp_problem (mlp);
-
+ res = mlp_solve_lp_problem (mlp, &s_ctx);
+ if (res != GNUNET_OK)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "LP Problem solving failed\n");
+ return GNUNET_SYSERR;
+ }
#if WRITE_MLP
GNUNET_asprintf(&name, "problem_%i_lp_solution", i);
glp_print_sol (mlp->prob, name);
GNUNET_free (name);
# endif
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve MLP problem\n");
+ res = mlp_solve_mlp_problem (mlp, &s_ctx);
if (res != GNUNET_OK)
{
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "LP Problem solving failed\n");
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP Problem solving failed\n");
return GNUNET_SYSERR;
}
-
- res = mlp_solve_mlp_problem (mlp);
-
#if WRITE_MLP
GNUNET_asprintf(&name, "problem_%i_mlp_solution", i);
glp_print_mip (mlp->prob, name);
GNUNET_free (name);
# endif
- if (res != GNUNET_OK)
- {
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP Problem solving failed\n");
-
- return GNUNET_SYSERR;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved %s (LP duration %llu / MLP duration %llu)\n",
+ (GNUNET_OK == res) ? "successfully" : "failed", s_ctx.lp_duration, s_ctx.mlp_duration);
/* Process result */
struct ATS_Peer *p = NULL;
struct ATS_Address *a = NULL;
if (addresses == 0)
addresses = DEF_ADDRESSES_PER_PEER;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up %u peers with %u addresses per peer\n", peers, addresses);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up %u peers with %u addresses per peer\n", peers, addresses);
struct PeerContext p[peers];
struct ATS_Address a[addresses * peers];
mlp->auto_solve = GNUNET_NO;
for (c=0; c < peers; c++)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up peer %u\n", c);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up peer %u\n", c);
GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[c].id.hashPubKey);
for (c2=0; c2 < addresses; c2++)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up address %u for peer %u\n", c2, c);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up address %u for peer %u\n", c2, c);
/* Setting required information */
a[ca].mlp_information = NULL;
a[ca].prev = NULL;
a[ca].ats[1].type = GNUNET_ATS_QUALITY_NET_DISTANCE;
a[ca].ats[1].value = 2;
a[ca].ats_count = 2;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up address %u\n", ca);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up address %u\n", ca);
GNUNET_CONTAINER_multihashmap_put (amap, &a[ca].peer.hashPubKey, &a[ca], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
GAS_mlp_address_update(mlp, amap, &a[ca]);
-
ca++;
}
}
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem contains %u peers and %u adresses\n", mlp->c_p, mlp->addr_in_problem);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem contains %u peers and %u adresses\n", mlp->c_p, mlp->addr_in_problem);
/* Solving the problem */
- //GAS_mlp_solve_problem(mlp);
+ if (GNUNET_OK == GAS_mlp_solve_problem(mlp))
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved successfully \n");
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved failed \n");
GAS_mlp_done (mlp);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Execution duration %llu\n", mlp->max_exec_duration);
+
+
for (ca=0; ca < (peers * addresses); ca++)
{
GNUNET_free (a[ca].plugin);