aboutsummaryrefslogtreecommitdiff
path: root/src/ats/plugin_ats_mlp.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-05-13 12:47:54 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-05-13 12:47:54 +0000
commit9948a0b7e77fa3ae2d6ed28d7dc50236e869fc93 (patch)
tree53b1ab382b1c70cdab41de017bcc30a4380468a4 /src/ats/plugin_ats_mlp.c
parent093f0291be26fa3dfc6fc98a536028ef99517832 (diff)
downloadgnunet-9948a0b7e77fa3ae2d6ed28d7dc50236e869fc93.tar.gz
gnunet-9948a0b7e77fa3ae2d6ed28d7dc50236e869fc93.zip
supporting additional log formats like MPS
Diffstat (limited to 'src/ats/plugin_ats_mlp.c')
-rw-r--r--src/ats/plugin_ats_mlp.c53
1 files changed, 50 insertions, 3 deletions
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c
index f168c08a3..4780daa8a 100644
--- a/src/ats/plugin_ats_mlp.c
+++ b/src/ats/plugin_ats_mlp.c
@@ -1331,10 +1331,28 @@ GAS_mlp_solve_problem (void *solver)
1331 (mlp->opt_dump_problem_on_fail && ((GNUNET_OK != res_lp) || (GNUNET_OK != res_mip))) ) 1331 (mlp->opt_dump_problem_on_fail && ((GNUNET_OK != res_lp) || (GNUNET_OK != res_mip))) )
1332 { 1332 {
1333 /* Write problem to disk */ 1333 /* Write problem to disk */
1334 GNUNET_asprintf(&filename, "problem_p_%u_a%u_%llu.lp", mlp->p.num_peers, 1334 switch (mlp->opt_log_format) {
1335 mlp->p.num_addresses, time.abs_value_us); 1335 case MLP_CPLEX:
1336 GNUNET_asprintf(&filename, "problem_p_%u_a%u_%llu.cplex", mlp->p.num_peers,
1337 mlp->p.num_addresses, time.abs_value_us);
1338 glp_write_lp (mlp->p.prob, NULL, filename);
1339 break;
1340 case MLP_GLPK:
1341 GNUNET_asprintf(&filename, "problem_p_%u_a%u_%llu.glpk", mlp->p.num_peers,
1342 mlp->p.num_addresses, time.abs_value_us);
1343 glp_write_prob (mlp->p.prob, 0, filename);
1344 break;
1345 case MLP_MPS:
1346 GNUNET_asprintf(&filename, "problem_p_%u_a%u_%llu.mps", mlp->p.num_peers,
1347 mlp->p.num_addresses, time.abs_value_us);
1348 glp_write_mps (mlp->p.prob, GLP_MPS_FILE, NULL, filename);
1349 break;
1350 default:
1351 break;
1352 }
1353
1354
1336 LOG(GNUNET_ERROR_TYPE_ERROR, "Dumped problem to file: `%s' \n", filename); 1355 LOG(GNUNET_ERROR_TYPE_ERROR, "Dumped problem to file: `%s' \n", filename);
1337 glp_write_lp (mlp->p.prob, NULL, filename);
1338 GNUNET_free(filename); 1356 GNUNET_free(filename);
1339 } 1357 }
1340 if ( (mlp->opt_dump_solution_all) || 1358 if ( (mlp->opt_dump_solution_all) ||
@@ -2022,6 +2040,7 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2022 int c; 2040 int c;
2023 int c2; 2041 int c2;
2024 int found; 2042 int found;
2043 char *outputformat;
2025 2044
2026 struct GNUNET_TIME_Relative max_duration; 2045 struct GNUNET_TIME_Relative max_duration;
2027 long long unsigned int max_iterations; 2046 long long unsigned int max_iterations;
@@ -2111,6 +2130,34 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2111 LOG (GNUNET_ERROR_TYPE_WARNING, 2130 LOG (GNUNET_ERROR_TYPE_WARNING,
2112 "MLP solver is configured use the mlp presolver\n"); 2131 "MLP solver is configured use the mlp presolver\n");
2113 2132
2133 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (env->cfg,
2134 "ats", "MLP_LOG_FORMAT", &outputformat))
2135 mlp->opt_log_format = MLP_CPLEX;
2136 else
2137 {
2138 GNUNET_STRINGS_utf8_toupper(outputformat, outputformat);
2139 if (0 == strcmp (outputformat, "MPS"))
2140 {
2141 mlp->opt_log_format = MLP_MPS;
2142 }
2143 else if (0 == strcmp (outputformat, "CPLEX"))
2144 {
2145 mlp->opt_log_format = MLP_CPLEX;
2146 }
2147 else if (0 == strcmp (outputformat, "GLPK"))
2148 {
2149 mlp->opt_log_format = MLP_GLPK;
2150 }
2151 else
2152 {
2153 LOG (GNUNET_ERROR_TYPE_WARNING,
2154 "Invalid log format `%s' in configuration, using CPLEX!\n",
2155 outputformat);
2156 mlp->opt_log_format = MLP_CPLEX;
2157 }
2158 GNUNET_free (outputformat);
2159 }
2160
2114 mlp->pv.BIG_M = (double) BIG_M_VALUE; 2161 mlp->pv.BIG_M = (double) BIG_M_VALUE;
2115 2162
2116 /* Get timeout for iterations */ 2163 /* Get timeout for iterations */