aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-05-12 19:05:54 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-05-12 19:05:54 +0000
commit116e346f3d01eaede6f48ef8aa0c9e03c71b0c19 (patch)
treeef1fd855908e15c93d428a0501c5705ca0f4925e /src
parent9c56050d0805cde393515f63d9b2d8918f8d4c76 (diff)
downloadgnunet-116e346f3d01eaede6f48ef8aa0c9e03c71b0c19.tar.gz
gnunet-116e346f3d01eaede6f48ef8aa0c9e03c71b0c19.zip
dbg option to autoscale problem
Diffstat (limited to 'src')
-rw-r--r--src/ats/plugin_ats_mlp.c49
-rw-r--r--src/ats/plugin_ats_mlp.h12
2 files changed, 41 insertions, 20 deletions
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c
index 20ffbbfaf..07d9b9ea9 100644
--- a/src/ats/plugin_ats_mlp.c
+++ b/src/ats/plugin_ats_mlp.c
@@ -656,7 +656,7 @@ mlp_create_problem_add_address_information (void *cls,
656 GNUNET_asprintf(&name, "c2_%s", GNUNET_i2s(&address->peer)); 656 GNUNET_asprintf(&name, "c2_%s", GNUNET_i2s(&address->peer));
657 peer->r_c2 = mlp_create_problem_create_constraint (p, name, GLP_FX, 1.0, 1.0); 657 peer->r_c2 = mlp_create_problem_create_constraint (p, name, GLP_FX, 1.0, 1.0);
658 GNUNET_free (name); 658 GNUNET_free (name);
659 if (GNUNET_NO == mlp->opt_feasibility_only) 659 if (GNUNET_NO == mlp->opt_dbg_feasibility_only)
660 { 660 {
661 /* Add c9) Relativity */ 661 /* Add c9) Relativity */
662 GNUNET_asprintf(&name, "c9_%s", GNUNET_i2s(&address->peer)); 662 GNUNET_asprintf(&name, "c9_%s", GNUNET_i2s(&address->peer));
@@ -677,7 +677,7 @@ mlp_create_problem_add_address_information (void *cls,
677 677
678 /* Add bandwidth column */ 678 /* Add bandwidth column */
679 GNUNET_asprintf (&name, "b_%s_%s_%p", GNUNET_i2s (&address->peer), address->plugin, address); 679 GNUNET_asprintf (&name, "b_%s_%s_%p", GNUNET_i2s (&address->peer), address->plugin, address);
680 if (GNUNET_NO == mlp->opt_feasibility_only) 680 if (GNUNET_NO == mlp->opt_dbg_feasibility_only)
681 { 681 {
682 mlpi->c_b = mlp_create_problem_create_column (p, name, GLP_CV, GLP_LO, 0.0, 0.0, 0.0); 682 mlpi->c_b = mlp_create_problem_create_column (p, name, GLP_CV, GLP_LO, 0.0, 0.0, 0.0);
683 } 683 }
@@ -744,7 +744,7 @@ mlp_create_problem_add_address_information (void *cls,
744 } 744 }
745 745
746 /* Optimality */ 746 /* Optimality */
747 if (GNUNET_NO == mlp->opt_feasibility_only) 747 if (GNUNET_NO == mlp->opt_dbg_feasibility_only)
748 { 748 {
749 /* c 6) maximize diversity */ 749 /* c 6) maximize diversity */
750 mlp_create_problem_set_value (p, p->r_c6, mlpi->c_n, 1, __LINE__); 750 mlp_create_problem_set_value (p, p->r_c6, mlpi->c_n, 1, __LINE__);
@@ -794,7 +794,7 @@ mlp_create_problem_add_invariant_rows (struct GAS_MLP_Handle *mlp, struct MLP_Pr
794 } 794 }
795 795
796 /* Optimality */ 796 /* Optimality */
797 if (GNUNET_NO == mlp->opt_feasibility_only) 797 if (GNUNET_NO == mlp->opt_dbg_feasibility_only)
798 { 798 {
799 char *name; 799 char *name;
800 /* Add row for c6) Maximize for diversity */ 800 /* Add row for c6) Maximize for diversity */
@@ -826,7 +826,7 @@ mlp_create_problem_add_invariant_rows (struct GAS_MLP_Handle *mlp, struct MLP_Pr
826static void 826static void
827mlp_create_problem_add_invariant_columns (struct GAS_MLP_Handle *mlp, struct MLP_Problem *p) 827mlp_create_problem_add_invariant_columns (struct GAS_MLP_Handle *mlp, struct MLP_Problem *p)
828{ 828{
829 if (GNUNET_NO == mlp->opt_feasibility_only) 829 if (GNUNET_NO == mlp->opt_dbg_feasibility_only)
830 { 830 {
831 char *name; 831 char *name;
832 int c; 832 int c;
@@ -920,7 +920,10 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp)
920 /* Load the matrix */ 920 /* Load the matrix */
921 LOG (GNUNET_ERROR_TYPE_DEBUG, "Loading matrix\n"); 921 LOG (GNUNET_ERROR_TYPE_DEBUG, "Loading matrix\n");
922 glp_load_matrix(p->prob, (p->ci)-1, p->ia, p->ja, p->ar); 922 glp_load_matrix(p->prob, (p->ci)-1, p->ia, p->ja, p->ar);
923 glp_scale_prob (p->prob, GLP_SF_AUTO); 923 if (GNUNET_YES == mlp->opt_dbg_autoscale_problem)
924 {
925 glp_scale_prob (p->prob, GLP_SF_AUTO);
926 }
924 927
925 return res; 928 return res;
926} 929}
@@ -1411,7 +1414,7 @@ GAS_mlp_address_property_changed (void *solver,
1411 abs_value, 1414 abs_value,
1412 rel_value); 1415 rel_value);
1413 1416
1414 if (GNUNET_YES == mlp->opt_feasibility_only) 1417 if (GNUNET_YES == mlp->opt_dbg_feasibility_only)
1415 return; 1418 return;
1416 1419
1417 /* Find row index */ 1420 /* Find row index */
@@ -1879,7 +1882,7 @@ GAS_mlp_address_change_preference (void *solver,
1879 return; 1882 return;
1880 } 1883 }
1881 1884
1882 if (GNUNET_NO == mlp->opt_feasibility_only) 1885 if (GNUNET_NO == mlp->opt_dbg_feasibility_only)
1883 { 1886 {
1884 p->f = get_peer_pref_value (mlp, peer); 1887 p->f = get_peer_pref_value (mlp, peer);
1885 mlp_create_problem_update_value (&mlp->p, p->r_c9, mlp->p.c_r, -p->f, __LINE__); 1888 mlp_create_problem_update_value (&mlp->p, p->r_c9, mlp->p.c_r, -p->f, __LINE__);
@@ -2034,19 +2037,27 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2034 if (GNUNET_SYSERR == mlp->opt_dump_solution_on_fail) 2037 if (GNUNET_SYSERR == mlp->opt_dump_solution_on_fail)
2035 mlp->opt_dump_solution_on_fail = GNUNET_NO; 2038 mlp->opt_dump_solution_on_fail = GNUNET_NO;
2036 2039
2037 mlp->opt_glpk_verbose = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, 2040 mlp->opt_dbg_glpk_verbose = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
2038 "ats", "MLP_GLPK_VERBOSE"); 2041 "ats", "MLP_GLPK_VERBOSE");
2039 if (GNUNET_SYSERR == mlp->opt_glpk_verbose) 2042 if (GNUNET_SYSERR == mlp->opt_dbg_glpk_verbose)
2040 mlp->opt_glpk_verbose = GNUNET_NO; 2043 mlp->opt_dbg_glpk_verbose = GNUNET_NO;
2041 2044
2042 mlp->opt_feasibility_only = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, 2045 mlp->opt_dbg_feasibility_only = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
2043 "ats", "MLP_FEASIBILITY_ONLY"); 2046 "ats", "MLP_DBG_FEASIBILITY_ONLY");
2044 if (GNUNET_SYSERR == mlp->opt_feasibility_only) 2047 if (GNUNET_SYSERR == mlp->opt_dbg_feasibility_only)
2045 mlp->opt_feasibility_only = GNUNET_NO; 2048 mlp->opt_dbg_feasibility_only = GNUNET_NO;
2046 if (GNUNET_YES == mlp->opt_feasibility_only) 2049 if (GNUNET_YES == mlp->opt_dbg_feasibility_only)
2047 LOG (GNUNET_ERROR_TYPE_WARNING, 2050 LOG (GNUNET_ERROR_TYPE_WARNING,
2048 "MLP solver is configured to check feasibility only!\n"); 2051 "MLP solver is configured to check feasibility only!\n");
2049 2052
2053 mlp->opt_dbg_autoscale_problem = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
2054 "ats", "MLP_DBG_AUTOSCALE_PROBLEM");
2055 if (GNUNET_SYSERR == mlp->opt_dbg_autoscale_problem)
2056 mlp->opt_dbg_autoscale_problem = GNUNET_NO;
2057 if (GNUNET_YES == mlp->opt_dbg_autoscale_problem)
2058 LOG (GNUNET_ERROR_TYPE_WARNING,
2059 "MLP solver is configured automatically scale the problem!\n");
2060
2050 mlp->pv.BIG_M = (double) BIG_M_VALUE; 2061 mlp->pv.BIG_M = (double) BIG_M_VALUE;
2051 2062
2052 /* Get timeout for iterations */ 2063 /* Get timeout for iterations */
@@ -2249,7 +2260,7 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2249 /* Init LP solving parameters */ 2260 /* Init LP solving parameters */
2250 glp_init_smcp(&mlp->control_param_lp); 2261 glp_init_smcp(&mlp->control_param_lp);
2251 mlp->control_param_lp.msg_lev = GLP_MSG_OFF; 2262 mlp->control_param_lp.msg_lev = GLP_MSG_OFF;
2252 if (GNUNET_YES == mlp->opt_glpk_verbose) 2263 if (GNUNET_YES == mlp->opt_dbg_glpk_verbose)
2253 mlp->control_param_lp.msg_lev = GLP_MSG_ALL; 2264 mlp->control_param_lp.msg_lev = GLP_MSG_ALL;
2254 2265
2255 mlp->control_param_lp.it_lim = max_iterations; 2266 mlp->control_param_lp.it_lim = max_iterations;
@@ -2258,7 +2269,7 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2258 /* Init MLP solving parameters */ 2269 /* Init MLP solving parameters */
2259 glp_init_iocp(&mlp->control_param_mlp); 2270 glp_init_iocp(&mlp->control_param_mlp);
2260 mlp->control_param_mlp.msg_lev = GLP_MSG_OFF; 2271 mlp->control_param_mlp.msg_lev = GLP_MSG_OFF;
2261 if (GNUNET_YES == mlp->opt_glpk_verbose) 2272 if (GNUNET_YES == mlp->opt_dbg_glpk_verbose)
2262 mlp->control_param_mlp.msg_lev = GLP_MSG_ALL; 2273 mlp->control_param_mlp.msg_lev = GLP_MSG_ALL;
2263 mlp->control_param_mlp.tm_lim = max_duration.rel_value_us / 1000LL; 2274 mlp->control_param_mlp.tm_lim = max_duration.rel_value_us / 1000LL;
2264 2275
diff --git a/src/ats/plugin_ats_mlp.h b/src/ats/plugin_ats_mlp.h
index 12e72d53c..8b15eb76c 100644
--- a/src/ats/plugin_ats_mlp.h
+++ b/src/ats/plugin_ats_mlp.h
@@ -337,9 +337,19 @@ struct GAS_MLP_Handle
337 int opt_dump_solution_on_fail; 337 int opt_dump_solution_on_fail;
338 338
339 /** 339 /**
340 * solve feasibility only
341 */
342 int opt_dbg_feasibility_only;
343
344 /**
345 * solve feasibility only
346 */
347 int opt_dbg_autoscale_problem;
348
349 /**
340 * Print GLPK output 350 * Print GLPK output
341 */ 351 */
342 int opt_glpk_verbose; 352 int opt_dbg_glpk_verbose;
343 353
344}; 354};
345 355