- struct GNUNET_TIME_Absolute start;
- struct GNUNET_TIME_Relative creation;
- struct GNUNET_TIME_Relative solving;
- int c_m;
- int c_p;
- char *text = "unmodified";
-
-#if FIXME_WACHS
- int dur;
- if (INT_MAX < ats->max_exec_duration.rel_value)
- dur = INT_MAX;
- else
- dur = (int) ats->max_exec_duration.rel_value;
-#endif
-
- ats->internal.simplex_rerun_required = GNUNET_NO;
- start = GNUNET_TIME_absolute_get();
- if ((ats->internal.recreate_problem == GNUNET_YES) ||
- (ats->prob==NULL) ||
- (ats->internal.valid == GNUNET_NO))
- {
- text = "new";
- ats->internal.recreate_problem = GNUNET_YES;
- ats_delete_problem (ats);
- ats->addr_notification(&ats->peers , &c_p, &ats->mechanisms, &c_m);
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Service returned: %i peer, %i mechs\n",
- c_p,
- c_m);
-#endif
- ats_create_problem (ats, &ats->internal, ats->peers, c_p, ats->mechanisms, c_m);
-
-
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Peers/Addresses were modified... new problem: %i peer, %i mechs\n",
- ats->internal.c_peers,
- ats->internal.c_mechs);
-#endif
- }
-
- else if ((ats->internal.recreate_problem == GNUNET_NO) &&
- (ats->internal.modified_resources == GNUNET_YES) &&
- (ats->internal.valid == GNUNET_YES))
- {
- text = "modified resources";
- ats_update_problem_cr (ats);
- }
- else if ((ats->internal.recreate_problem == GNUNET_NO) &&
- (ats->internal.modified_quality == GNUNET_YES) &&
- (ats->internal.valid == GNUNET_YES))
- {
- text = "modified quality";
- ats_update_problem_qm (ats);
- //ats_update_problem_qm_TEST ();
- }
-#if DEBUG_ATS
- else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem is %s\n", text);
-#endif
-
- creation = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get());
- start = GNUNET_TIME_absolute_get();
-
- ats->internal.solution = GLP_UNDEF;
- if (ats->internal.valid == GNUNET_YES)
- {
- ats_solve_problem(ats,
- ats->max_iterations,
- ats->max_exec_duration.rel_value,
- ats->internal.c_peers,
- ats->internal.c_mechs,
- &ats->internal);
- }
- solving = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get());
-
- if (ats->internal.valid == GNUNET_YES)
- {
- /* Telling about new distribution*/
- ats->result_cb ();
-
- int msg_type = GNUNET_ERROR_TYPE_DEBUG;
-#if DEBUG_ATS
- msg_type = GNUNET_ERROR_TYPE_ERROR;
-#endif
- GNUNET_log (msg_type,
- "MLP %s: creation time: %llu, execution time: %llu, %i peers, %i mechanisms, simplex rerun: %s, solution %s\n",
- text,
- creation.rel_value,
- solving.rel_value,
- ats->internal.c_peers,
- ats->internal.c_mechs,
- (ats->internal.simplex_rerun_required == GNUNET_NO) ? "NO" : "YES",
- (ats->internal.solution == 5) ? "OPTIMAL" : "INVALID");
- ats->successful_executions ++;
- GNUNET_STATISTICS_set (stats, "# ATS successful executions",
- ats->successful_executions,
- GNUNET_NO);
-
- if ((ats->internal.recreate_problem == GNUNET_YES) || (ats->prob==NULL))
- GNUNET_STATISTICS_set (stats, "ATS state",ATS_NEW, GNUNET_NO);
- else if ((ats->internal.modified_resources == GNUNET_YES) &&
- (ats->internal.modified_quality == GNUNET_NO))
- GNUNET_STATISTICS_set (stats, "ATS state", ATS_COST_UPDATED, GNUNET_NO);
- else if ((ats->internal.modified_resources == GNUNET_NO) &&
- (ats->internal.modified_quality == GNUNET_YES) &&
- (ats->internal.simplex_rerun_required == GNUNET_NO))
- GNUNET_STATISTICS_set (stats, "ATS state", ATS_QUALITY_UPDATED, GNUNET_NO);
- else if ((ats->internal.modified_resources == GNUNET_YES) &&
- (ats->internal.modified_quality == GNUNET_YES) &&
- (ats->internal.simplex_rerun_required == GNUNET_NO))
- GNUNET_STATISTICS_set (stats, "ATS state", ATS_QUALITY_COST_UPDATED, GNUNET_NO);
- else if (ats->internal.simplex_rerun_required == GNUNET_NO)
- GNUNET_STATISTICS_set (stats, "ATS state", ATS_UNMODIFIED, GNUNET_NO);
- }
- else
- {
- if (ats->internal.c_peers != 0)
- {
- ats->invalid_executions ++;
- GNUNET_STATISTICS_set (stats, "# ATS invalid executions",
- ats->invalid_executions, GNUNET_NO);
- }
- else
- {
- GNUNET_STATISTICS_set (stats, "# ATS successful executions",
- ats->successful_executions, GNUNET_NO);
- }
- }
-
- GNUNET_STATISTICS_set (stats,
- "ATS duration", solving.rel_value + creation.rel_value, GNUNET_NO);
- GNUNET_STATISTICS_set (stats,
- "ATS mechanisms", ats->internal.c_mechs, GNUNET_NO);
- GNUNET_STATISTICS_set (stats,
- "ATS peers", ats->internal.c_peers, GNUNET_NO);
- GNUNET_STATISTICS_set (stats,
- "ATS solution", ats->internal.solution, GNUNET_NO);
- GNUNET_STATISTICS_set (stats,
- "ATS timestamp", start.abs_value, GNUNET_NO);
-
- if ((ats->save_mlp == GNUNET_YES) &&
- (ats->internal.c_mechs >= ats->dump_min_peers) &&
- (ats->internal.c_mechs >= ats->dump_min_addr))
- {
- char * filename;
- if (ats->dump_overwrite == GNUNET_NO)
- {
- GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%s_%llu.mlp",
- ats->internal.c_peers,
- ats->internal.c_mechs,
- text,
- GNUNET_TIME_absolute_get().abs_value);
- _lp_write_lp ((void *) ats->prob, NULL, filename);
- }
- else
- {
- GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i.mlp",
- ats->internal.c_peers, ats->internal.c_mechs );
- _lp_write_lp ((void *) ats->prob, NULL, filename);
- }
- GNUNET_free (filename);
- }
- if ((ats->save_solution == GNUNET_YES) &&
- (ats->internal.c_mechs >= ats->dump_min_peers) &&
- (ats->internal.c_mechs >= ats->dump_min_addr))
- {
- char * filename;
- if (ats->dump_overwrite == GNUNET_NO)
- {
- GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%s_%llu.sol",
- ats->internal.c_peers,
- ats->internal.c_mechs,
- text,
- GNUNET_TIME_absolute_get().abs_value);
- _lp_print_sol (ats->prob, filename);
- }
- else
- {
- GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i.sol",
- ats->internal.c_peers, ats->internal.c_mechs);
- _lp_print_sol (ats->prob, filename);
- }
- GNUNET_free (filename);
- }