+static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsigned int c_peers, unsigned int c_mechs, struct ATS_result *res)
+{
+ int result;
+ int solution;
+
+ // Solving simplex
+ glp_prob *prob = ats->prob;
+ /*
+ glp_smcp opt_lp;
+ glp_init_smcp(&opt_lp);
+#if VERBOSE_ATS
+ opt_lp.msg_lev = GLP_MSG_ALL;
+#else
+ opt_lp.msg_lev = GLP_MSG_OFF;
+#endif
+ opt_lp.presolve = GLP_ON;
+ result = glp_simplex(prob, &opt_lp);
+ solution = glp_get_status (prob);
+
+ if (GNUNET_YES == ats_evaluate_results(result, solution, "LP"))
+ {*/
+ /* Solving mlp */
+ glp_iocp opt_mlp;
+ glp_init_iocp(&opt_mlp);
+ /* maximum duration */
+ opt_mlp.presolve = GLP_ON;
+ opt_mlp.tm_lim = max_dur;
+ /* output level */
+#if VERBOSE_ATS
+ opt_mlp.msg_lev = GLP_MSG_ALL;
+#else
+ opt_mlp.msg_lev = GLP_MSG_OFF;
+#endif
+ result = glp_intopt (prob, &opt_mlp);
+ solution = glp_mip_status (prob);
+ res->solution = solution;
+ res->valid = GNUNET_NO;
+ if (ats_evaluate_results(result, solution, "MLP") == GNUNET_YES)
+ res->valid = GNUNET_YES;
+ /* done */
+ //}
+
+ if ((ats->save_mlp == GNUNET_YES) && (c_peers > 1))
+ {
+ char * filename;
+ GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_llu.mlp",c_peers, c_mechs, GNUNET_TIME_absolute_get().abs_value);
+ if (GNUNET_NO == GNUNET_DISK_file_test(filename))
+ glp_write_mip (prob, filename);
+ GNUNET_free (filename);
+ }
+ if ((ats->save_solution == GNUNET_YES) && (c_peers > 1))
+ {
+ char * filename;
+ GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.sol",c_peers, c_mechs, GNUNET_TIME_absolute_get().abs_value);
+ if (GNUNET_NO == GNUNET_DISK_file_test(filename))
+ glp_print_sol (prob, filename);
+ GNUNET_free (filename);
+ }
+
+ /*
+ int check;
+ int error = GNUNET_NO;
+ double bw;
+ struct ATS_mechanism *t = NULL;
+ for (c=1; c<= (c_peers); c++ )
+ {
+ check = GNUNET_NO;
+ t = peers[c].m_head;
+ while (t!=NULL)
+ {
+ bw = glp_get_col_prim(prob, t->col_index);
+ if (bw > 1.0)
+ {
+#if VERBOSE_ATS
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[%i][%i] `%s' %s %s %f\n", c, t->col_index, GNUNET_h2s(&peers[c].peer.hashPubKey), t->plugin->short_name, glp_get_col_name(prob,t->col_index), bw);
+#endif
+ if (check ==GNUNET_YES)
+ {
+ glp_write_sol(prob, "invalid_solution.mlp");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Invalid solution, check invalid_solution.mlp");
+ GNUNET_STATISTICS_update (stats, "ATS invalid solutions", 1, GNUNET_NO);
+ error = GNUNET_YES;
+ }
+ if (check ==GNUNET_NO)
+ check = GNUNET_YES;
+ }
+ t = t->next;
+ }
+ }*/
+
+#if VERBOSE_ATS
+ for (c=1; c<= available_quality_metrics; c++ )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n", glp_get_col_name(prob,2*c_mechs+3+c), glp_get_col_prim(prob,2*c_mechs+3+c));
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n", glp_get_col_name(prob,2*c_mechs+1), glp_get_col_prim(prob,2*c_mechs+1));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n", glp_get_col_name(prob,2*c_mechs+2), glp_get_col_prim(prob,2*c_mechs+2));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s %f\n", glp_get_col_name(prob,2*c_mechs+3), glp_get_col_prim(prob,2*c_mechs+3));
+#endif
+
+}
+