/* last +1 caused by glpk index starting with one: [1..elements]*/
p->ci = 1;
/* row index */
- int *ia = GNUNET_malloc (p->num_elements * sizeof (int));
- p->ia = ia;
+ p->ia = GNUNET_malloc (p->num_elements * sizeof (int));
/* column index */
- int *ja = GNUNET_malloc (p->num_elements * sizeof (int));
- p->ja = ja;
+ p->ja = GNUNET_malloc (p->num_elements * sizeof (int));
/* coefficient */
- double *ar= GNUNET_malloc (p->num_elements * sizeof (double));
- p->ar = ar;
+ p->ar = GNUNET_malloc (p->num_elements * sizeof (double));
+
+ if ((NULL == p->ia) || (NULL == p->ja) || (NULL == p->ar))
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR, _("Problem size too large, cannot allocate memory!\n"));
+ return GNUNET_SYSERR;
+ }
/* Adding invariant columns */
mlp_create_problem_add_invariant_columns (mlp, p);
mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp)
{
int res = 0;
- if (GNUNET_YES == mlp->mlp_prob_changed)
- {
- /* Problem was recreated: use LP presolver */
- mlp->control_param_lp.presolve = GLP_ON;
- }
- else
- {
- /* Problem was not recreated: do not use LP presolver */
- mlp->control_param_lp.presolve = GLP_OFF;
- }
res = glp_simplex(mlp->p.prob, &mlp->control_param_lp);
if (0 == res)
LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving LP problem: 0x%02X %s\n", res, mlp_solve_to_string(res));
else
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving LP problem failed: 0x%02X %s\n", res, mlp_solve_to_string(res));
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Solving LP problem failed: 0x%02X %s\n", res, mlp_solve_to_string(res));
/* Analyze problem status */
res = glp_get_status (mlp->p.prob);
return GNUNET_OK;
/* Problem was ill-defined, no way to handle that */
default:
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving LP problem failed, no solution: 0x%02X %s\n",
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Solving LP problem failed, no solution: 0x%02X %s\n",
res, mlp_status_to_string(res));
return GNUNET_SYSERR;
}
if (0 == res)
LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving MLP problem: 0x%02X %s\n", res, mlp_solve_to_string(res));
else
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Solving MLP problem failed: 0x%02X %s\n", res, mlp_solve_to_string(res));
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Solving MLP problem failed: 0x%02X %s\n", res, mlp_solve_to_string(res));
/* Analyze problem status */
res = glp_mip_status(mlp->p.prob);
switch (res) {
return GNUNET_OK;
/* Problem was ill-defined, no way to handle that */
default:
- LOG (GNUNET_ERROR_TYPE_DEBUG,"Solving MLP problem failed, 0x%02X %s\n\n", res, mlp_status_to_string(res));
+ LOG (GNUNET_ERROR_TYPE_WARNING,"Solving MLP problem failed, 0x%02X %s\n\n", res, mlp_status_to_string(res));
return GNUNET_SYSERR;
}
}
LOG (GNUNET_ERROR_TYPE_DEBUG, "Problem size changed, rebuilding\n");
mlp_delete_problem (mlp);
start_build = GNUNET_TIME_absolute_get();
- mlp_create_problem (mlp, addresses);
+ if (GNUNET_SYSERR == mlp_create_problem (mlp, addresses))
+ return GNUNET_SYSERR;
duration_build = GNUNET_TIME_absolute_get_duration (start_build);
mlp->control_param_lp.presolve = GLP_YES;
+ mlp->control_param_mlp.presolve = GNUNET_NO; /* No presolver, we have LP solution */
}
else
{
mlp->ps.build_dur = duration_build;
mlp->ps.lp_dur = duration_lp;
mlp->ps.mip_dur = duration_mlp;
+ mlp->ps.lp_presolv = mlp->control_param_lp.presolve;
+ mlp->ps.mip_presolv = mlp->control_param_mlp.presolve;
+ mlp->ps.p_cols = glp_get_num_cols (mlp->p.prob);
+ mlp->ps.p_rows = glp_get_num_rows (mlp->p.prob);
+ mlp->ps.p_elements = mlp->p.num_elements;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Execution time: Build %llu ms, LP %llu ms, MLP %llu ms\n",
(unsigned long long) duration_build.rel_value,
ret = res;
}
-static void
-end_correctly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
-
-}
-
static void
bandwidth_changed_cb (void *cls, struct ATS_Address *address)
{
GAS_mlp_solve_problem (mlp, addresses);
- fprintf (stderr, "Solving problem for %u peers with each %u addresses (build/LP/MIP in ms): %llu %llu %llu\n",
+ fprintf (stderr, "%u peers each %u addresses; state [%s/%s], (build/LP/MIP in ms): %04llu %04llu %04llu; presolv LP/MIP [%s/%s]; size (cols x rows, nonzero elements): [%u x %u] = %u\n",
cp + 1, ca,
+ (GNUNET_OK == mlp->ps.lp_res) ? "OK" : "FAIL",
+ (GNUNET_OK == mlp->ps.mip_res) ? "OK" : "FAIL",
(unsigned long long) mlp->ps.build_dur.rel_value,
(unsigned long long) mlp->ps.lp_dur.rel_value,
- (unsigned long long) mlp->ps.mip_dur.rel_value);
+ (unsigned long long) mlp->ps.mip_dur.rel_value,
+ (GLP_YES == mlp->ps.lp_presolv) ? "YES" : "NO",
+ (GNUNET_OK == mlp->ps.mip_presolv) ? "YES" : "NO",
+ mlp->ps.p_cols, mlp->ps.p_rows, mlp->ps.p_elements);
}
}
if (0 != atoi(argv[c+1]))
{
N_peers_start = atoi(argv[c+1]);
- fprintf (stderr, "peers_start: %u\n",N_peers_start );
}
}
if ((0 == strcmp (argv[c], "-w")) && (c < argc))
if (0 != atoi(argv[c+1]))
{
N_peers_end = atoi(argv[c+1]);
- fprintf (stderr, "peers_end: %u\n",N_peers_end );
}
}
if ((0 == strcmp (argv[c], "-a")) && (c < argc))
if (0 != atoi(argv[c+1]))
{
N_address = atoi(argv[c+1]);
- fprintf (stderr, "address: %u\n",N_address );
}
}
}