switch (retcode) {
case 0:
return "ok";
- break;
case GLP_EBADB:
return "invalid basis";
- break;
case GLP_ESING:
return "singular matrix";
- break;
case GLP_ECOND:
return "ill-conditioned matrix";
- break;
case GLP_EBOUND:
return "invalid bounds";
- break;
case GLP_EFAIL:
return "solver failed";
- break;
case GLP_EOBJLL:
return "objective lower limit reached";
- break;
case GLP_EOBJUL:
return "objective upper limit reached";
- break;
case GLP_EITLIM:
return "iteration limit exceeded";
- break;
case GLP_ETMLIM:
return "time limit exceeded";
- break;
case GLP_ENOPFS:
return "no primal feasible solution";
- break;
case GLP_EROOT:
return "root LP optimum not provided";
- break;
case GLP_ESTOP:
return "search terminated by application";
- break;
case GLP_EMIPGAP:
return "relative mip gap tolerance reached";
- break;
case GLP_ENOFEAS:
return "no dual feasible solution";
- break;
case GLP_ENOCVG:
return "no convergence";
- break;
case GLP_EINSTAB:
return "numerical instability";
- break;
case GLP_EDATA:
return "invalid data";
- break;
case GLP_ERANGE:
return "result out of range";
- break;
default:
GNUNET_break (0);
return "unknown error";
- break;
}
- GNUNET_break (0);
- return "unknown error";
}
switch (retcode) {
case GLP_UNDEF:
return "solution is undefined";
- break;
case GLP_FEAS:
return "solution is feasible";
- break;
case GLP_INFEAS:
return "solution is infeasible";
- break;
case GLP_NOFEAS:
return "no feasible solution exists";
- break;
case GLP_OPT:
return "solution is optimal";
- break;
case GLP_UNBND:
return "solution is unbounded";
- break;
default:
GNUNET_break (0);
return "unknown error";
- break;
}
- GNUNET_break (0);
- return "unknown error";
}
/**
switch (ats_index) {
case GNUNET_ATS_ARRAY_TERMINATOR:
return "GNUNET_ATS_ARRAY_TERMINATOR";
- break;
case GNUNET_ATS_UTILIZATION_UP:
return "GNUNET_ATS_UTILIZATION_UP";
- break;
case GNUNET_ATS_UTILIZATION_DOWN:
return "GNUNET_ATS_UTILIZATION_DOWN";
- break;
case GNUNET_ATS_COST_LAN:
return "GNUNET_ATS_COST_LAN";
- break;
case GNUNET_ATS_COST_WAN:
return "GNUNET_ATS_COST_LAN";
- break;
case GNUNET_ATS_COST_WLAN:
return "GNUNET_ATS_COST_WLAN";
- break;
case GNUNET_ATS_NETWORK_TYPE:
return "GNUNET_ATS_NETWORK_TYPE";
- break;
case GNUNET_ATS_QUALITY_NET_DELAY:
return "GNUNET_ATS_QUALITY_NET_DELAY";
- break;
case GNUNET_ATS_QUALITY_NET_DISTANCE:
return "GNUNET_ATS_QUALITY_NET_DISTANCE";
- break;
default:
+ GNUNET_break (0);
return "unknown";
- break;
}
- GNUNET_break (0);
- return "unknown error";
}
/**
* @return GNUNET_OK to continue
*/
static int
-create_constraint_it (void *cls, const GNUNET_HashCode * key, void *value)
+create_constraint_it (void *cls, const struct GNUNET_HashCode * key, void *value)
{
struct GAS_MLP_Handle *mlp = cls;
struct ATS_Address *address = value;
* c 10) obey network specific quota
*/
+ /* Row for c4) minimum connection */
int min = mlp->n_min;
+ /* Number of minimum connections is min(|Peers|, n_min) */
if (mlp->n_min > mlp->c_p)
min = mlp->c_p;
mlp->ci++;
struct ATS_Peer * peer = mlp->peer_head;
+ /* For all peers */
while (peer != NULL)
{
struct ATS_Address *addr = peer->head;
/* Set -r */
ia[mlp->ci] = peer->r_c9;
ja[mlp->ci] = mlp->c_r;
- ar[mlp->ci] = -1;
+ ar[mlp->ci] = -peer->f;
mlp->ci++;
#endif
-
+ /* For all addresses of this peer */
while (addr != NULL)
{
mlpi = (struct MLP_information *) addr->mlp_information;
/* coefficient for c 2) */
-
ia[mlp->ci] = peer->r_c2;
ja[mlp->ci] = mlpi->c_n;
ar[mlp->ci] = 1;
}
/* c 7) For all quality metrics */
-
-
for (c = 0; c < mlp->m_q; c++)
{
struct ATS_Peer *tp;
glp_set_row_name (mlp->prob, mlp->r_q[c], name);
GNUNET_free (name);
/* Set row bound == 0 */
- glp_set_row_bnds (mlp->prob, mlp->r_q[c], GLP_LO, 0.0, 0.0);
+ glp_set_row_bnds (mlp->prob, mlp->r_q[c], GLP_FX, 0.0, 0.0);
ia[mlp->ci] = mlp->r_q[c];
ja[mlp->ci] = mlp->c_q[c];
ia[mlp->ci] = mlp->r_q[c];
ja[mlp->ci] = mlpi->c_b;
- ar[mlp->ci] = tp->f * value;
+ ar[mlp->ci] = tp->f_q[c] * value;
mlp->ci++;
}
}
* @return GNUNET_OK to continue
*/
static int
-create_columns_it (void *cls, const GNUNET_HashCode * key, void *value)
+create_columns_it (void *cls, const struct GNUNET_HashCode * key, void *value)
{
struct GAS_MLP_Handle *mlp = cls;
struct ATS_Address *address = value;
/* Adding invariant columns */
/* Diversity d column */
-
col = glp_add_cols (mlp->prob, 1);
mlp->c_d = col;
/* Column name */
glp_set_col_bnds (mlp->prob, col, GLP_LO, 0.0, 0.0);
/* Utilization u column */
-
col = glp_add_cols (mlp->prob, 1);
mlp->c_u = col;
/* Column name */
end = GNUNET_TIME_absolute_get ();
duration = GNUNET_TIME_absolute_get_difference (start, end);
mlp->lp_solved++;
- mlp->lp_total_duration =+ duration.rel_value;
+ mlp->lp_total_duration += duration.rel_value;
s_ctx->lp_duration = duration;
GNUNET_STATISTICS_update (mlp->stats,"# LP problem solved", 1, GNUNET_NO);
end = GNUNET_TIME_absolute_get ();
duration = GNUNET_TIME_absolute_get_difference (start, end);
mlp->mlp_solved++;
- mlp->mlp_total_duration =+ duration.rel_value;
+ mlp->mlp_total_duration += duration.rel_value;
s_ctx->mlp_duration = duration;
GNUNET_STATISTICS_update (mlp->stats,"# MLP problem solved", 1, GNUNET_NO);
int GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContext *ctx);
+
static void
mlp_scheduler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
GAS_mlp_solve_problem(mlp, &ctx);
}
+
/**
* Solves the MLP problem
*
* @param mlp the MLP Handle
+ * @param ctx solution context
* @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure
*/
int
GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContext *ctx)
{
int res;
+ /* Check if solving is already running */
+ if (GNUNET_YES == mlp->semaphore)
+ {
+ if (mlp->mlp_task != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel(mlp->mlp_task);
+ mlp->mlp_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+ mlp->mlp_task = GNUNET_SCHEDULER_add_delayed (mlp->exec_interval, &mlp_scheduler, mlp);
+ return GNUNET_SYSERR;
+ }
+ mlp->semaphore = GNUNET_YES;
+
mlp->last_execution = GNUNET_TIME_absolute_get ();
ctx->lp_result = GNUNET_SYSERR;
ctx->mlp_result = GNUNET_SYSERR;
- ctx->lp_duration = GNUNET_TIME_relative_get_forever();
- ctx->mlp_duration = GNUNET_TIME_relative_get_forever();
+ ctx->lp_duration = GNUNET_TIME_UNIT_FOREVER_REL;
+ ctx->mlp_duration = GNUNET_TIME_UNIT_FOREVER_REL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve LP problem\n");
#if WRITE_MLP
if (res != GNUNET_OK)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "LP Problem solving failed\n");
+ mlp->semaphore = GNUNET_NO;
return GNUNET_SYSERR;
}
if (res != GNUNET_OK)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP Problem solving failed\n");
+ mlp->semaphore = GNUNET_NO;
return GNUNET_SYSERR;
}
#if WRITE_MLP
GNUNET_SCHEDULER_cancel(mlp->mlp_task);
mlp->mlp_task = GNUNET_SCHEDULER_NO_TASK;
}
- //mlp->mlp_task = GNUNET_SCHEDULER_add_delayed (mlp->exec_interval, &mlp_scheduler, mlp);
+ mlp->mlp_task = GNUNET_SCHEDULER_add_delayed (mlp->exec_interval, &mlp_scheduler, mlp);
+ mlp->semaphore = GNUNET_NO;
return res;
}
double D;
double R;
double U;
- long long unsigned int tmp;
+ unsigned long long tmp;
unsigned int b_min;
unsigned int n_min;
struct GNUNET_TIME_Relative i_exec;
/* Check if defined quota could make problem unsolvable */
if (((n_min * b_min) > quota_out) && (GNUNET_ATS_NET_UNSPECIFIED != quotas[c]))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Inconsistent quota configuration value `%s': " \
- "outbound quota (%u Bps) too small for combination of minimum connections and minimum bandwidth per peer (%u * %u Bps = %u)\n", entry_out, quota_out, n_min, b_min, n_min * b_min);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Inconsistent quota configuration value `%s': "
+ "outbound quota (%u Bps) too small for combination of minimum connections and minimum bandwidth per peer (%u * %u Bps = %u)\n", entry_out, quota_out, n_min, b_min, n_min * b_min);
GAS_mlp_done(mlp);
mlp = NULL;
#endif
mlp->control_param_mlp.tm_lim = max_duration.rel_value;
- mlp->last_execution = GNUNET_TIME_absolute_get_forever();
+ mlp->last_execution = GNUNET_TIME_UNIT_FOREVER_ABS;
mlp->co_D = D;
mlp->co_R = R;
mlp->b_min = b_min;
mlp->n_min = n_min;
mlp->m_q = GNUNET_ATS_QualityPropertiesCount;
-
+ mlp->semaphore = GNUNET_NO;
return mlp;
}
}
static int
-mlp_get_preferred_address_it (void *cls, const GNUNET_HashCode * key, void *value)
+mlp_get_preferred_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
{
struct ATS_PreferedAddress *aa = (struct ATS_PreferedAddress *) cls;
{
GNUNET_STATISTICS_update (mlp->stats,"# LP address preference changes", 1, GNUNET_NO);
- struct ATS_Peer *p = mlp_find_peer (mlp, peer);
- p = p;
+ //struct ATS_Peer *p = mlp_find_peer (mlp, peer);
+ //FIXME to finish implementation
/* Here we have to do the matching */
}