void solve_mlp(int presolve)
{
- int result, solution;
+ int result, solution;
- glp_iocp opt_mlp;
- glp_init_iocp(&opt_mlp);
- opt_mlp.msg_lev = GLP_MSG_OFF;
- opt_mlp.presolve = GLP_OFF;
+ glp_iocp opt_mlp;
+ glp_init_iocp(&opt_mlp);
+ opt_mlp.msg_lev = GLP_MSG_OFF;
+ opt_mlp.presolve = GLP_OFF;
- result = glp_intopt (prob, &opt_mlp);
- solution = glp_mip_status (prob);
- GNUNET_assert ((solution == 5) && (result==0));
+ result = glp_intopt (prob, &opt_mlp);
+ solution = glp_mip_status (prob);
+ GNUNET_assert ((solution == 5) && (result==0));
}
void solve_lp(int presolve)
{
- int result, solution;
+ int result, solution;
- glp_smcp opt_lp;
- glp_init_smcp(&opt_lp);
+ glp_smcp opt_lp;
+ glp_init_smcp(&opt_lp);
- opt_lp.msg_lev = GLP_MSG_OFF;
- if (presolve==GNUNET_YES) opt_lp.presolve = GLP_ON;
- else opt_lp.presolve = GLP_OFF;
+ opt_lp.msg_lev = GLP_MSG_OFF;
+ if (presolve==GNUNET_YES) opt_lp.presolve = GLP_ON;
+ else opt_lp.presolve = GLP_OFF;
- result = glp_simplex(prob, &opt_lp);
- solution = glp_get_status (prob);
- GNUNET_assert ((solution == 5) && (result==0));
+ result = glp_simplex(prob, &opt_lp);
+ solution = glp_get_status (prob);
+ GNUNET_assert ((solution == 5) && (result==0));
}
/* Modify quality constraint */
void modify_qm(int start, int length, int values_to_change)
{
- //int * ind = GNUNET_malloc (length * sizeof (int));
- //double *val = GNUNET_malloc (length * sizeof (double));
- int ind[1000];
- double val[1000];
-
- int res = 0;
- int c = start, c2=1;
- while (c<=(start+values_to_change))
- {
- res = glp_get_mat_row(prob, c, ind, val);
-
- printf("%i %i \n", c, res);
- for (c2=0; c2<res; c2++)
- {
- printf("%i = %f \n", ind[c2], val[c2]);
- }
-
- c++;
- }
- //glp_set_mat_row(prob, start, length, ind, val);
+ //int * ind = GNUNET_malloc (length * sizeof (int));
+ //double *val = GNUNET_malloc (length * sizeof (double));
+ int ind[1000];
+ double val[1000];
+
+ int res = 0;
+ int c = start, c2=1;
+ while (c<=(start+values_to_change))
+ {
+ res = glp_get_mat_row(prob, c, ind, val);
+
+ printf("%i %i \n", c, res);
+ for (c2=0; c2<res; c2++)
+ {
+ printf("%i = %f \n", ind[c2], val[c2]);
+ }
+
+ c++;
+ }
+ //glp_set_mat_row(prob, start, length, ind, val);
}
void bench_simplex_optimization(char * file, int executions)
{
+ int c;
- int c;
- prob = glp_create_prob();
- glp_read_lp(prob, NULL, file);
+ prob = glp_create_prob();
+ glp_read_lp(prob, NULL, file);
- solve_lp(GNUNET_YES);
+ solve_lp(GNUNET_YES);
- for (c=0; c<executions;c++)
- {
- start = GNUNET_TIME_absolute_get();
- solve_lp(GNUNET_NO);
- end = GNUNET_TIME_absolute_get();
+ for (c=0; c<executions;c++)
+ {
+ start = GNUNET_TIME_absolute_get();
+ solve_lp(GNUNET_NO);
+ end = GNUNET_TIME_absolute_get();
- exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
+ exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
- sim_with_opt_avg += exec_time[c];
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex /w optimization iterations %i: %llu \n", c, exec_time[c]);
- }
+ sim_with_opt_avg += exec_time[c];
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Simplex /w optimization iterations %i: %llu \n", c, exec_time[c]);
+ }
- glp_delete_prob(prob);
+ glp_delete_prob(prob);
}
void bench_simplex_no_optimization(char * file, int executions)
{
+ int c;
- int c;
- prob = glp_create_prob();
- glp_read_lp(prob, NULL, file);
+ prob = glp_create_prob();
+ glp_read_lp(prob, NULL, file);
- for (c=0; c<executions;c++)
- {
- start = GNUNET_TIME_absolute_get();
- solve_lp(GNUNET_YES);
- end = GNUNET_TIME_absolute_get();
+ for (c=0; c<executions;c++)
+ {
+ start = GNUNET_TIME_absolute_get();
+ solve_lp(GNUNET_YES);
+ end = GNUNET_TIME_absolute_get();
- exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
+ exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
- sim_no_opt_avg += exec_time[c];
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex iterations %i: %llu \n", c, exec_time[c]);
- }
+ sim_no_opt_avg += exec_time[c];
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Simplex iterations %i: %llu \n",
+ c, exec_time[c]);
+ }
- glp_delete_prob(prob);
+ glp_delete_prob(prob);
}
void bench_mlp_no_optimization(char * file, int executions)
{
+ int c;
- int c;
- prob = glp_create_prob();
- glp_read_lp(prob, NULL, file);
+ prob = glp_create_prob();
+ glp_read_lp(prob, NULL, file);
- for (c=0; c<executions;c++)
- {
- start = GNUNET_TIME_absolute_get();
- solve_lp(GNUNET_YES);
- solve_mlp (GNUNET_NO);
- end = GNUNET_TIME_absolute_get();
+ for (c=0; c<executions;c++)
+ {
+ start = GNUNET_TIME_absolute_get();
+ solve_lp(GNUNET_YES);
+ solve_mlp (GNUNET_NO);
+ end = GNUNET_TIME_absolute_get();
- exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
+ exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
- mlp_no_opt_avg += exec_time[c];
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP iterations no optimization %i: %llu \n", c, exec_time[c]);
- }
+ mlp_no_opt_avg += exec_time[c];
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "MLP iterations no optimization %i: %llu \n",
+ c, exec_time[c]);
+ }
- glp_delete_prob(prob);
+ glp_delete_prob(prob);
}
void bench_mlp_with_optimization(char * file, int executions, int changes)
{
- int c;
- prob = glp_create_prob();
- glp_read_lp(prob, NULL, file);
-
- solve_lp(GNUNET_YES);
-
- for (c=0; c<executions;c++)
- {
- start = GNUNET_TIME_absolute_get();
- //modify_qm(906, 0, 0);
- solve_lp(GNUNET_NO);
- solve_mlp (GNUNET_NO);
- end = GNUNET_TIME_absolute_get();
+ int c;
+ prob = glp_create_prob();
+ glp_read_lp(prob, NULL, file);
- exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
+ solve_lp(GNUNET_YES);
- mlp_with_opt_avg += exec_time[c];
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP /w optimization iterations %i: %llu \n", c, exec_time[c]);
- }
+ for (c=0; c<executions;c++)
+ {
+ start = GNUNET_TIME_absolute_get();
+ //modify_qm(906, 0, 0);
+ solve_lp(GNUNET_NO);
+ solve_mlp (GNUNET_NO);
+ end = GNUNET_TIME_absolute_get();
+
+ exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
+
+ mlp_with_opt_avg += exec_time[c];
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "MLP /w optimization iterations %i: %llu \n",
+ c, exec_time[c]);
+ }
- glp_delete_prob(prob);
+ glp_delete_prob(prob);
}
#if 0
void modify_cr (int start, int length, int count)
{
- //int * ind = GNUNET_malloc (length * sizeof (int));
- //double *val = GNUNET_malloc (length * sizeof (double));
- int ind[500];
- double val[500];
- int res = 0;
- int c = start, c2=1;
- while (c<=(start+count))
- {
- res = glp_get_mat_row(prob, c, ind, val);
-
- printf("row index: %i non-zero elements: %i \n", c, res);
- for (c2=1; c2<=res; c2++)
- {
- printf("%i = %f ", ind[c2], val[c2]);
- }
- c++;
- printf ("\n----\n");
- }
- //glp_set_mat_row(prob, start, length, ind, val);
+ //int * ind = GNUNET_malloc (length * sizeof (int));
+ //double *val = GNUNET_malloc (length * sizeof (double));
+ int ind[500];
+ double val[500];
+ int res = 0;
+ int c = start, c2=1;
+ while (c<=(start+count))
+ {
+ res = glp_get_mat_row(prob, c, ind, val);
+
+ printf("row index: %i non-zero elements: %i \n", c, res);
+ for (c2=1; c2<=res; c2++)
+ {
+ printf("%i = %f ", ind[c2], val[c2]);
+ }
+ c++;
+ printf ("\n----\n");
+ }
+ //glp_set_mat_row(prob, start, length, ind, val);
}
#endif
#endif