aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-05-14 08:17:46 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-05-14 08:17:46 +0000
commit4cb749c370a4fd93a00734c5692a6e3664a5d67f (patch)
tree391ea69c7ca9d1225846c6285d0fbdf57e249fb9 /src/ats
parent62b5f9d7d649be845774ed4d876deb586f538c74 (diff)
downloadgnunet-4cb749c370a4fd93a00734c5692a6e3664a5d67f.tar.gz
gnunet-4cb749c370a4fd93a00734c5692a6e3664a5d67f.zip
read coefficients with cfg functions
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/perf_ats_solver.conf8
-rw-r--r--src/ats/plugin_ats_mlp.c112
2 files changed, 75 insertions, 45 deletions
diff --git a/src/ats/perf_ats_solver.conf b/src/ats/perf_ats_solver.conf
index debcef8c7..407dec323 100644
--- a/src/ats/perf_ats_solver.conf
+++ b/src/ats/perf_ats_solver.conf
@@ -35,10 +35,10 @@ PROP_STABILITY_FACTOR = 125
35 35
36# Maximum number of iterations for a solution process 36# Maximum number of iterations for a solution process
37# MLP_MAX_ITERATIONS = 1024 37# MLP_MAX_ITERATIONS = 1024
38# Tolerated MIP Gap [0.0 .. 1.0] 38# Tolerated MIP Gap [0.0 .. 1.0], default 0.025
39MLP_MAX_MIP_GAP = 0,0025 39MLP_MAX_MIP_GAP = 0.025
40# Tolerated LP/MIP Gap [0.0 .. 1.0] 40# Tolerated LP/MIP Gap [0.0 .. 1.0], default 0.025
41MLP_MAX_LP_MIP_GAP = 0,025 41MLP_MAX_LP_MIP_GAP = 0.025
42 42
43# MLP_COEFFICIENT_D = 1.0 43# MLP_COEFFICIENT_D = 1.0
44# MLP_COEFFICIENT_U = 1.0 44# MLP_COEFFICIENT_U = 1.0
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c
index 3c6523dae..ef6c978ca 100644
--- a/src/ats/plugin_ats_mlp.c
+++ b/src/ats/plugin_ats_mlp.c
@@ -2163,16 +2163,13 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2163 struct GNUNET_ATS_PluginEnvironment *env = cls; 2163 struct GNUNET_ATS_PluginEnvironment *env = cls;
2164 struct GAS_MLP_Handle * mlp = GNUNET_new (struct GAS_MLP_Handle); 2164 struct GAS_MLP_Handle * mlp = GNUNET_new (struct GAS_MLP_Handle);
2165 2165
2166 double D; 2166 float f_tmp;
2167 double R;
2168 double U;
2169 unsigned long long tmp; 2167 unsigned long long tmp;
2170 unsigned int b_min; 2168 unsigned int b_min;
2171 unsigned int n_min; 2169 unsigned int n_min;
2172 int c; 2170 int c;
2173 int c2; 2171 int c2;
2174 int found; 2172 int found;
2175 char *tmp_str;
2176 char *outputformat; 2173 char *outputformat;
2177 2174
2178 struct GNUNET_TIME_Relative max_duration; 2175 struct GNUNET_TIME_Relative max_duration;
@@ -2334,35 +2331,37 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2334 mlp->pv.BIG_M = (double) BIG_M_VALUE; 2331 mlp->pv.BIG_M = (double) BIG_M_VALUE;
2335 2332
2336 mlp->pv.mip_gap = (double) 0.0; 2333 mlp->pv.mip_gap = (double) 0.0;
2337 if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", 2334 if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
2338 "MLP_MAX_MIP_GAP", &tmp_str)) 2335 "MLP_MAX_MIP_GAP", &f_tmp))
2339 { 2336 {
2340 /* Dangerous due to localized separator , or . */ 2337 if ((f_tmp < 0.0) || (f_tmp > 1.0))
2341 mlp->pv.mip_gap = strtod (tmp_str, NULL);
2342 if ( (mlp->pv.mip_gap < 0.0) && (mlp->pv.mip_gap > 1.0) )
2343 { 2338 {
2344 LOG (GNUNET_ERROR_TYPE_INFO, "Invalid MIP gap configuration %u \n", 2339 LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
2345 tmp); 2340 "MIP gap", f_tmp);
2346 } 2341 }
2347 else 2342 else
2348 LOG (GNUNET_ERROR_TYPE_WARNING, "Using MIP gap of %.3f\n", 2343 {
2349 mlp->pv.mip_gap); 2344 mlp->pv.mip_gap = f_tmp;
2345 LOG (GNUNET_ERROR_TYPE_INFO, "Using %s of %.3f\n",
2346 "MIP gap", mlp->pv.mip_gap);
2347 }
2350 } 2348 }
2351 2349
2352 mlp->pv.lp_mip_gap = (double) 0.0; 2350 mlp->pv.lp_mip_gap = (double) 0.0;
2353 if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string (env->cfg, "ats", 2351 if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
2354 "MLP_MAX_LP_MIP_GAP", &tmp_str)) 2352 "MLP_MAX_LP_MIP_GAP", &f_tmp))
2355 { 2353 {
2356 /* Dangerous due to localized separator , or . */ 2354 if ((f_tmp < 0.0) || (f_tmp > 1.0))
2357 mlp->pv.lp_mip_gap = strtod (tmp_str, NULL);
2358 if ( (mlp->pv.lp_mip_gap < 0.0) && (mlp->pv.lp_mip_gap > 1.0) )
2359 { 2355 {
2360 LOG (GNUNET_ERROR_TYPE_INFO, "Invalid LP/MIP gap configuration %u \n", 2356 LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
2361 tmp); 2357 "LP/MIP", f_tmp);
2362 } 2358 }
2363 else 2359 else
2364 LOG (GNUNET_ERROR_TYPE_WARNING, "Using LP/MIP gap of %.3f\n", 2360 {
2365 mlp->pv.lp_mip_gap); 2361 mlp->pv.lp_mip_gap = f_tmp;
2362 LOG (GNUNET_ERROR_TYPE_INFO, "Using %s gap of %.3f\n",
2363 "LP/MIP", mlp->pv.lp_mip_gap);
2364 }
2366 } 2365 }
2367 2366
2368 /* Get timeout for iterations */ 2367 /* Get timeout for iterations */
@@ -2380,25 +2379,59 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2380 } 2379 }
2381 2380
2382 /* Get diversity coefficient from configuration */ 2381 /* Get diversity coefficient from configuration */
2383 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (env->cfg, 2382 mlp->pv.co_D = DEFAULT_D;
2384 "ats", "MLP_COEFFICIENT_D", &tmp)) 2383 if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
2385 D = (double) tmp / 100; 2384 "MLP_COEFFICIENT_D", &f_tmp))
2386 else 2385 {
2387 D = DEFAULT_D; 2386 if ((f_tmp < 0.0))
2387 {
2388 LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
2389 "MLP_COEFFICIENT_D", f_tmp);
2390 }
2391 else
2392 {
2393 mlp->pv.co_D = f_tmp;
2394 LOG (GNUNET_ERROR_TYPE_INFO, "Using %s gap of %.3f\n",
2395 "MLP_COEFFICIENT_D", mlp->pv.lp_mip_gap);
2396 }
2397 }
2398
2399 /* Get relativity coefficient from configuration */
2400 mlp->pv.co_R = DEFAULT_R;
2401 if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
2402 "MLP_COEFFICIENT_R", &f_tmp))
2403 {
2404 if ((f_tmp < 0.0))
2405 {
2406 LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
2407 "MLP_COEFFICIENT_R", f_tmp);
2408 }
2409 else
2410 {
2411 mlp->pv.co_R = f_tmp;
2412 LOG (GNUNET_ERROR_TYPE_INFO, "Using %s gap of %.3f\n",
2413 "MLP_COEFFICIENT_R", mlp->pv.lp_mip_gap);
2414 }
2415 }
2388 2416
2389 /* Get proportionality coefficient from configuration */
2390 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (env->cfg,
2391 "ats", "MLP_COEFFICIENT_R", &tmp))
2392 R = (double) tmp / 100;
2393 else
2394 R = DEFAULT_R;
2395 2417
2396 /* Get utilization coefficient from configuration */ 2418 /* Get utilization coefficient from configuration */
2397 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (env->cfg, 2419 mlp->pv.co_U = DEFAULT_U;
2398 "ats", "MLP_COEFFICIENT_U", &tmp)) 2420 if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
2399 U = (double) tmp / 100; 2421 "MLP_COEFFICIENT_U", &f_tmp))
2400 else 2422 {
2401 U = DEFAULT_U; 2423 if ((f_tmp < 0.0))
2424 {
2425 LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid %s configuration %f \n"),
2426 "MLP_COEFFICIENT_U", f_tmp);
2427 }
2428 else
2429 {
2430 mlp->pv.co_U = f_tmp;
2431 LOG (GNUNET_ERROR_TYPE_INFO, "Using %s gap of %.3f\n",
2432 "MLP_COEFFICIENT_U", mlp->pv.lp_mip_gap);
2433 }
2434 }
2402 2435
2403 /* Get quality metric coefficients from configuration */ 2436 /* Get quality metric coefficients from configuration */
2404 int i_delay = MLP_NaN; 2437 int i_delay = MLP_NaN;
@@ -2547,9 +2580,6 @@ libgnunet_plugin_ats_mlp_init (void *cls)
2547 mlp->get_properties_cls = env->get_property_cls; 2580 mlp->get_properties_cls = env->get_property_cls;
2548 /* Setting MLP Input variables */ 2581 /* Setting MLP Input variables */
2549 2582
2550 mlp->pv.co_D = D;
2551 mlp->pv.co_R = R;
2552 mlp->pv.co_U = U;
2553 mlp->pv.b_min = b_min; 2583 mlp->pv.b_min = b_min;
2554 mlp->pv.n_min = n_min; 2584 mlp->pv.n_min = n_min;
2555 mlp->pv.m_q = GNUNET_ATS_QualityPropertiesCount; 2585 mlp->pv.m_q = GNUNET_ATS_QualityPropertiesCount;