diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-02-22 15:21:23 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-02-22 15:21:23 +0000 |
commit | 4be398a16f46ff903fc4ea79cd2d1d00fa6b0174 (patch) | |
tree | ad92f38363b2a80f2a3c357139cf7e636406a6e9 | |
parent | f6a740636d7a43be40a13b2c5c83ec4c3e6f81a5 (diff) | |
download | gnunet-4be398a16f46ff903fc4ea79cd2d1d00fa6b0174.tar.gz gnunet-4be398a16f46ff903fc4ea79cd2d1d00fa6b0174.zip |
simplyfiying code
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_mlp.c | 330 |
1 files changed, 71 insertions, 259 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index 529d06855..32730b206 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c | |||
@@ -572,116 +572,7 @@ mlp_create_constraint_it (void *cls, const struct GNUNET_HashCode * key, void *v | |||
572 | unsigned int row_index; | 572 | unsigned int row_index; |
573 | char *name; | 573 | char *name; |
574 | 574 | ||
575 | /* Check if we have to add this peer due to a pending request */ | ||
576 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(mlp->peers, key)) | ||
577 | return GNUNET_OK; | ||
578 | |||
579 | /* Get peer */ | ||
580 | peer = GNUNET_CONTAINER_multihashmap_get (mlp->peers, key); | ||
581 | GNUNET_assert (NULL != peer); | ||
582 | if (GNUNET_NO == peer->processed) | ||
583 | { | ||
584 | /* Adding constraints for peer */ | ||
585 | peer->processed = GNUNET_YES; | ||
586 | } | ||
587 | |||
588 | |||
589 | GNUNET_assert (address->solver_information != NULL); | ||
590 | mlpi = (struct MLP_information *) address->solver_information; | ||
591 | |||
592 | /* c 1) bandwidth capping | ||
593 | * b_t + (-M) * n_t <= 0 | ||
594 | * */ | ||
595 | row_index = glp_add_rows (p->prob, 1); | ||
596 | mlpi->r_c1 = row_index; | ||
597 | /* set row name */ | ||
598 | GNUNET_asprintf(&name, "c1_%s_%s", GNUNET_i2s(&address->peer), address->plugin); | ||
599 | glp_set_row_name (p->prob, row_index, name); | ||
600 | /* set row bounds: <= 0 */ | ||
601 | glp_set_row_bnds (p->prob, row_index, GLP_UP, 0.0, 0.0); | ||
602 | #if DEBUG_MLP_PROBLEM_CREATION | ||
603 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added row [%u] `%s': %s %u\n", | ||
604 | row_index, name, | ||
605 | "<=", 0); | ||
606 | #endif | ||
607 | GNUNET_free (name); | ||
608 | |||
609 | p->ia[p->ci] = row_index; | ||
610 | p->ja[p->ci] = mlpi->c_b; | ||
611 | p->ar[p->ci] = 1; | ||
612 | #if DEBUG_MLP_PROBLEM_CREATION | ||
613 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Set value [%u,%u] == %.2f\n", | ||
614 | p->ia[p->ci], p->ja[p->ci], p->ar[p->ci]); | ||
615 | #endif | ||
616 | p->ci++; | ||
617 | |||
618 | p->ia[p->ci] = row_index; | ||
619 | p->ja[p->ci] = mlpi->c_n; | ||
620 | p->ar[p->ci] = -mlp->pv.BIG_M; | ||
621 | #if DEBUG_MLP_PROBLEM_CREATION | ||
622 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Set value [%u,%u] == %.2f\n", | ||
623 | p->ia[p->ci], p->ja[p->ci], p->ar[p->ci]); | ||
624 | #endif | ||
625 | p->ci++; | ||
626 | |||
627 | /* c 3) minimum bandwidth | ||
628 | * b_t + (-n_t * b_min) >= 0 | ||
629 | * */ | ||
630 | row_index = glp_add_rows (p->prob, 1); | ||
631 | mlpi->r_c3 = row_index; | ||
632 | /* set row name */ | ||
633 | GNUNET_asprintf(&name, "c3_%s_%s", GNUNET_i2s(&address->peer), address->plugin); | ||
634 | glp_set_row_name (p->prob, row_index, name); | ||
635 | /* set row bounds: >= 0 */ | ||
636 | glp_set_row_bnds (p->prob, row_index, GLP_LO, 0.0, 0.0); | ||
637 | #if DEBUG_MLP_PROBLEM_CREATION | ||
638 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added row [%u] `%s': %s %u\n", | ||
639 | row_index, name, | ||
640 | "<=", 0); | ||
641 | #endif | ||
642 | GNUNET_free (name); | ||
643 | |||
644 | p->ia[p->ci] = row_index; | ||
645 | p->ja[p->ci] = mlpi->c_b; | ||
646 | p->ar[p->ci] = 1; | ||
647 | #if DEBUG_MLP_PROBLEM_CREATION | ||
648 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Set value [%u,%u] == %.2f\n", | ||
649 | p->ia[p->ci], p->ja[p->ci], p->ar[p->ci]); | ||
650 | #endif | ||
651 | p->ci++; | ||
652 | |||
653 | p->ia[p->ci] = row_index; | ||
654 | p->ja[p->ci] = mlpi->c_n; | ||
655 | p->ar[p->ci] = - (double) mlp->pv.b_min; | ||
656 | #if DEBUG_MLP_PROBLEM_CREATION | ||
657 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Set value [%u,%u] == %.2f\n", | ||
658 | p->ia[p->ci], p->ja[p->ci], p->ar[p->ci]); | ||
659 | #endif | ||
660 | p->ci++; | ||
661 | |||
662 | /* c 4) minimum connections | ||
663 | * (1)*n_1 + ... + (1)*n_m >= n_min | ||
664 | */ | ||
665 | p->ia[p->ci] = p->r_c4; | ||
666 | p->ja[p->ci] = mlpi->c_n; | ||
667 | p->ar[p->ci] = 1; | ||
668 | #if DEBUG_MLP_PROBLEM_CREATION | ||
669 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Set value [%u,%u] == %.2f\n", | ||
670 | p->ia[p->ci], p->ja[p->ci], p->ar[p->ci]); | ||
671 | #endif | ||
672 | p->ci++; | ||
673 | 575 | ||
674 | /* c 6) maximize diversity | ||
675 | * (1)*n_1 + ... + (1)*n_m - d == 0 | ||
676 | */ | ||
677 | p->ia[p->ci] = p->r_c6; | ||
678 | p->ja[p->ci] = mlpi->c_n; | ||
679 | p->ar[p->ci] = 1; | ||
680 | #if DEBUG_MLP_PROBLEM_CREATION | ||
681 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Set value [%u,%u] == %.2f\n", | ||
682 | p->ia[p->ci], p->ja[p->ci], p->ar[p->ci]); | ||
683 | #endif | ||
684 | p->ci++; | ||
685 | 576 | ||
686 | /* c 10) obey network specific quotas | 577 | /* c 10) obey network specific quotas |
687 | * (1)*b_1 + ... + (1)*b_m <= quota_n | 578 | * (1)*b_1 + ... + (1)*b_m <= quota_n |
@@ -967,83 +858,6 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON | |||
967 | } | 858 | } |
968 | } | 859 | } |
969 | 860 | ||
970 | #if 0 | ||
971 | /** | ||
972 | * Add columns for all addresses | ||
973 | * | ||
974 | * @param cls GAS_MLP_Handle | ||
975 | * @param key Hashcode | ||
976 | * @param value ATS_Address | ||
977 | * | ||
978 | * @return GNUNET_OK to continue | ||
979 | */ | ||
980 | static int | ||
981 | mlp_create_address_columns_it (void *cls, const struct GNUNET_HashCode * key, void *value) | ||
982 | { | ||
983 | struct GAS_MLP_Handle *mlp = cls; | ||
984 | struct MLP_Problem *p = &mlp->p; | ||
985 | struct ATS_Address *address = value; | ||
986 | struct ATS_Peer *peer; | ||
987 | struct MLP_information *mlpi; | ||
988 | unsigned int col; | ||
989 | char *name; | ||
990 | |||
991 | if (NULL != address->solver_information) | ||
992 | { | ||
993 | GNUNET_free (address->solver_information); | ||
994 | address->solver_information = NULL; | ||
995 | } | ||
996 | |||
997 | /* Check if we have to add this peer due to a pending request */ | ||
998 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(mlp->peers, key)) | ||
999 | return GNUNET_OK; | ||
1000 | |||
1001 | /* Get peer */ | ||
1002 | peer = GNUNET_CONTAINER_multihashmap_get (mlp->peers, key); | ||
1003 | peer->processed = GNUNET_NO; | ||
1004 | |||
1005 | p->num_addresses ++; | ||
1006 | mlpi = GNUNET_malloc (sizeof (struct MLP_information)); | ||
1007 | address->solver_information = mlpi; | ||
1008 | |||
1009 | /* Add bandwidth column */ | ||
1010 | col = glp_add_cols (p->prob, 2); | ||
1011 | mlpi->c_b = col; | ||
1012 | mlpi->c_n = col + 1; | ||
1013 | |||
1014 | |||
1015 | GNUNET_asprintf (&name, "b_%s_%s", GNUNET_i2s (&address->peer), address->plugin); | ||
1016 | glp_set_col_name (p->prob, mlpi->c_b , name); | ||
1017 | /* Lower bound == 0 */ | ||
1018 | glp_set_col_bnds (p->prob, mlpi->c_b , GLP_LO, 0.0, 0.0); | ||
1019 | /* Continuous value*/ | ||
1020 | glp_set_col_kind (p->prob, mlpi->c_b , GLP_CV); | ||
1021 | /* Objective function coefficient == 0 */ | ||
1022 | glp_set_obj_coef (p->prob, mlpi->c_b , 0); | ||
1023 | #if DEBUG_MLP_PROBLEM_CREATION | ||
1024 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%u] `%s': `%s' address %p\n", | ||
1025 | mlpi->c_b, name, GNUNET_i2s(&address->peer), address); | ||
1026 | #endif | ||
1027 | GNUNET_free (name); | ||
1028 | |||
1029 | /* Add usage column */ | ||
1030 | GNUNET_asprintf (&name, "n_%s_%s", GNUNET_i2s (&address->peer), address->plugin); | ||
1031 | glp_set_col_name (p->prob, mlpi->c_n, name); | ||
1032 | /* Limit value : 0 <= value <= 1 */ | ||
1033 | glp_set_col_bnds (p->prob, mlpi->c_n, GLP_DB, 0.0, 1.0); | ||
1034 | /* Integer value*/ | ||
1035 | glp_set_col_kind (p->prob, mlpi->c_n, GLP_IV); | ||
1036 | /* Objective function coefficient == 0 */ | ||
1037 | glp_set_obj_coef (p->prob, mlpi->c_n, 0); | ||
1038 | #if DEBUG_MLP_PROBLEM_CREATION | ||
1039 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%u] `%s': `%s' address %p\n", | ||
1040 | mlpi->c_n, name, GNUNET_i2s(&address->peer), address); | ||
1041 | #endif | ||
1042 | GNUNET_free (name); | ||
1043 | |||
1044 | return GNUNET_OK; | ||
1045 | } | ||
1046 | #endif | ||
1047 | 861 | ||
1048 | 862 | ||
1049 | struct CountContext | 863 | struct CountContext |
@@ -1093,6 +907,23 @@ mlp_create_problem_set_value (struct MLP_Problem *p, int row, int col, double va | |||
1093 | p->ci++; | 907 | p->ci++; |
1094 | } | 908 | } |
1095 | 909 | ||
910 | static int | ||
911 | mlp_create_problem_create_column (struct MLP_Problem *p, char *name, | ||
912 | unsigned int type, unsigned int bound, double lb, double ub, | ||
913 | double coef) | ||
914 | { | ||
915 | int col = glp_add_cols (p->prob, 1); | ||
916 | glp_set_col_name (p->prob, col, name); | ||
917 | glp_set_col_bnds (p->prob, col, bound, lb, ub); | ||
918 | glp_set_col_kind (p->prob, col, type); | ||
919 | glp_set_obj_coef (p->prob, col, coef); | ||
920 | #if DEBUG_MLP_PROBLEM_CREATION | ||
921 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%u] `%s': %.2f\n", | ||
922 | col, name, coef); | ||
923 | #endif | ||
924 | return col; | ||
925 | } | ||
926 | |||
1096 | /** | 927 | /** |
1097 | * Create the | 928 | * Create the |
1098 | * - address columns b and n | 929 | * - address columns b and n |
@@ -1125,37 +956,63 @@ mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashC | |||
1125 | address->solver_information = mlpi; | 956 | address->solver_information = mlpi; |
1126 | 957 | ||
1127 | /* Add bandwidth column */ | 958 | /* Add bandwidth column */ |
1128 | col = glp_add_cols (p->prob, 2); | ||
1129 | mlpi->c_b = col; | ||
1130 | mlpi->c_n = col + 1; | ||
1131 | GNUNET_asprintf (&name, "b_%s_%s", GNUNET_i2s (&address->peer), address->plugin); | 959 | GNUNET_asprintf (&name, "b_%s_%s", GNUNET_i2s (&address->peer), address->plugin); |
1132 | glp_set_col_name (p->prob, mlpi->c_b , name); | 960 | mlpi->c_b = mlp_create_problem_create_column (p, name, GLP_CV, GLP_LO, 0.0, 0.0, 0.0); |
1133 | /* Lower bound == 0 */ | ||
1134 | glp_set_col_bnds (p->prob, mlpi->c_b , GLP_LO, 0.0, 0.0); | ||
1135 | /* Continuous value*/ | ||
1136 | glp_set_col_kind (p->prob, mlpi->c_b , GLP_CV); | ||
1137 | /* Objective function coefficient == 0 */ | ||
1138 | glp_set_obj_coef (p->prob, mlpi->c_b , 0); | ||
1139 | #if DEBUG_MLP_PROBLEM_CREATION | ||
1140 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%u] `%s': `%s' address %p\n", | ||
1141 | mlpi->c_b, name, GNUNET_i2s(&address->peer), address); | ||
1142 | #endif | ||
1143 | GNUNET_free (name); | 961 | GNUNET_free (name); |
1144 | 962 | ||
1145 | /* Add usage column */ | 963 | /* Add usage column */ |
1146 | GNUNET_asprintf (&name, "n_%s_%s", GNUNET_i2s (&address->peer), address->plugin); | 964 | GNUNET_asprintf (&name, "n_%s_%s", GNUNET_i2s (&address->peer), address->plugin); |
1147 | glp_set_col_name (p->prob, mlpi->c_n, name); | 965 | mlpi->c_n = mlp_create_problem_create_column (p, name, GLP_IV, GLP_DB, 0.0, 1.0, 0.0); |
1148 | /* Limit value : 0 <= value <= 1 */ | 966 | GNUNET_free (name); |
1149 | glp_set_col_bnds (p->prob, mlpi->c_n, GLP_DB, 0.0, 1.0); | 967 | |
1150 | /* Integer value*/ | 968 | /* Add address dependent constraints */ |
1151 | glp_set_col_kind (p->prob, mlpi->c_n, GLP_IV); | 969 | /* Add constraint c1) bandwidth capping |
1152 | /* Objective function coefficient == 0 */ | 970 | * b_t + (-M) * n_t <= 0 |
1153 | glp_set_obj_coef (p->prob, mlpi->c_n, 0); | 971 | * */ |
972 | mlpi->r_c1 = glp_add_rows (p->prob, 1); | ||
973 | /* set row name */ | ||
974 | GNUNET_asprintf(&name, "c1_%s_%s", GNUNET_i2s(&address->peer), address->plugin); | ||
975 | glp_set_row_name (p->prob, mlpi->r_c1, name); | ||
976 | /* set row bounds: <= 0 */ | ||
977 | glp_set_row_bnds (p->prob, mlpi->r_c1, GLP_UP, 0.0, 0.0); | ||
1154 | #if DEBUG_MLP_PROBLEM_CREATION | 978 | #if DEBUG_MLP_PROBLEM_CREATION |
1155 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%u] `%s': `%s' address %p\n", | 979 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added row [%u] `%s': %s %u\n", |
1156 | mlpi->c_n, name, GNUNET_i2s(&address->peer), address); | 980 | mlpi->r_c1, name, |
981 | "<=", 0); | ||
1157 | #endif | 982 | #endif |
1158 | GNUNET_free (name); | 983 | GNUNET_free (name); |
984 | /* c1) set b = 1 coefficient */ | ||
985 | mlp_create_problem_set_value (p, mlpi->r_c1, mlpi->c_b, 1); | ||
986 | /* c1) set n = -M coefficient */ | ||
987 | mlp_create_problem_set_value (p, mlpi->r_c1, mlpi->c_n, -mlp->pv.BIG_M); | ||
988 | |||
989 | /* Add constraint c 3) minimum bandwidth | ||
990 | * b_t + (-n_t * b_min) >= 0 | ||
991 | * */ | ||
992 | mlpi->r_c3 = glp_add_rows (p->prob, 1); | ||
993 | /* set row name */ | ||
994 | GNUNET_asprintf(&name, "c3_%s_%s", GNUNET_i2s(&address->peer), address->plugin); | ||
995 | glp_set_row_name (p->prob, mlpi->r_c3, name); | ||
996 | /* set row bounds: >= 0 */ | ||
997 | glp_set_row_bnds (p->prob, mlpi->r_c3, GLP_LO, 0.0, 0.0); | ||
998 | #if DEBUG_MLP_PROBLEM_CREATION | ||
999 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added row [%u] `%s': %s %u\n", | ||
1000 | mlpi->r_c3, name, | ||
1001 | "<=", 0); | ||
1002 | #endif | ||
1003 | GNUNET_free (name); | ||
1004 | /* c3) set b = 1 coefficient */ | ||
1005 | mlp_create_problem_set_value (p, mlpi->r_c3, mlpi->c_b, 1); | ||
1006 | /* c3) set n = -b_min coefficient */ | ||
1007 | mlp_create_problem_set_value (p, mlpi->r_c3, mlpi->c_n, -mlp->pv.b_min); | ||
1008 | |||
1009 | |||
1010 | /* Set coefficient entries in invariant rows */ | ||
1011 | /* c 4) minimum connections */ | ||
1012 | mlp_create_problem_set_value (p, p->r_c4, mlpi->c_n, 1); | ||
1013 | /* c 6) maximize diversity */ | ||
1014 | mlp_create_problem_set_value (p, p->r_c6, mlpi->c_n, 1); | ||
1015 | |||
1159 | 1016 | ||
1160 | /* Get peer */ | 1017 | /* Get peer */ |
1161 | peer = GNUNET_CONTAINER_multihashmap_get (mlp->peers, key); | 1018 | peer = GNUNET_CONTAINER_multihashmap_get (mlp->peers, key); |
@@ -1166,9 +1023,6 @@ mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashC | |||
1166 | /* Add constraint c2 */ | 1023 | /* Add constraint c2 */ |
1167 | /* Add constraint c9 */ | 1024 | /* Add constraint c9 */ |
1168 | 1025 | ||
1169 | /* Add address dependent constraints */ | ||
1170 | /* Add constraint c1 */ | ||
1171 | /* Add constraint c3 */ | ||
1172 | 1026 | ||
1173 | return GNUNET_OK; | 1027 | return GNUNET_OK; |
1174 | } | 1028 | } |
@@ -1269,63 +1123,21 @@ mlp_create_problem_add_invariant_columns (struct GAS_MLP_Handle *mlp, struct MLP | |||
1269 | { | 1123 | { |
1270 | char *name; | 1124 | char *name; |
1271 | int c; | 1125 | int c; |
1272 | int cur_col; | ||
1273 | 1126 | ||
1274 | /* Diversity d column */ | 1127 | /* Diversity d column */ |
1275 | p->c_d = glp_add_cols (p->prob, 1); | 1128 | p->c_d = mlp_create_problem_create_column (p, "d", GLP_CV, GLP_LO, 0.0, 0.0, mlp->pv.co_D); |
1276 | /* Column name */ | ||
1277 | glp_set_col_name (p->prob, p->c_d, "d"); | ||
1278 | /* Column objective function coefficient */ | ||
1279 | glp_set_obj_coef (p->prob, p->c_d, mlp->pv.co_D); | ||
1280 | /* Column lower bound = 0.0 */ | ||
1281 | glp_set_col_bnds (p->prob, p->c_d, GLP_LO, 0.0, 0.0); | ||
1282 | #if DEBUG_MLP_PROBLEM_CREATION | ||
1283 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%i] `%s': %.2f \n", | ||
1284 | p->c_d, "d", mlp->pv.co_D); | ||
1285 | #endif | ||
1286 | |||
1287 | 1129 | ||
1288 | /* Utilization u column */ | 1130 | /* Utilization u column */ |
1289 | p->c_u = glp_add_cols (p->prob, 1); | 1131 | p->c_u = mlp_create_problem_create_column (p, "u", GLP_CV, GLP_LO, 0.0, 0.0, mlp->pv.co_U); |
1290 | /* Column name */ | ||
1291 | glp_set_col_name (p->prob, p->c_u, "u"); | ||
1292 | /* Column objective function coefficient */ | ||
1293 | glp_set_obj_coef (p->prob, p->c_u, mlp->pv.co_U); | ||
1294 | /* Column lower bound = 0.0 */ | ||
1295 | glp_set_col_bnds (p->prob, p->c_u, GLP_LO, 0.0, 0.0); | ||
1296 | #if DEBUG_MLP_PROBLEM_CREATION | ||
1297 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%i] `%s': %.2f \n", | ||
1298 | p->c_u, "u", mlp->pv.co_U); | ||
1299 | #endif | ||
1300 | 1132 | ||
1301 | /* Relativity r column */ | 1133 | /* Relativity r column */ |
1302 | p->c_r = glp_add_cols (p->prob, 1); | 1134 | p->c_r = mlp_create_problem_create_column (p, "u", GLP_CV, GLP_LO, 0.0, 0.0, mlp->pv.co_R); |
1303 | /* Column name */ | ||
1304 | glp_set_col_name (p->prob, p->c_r, "r"); | ||
1305 | /* Column objective function coefficient */ | ||
1306 | glp_set_obj_coef (p->prob, p->c_r, mlp->pv.co_R); | ||
1307 | /* Column lower bound = 0.0 */ | ||
1308 | glp_set_col_bnds (p->prob, p->c_r, GLP_LO, 0.0, 0.0); | ||
1309 | #if DEBUG_MLP_PROBLEM_CREATION | ||
1310 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%i] `%s': %.2f \n", | ||
1311 | p->c_r, "r", mlp->pv.co_R); | ||
1312 | #endif | ||
1313 | 1135 | ||
1314 | /* Quality metric columns */ | 1136 | /* Quality metric columns */ |
1315 | cur_col = glp_add_cols(p->prob, mlp->pv.m_q); | ||
1316 | for (c = 0; c < mlp->pv.m_q; c++) | 1137 | for (c = 0; c < mlp->pv.m_q; c++) |
1317 | { | 1138 | { |
1318 | p->c_q[c] = cur_col + c; | ||
1319 | GNUNET_asprintf (&name, "q_%u", mlp->pv.q[c]); | 1139 | GNUNET_asprintf (&name, "q_%u", mlp->pv.q[c]); |
1320 | glp_set_col_name (p->prob, p->c_q[c], name); | 1140 | p->c_q[c] = mlp_create_problem_create_column (p, name, GLP_CV, GLP_LO, 0.0, 0.0, mlp->pv.co_Q[c]); |
1321 | /* Column lower bound = 0.0 */ | ||
1322 | glp_set_col_bnds (p->prob, p->c_q[c], GLP_LO, 0.0, 0.0); | ||
1323 | /* Coefficient == Qm */ | ||
1324 | glp_set_obj_coef (p->prob, p->c_q[c], mlp->pv.co_Q[c]); | ||
1325 | #if DEBUG_MLP_PROBLEM_CREATION | ||
1326 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%i] `%s': %.2f \n", | ||
1327 | p->c_q[c], name, mlp->pv.co_Q[c]); | ||
1328 | #endif | ||
1329 | GNUNET_free (name); | 1141 | GNUNET_free (name); |
1330 | } | 1142 | } |
1331 | } | 1143 | } |