aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-01-19 12:55:58 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-01-19 12:55:58 +0000
commit1df3690d0e3503a1bf3a7ecabd2fa3ba0e16ed0a (patch)
tree7f97bd58918b842d00f68e95d76ed6ed0a3c0358 /src/ats
parent6525120b1e00378a99a0a70af700f0907e40eecd (diff)
downloadgnunet-1df3690d0e3503a1bf3a7ecabd2fa3ba0e16ed0a.tar.gz
gnunet-1df3690d0e3503a1bf3a7ecabd2fa3ba0e16ed0a.zip
- problem matrix index starts with 1 not 0
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c
index 74869e94c..78bb5f21a 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.c
+++ b/src/ats/gnunet-service-ats_addresses_mlp.c
@@ -32,7 +32,7 @@
32#include "glpk.h" 32#include "glpk.h"
33#include "float.h" 33#include "float.h"
34 34
35#define WRITE_MLP GNUNET_NO 35#define WRITE_MLP GNUNET_YES
36#define DEBUG_ATS GNUNET_YES 36#define DEBUG_ATS GNUNET_YES
37/* A very big value */ 37/* A very big value */
38#define M DBL_MAX 38#define M DBL_MAX
@@ -257,7 +257,7 @@ create_constraint_it (void *cls, const GNUNET_HashCode * key, void *value)
257 mlp->ja[mlp->ci] = mlpi->c_n; 257 mlp->ja[mlp->ci] = mlpi->c_n;
258 mlp->ar[mlp->ci] = -M; 258 mlp->ar[mlp->ci] = -M;
259 mlp->ci++; 259 mlp->ci++;
260#if 0 260
261 /* c 3) minimum bandwidth 261 /* c 3) minimum bandwidth
262 * b_t + (-n_t * b_min) >= 0 262 * b_t + (-n_t * b_min) >= 0
263 */ 263 */
@@ -276,7 +276,7 @@ create_constraint_it (void *cls, const GNUNET_HashCode * key, void *value)
276 mlp->ja[mlp->ci] = mlpi->c_n; 276 mlp->ja[mlp->ci] = mlpi->c_n;
277 mlp->ar[mlp->ci] = -mlp->b_min; 277 mlp->ar[mlp->ci] = -mlp->b_min;
278 mlp->ci++; 278 mlp->ci++;
279 279#if 0
280 /* c 4) minimum connections 280 /* c 4) minimum connections
281 * (1)*n_1 + ... + (1)*n_m >= n_min 281 * (1)*n_1 + ... + (1)*n_m >= n_min
282 */ 282 */
@@ -490,7 +490,7 @@ create_columns_it (void *cls, const GNUNET_HashCode * key, void *value)
490 /* Continuous value*/ 490 /* Continuous value*/
491 glp_set_col_kind (mlp->prob, mlpi->c_b , GLP_CV); 491 glp_set_col_kind (mlp->prob, mlpi->c_b , GLP_CV);
492 /* Objective function coefficient == 0 */ 492 /* Objective function coefficient == 0 */
493 glp_set_obj_coef (mlp->prob, mlpi->c_b , 0); 493 glp_set_obj_coef (mlp->prob, mlpi->c_b , 1);
494 494
495 495
496 /* Add usage column */ 496 /* Add usage column */
@@ -535,6 +535,10 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas
535 /* Set optimization direction to maximize */ 535 /* Set optimization direction to maximize */
536 glp_set_obj_dir (mlp->prob, GLP_MAX); 536 glp_set_obj_dir (mlp->prob, GLP_MAX);
537 537
538 /* Setting initial index == 1
539 * glpk matrix is from 1 .. number_elements*/
540
541 mlp->ci = 1;
538 /* Adding invariant columns */ 542 /* Adding invariant columns */
539 543
540 /* Diversity d column */ 544 /* Diversity d column */
@@ -590,7 +594,7 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas
590 mlp_add_constraints_all_addresses (mlp, addresses); 594 mlp_add_constraints_all_addresses (mlp, addresses);
591 595
592 /* Load the matrix */ 596 /* Load the matrix */
593 glp_load_matrix(mlp->prob, (mlp->ci - 1), mlp->ia, mlp->ja, mlp->ar); 597 glp_load_matrix(mlp->prob, (mlp->ci-1), mlp->ia, mlp->ja, mlp->ar);
594 598
595 return res; 599 return res;
596} 600}