diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-02-22 14:37:06 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-02-22 14:37:06 +0000 |
commit | 21f7abb96a59ece024cf63e72b3fb91eed6409e1 (patch) | |
tree | 4233336024818d9cef677728cac3c3e915185092 /src | |
parent | be143717676293b28b614659d4e322acb538dd24 (diff) | |
download | gnunet-21f7abb96a59ece024cf63e72b3fb91eed6409e1.tar.gz gnunet-21f7abb96a59ece024cf63e72b3fb91eed6409e1.zip |
changes
Diffstat (limited to 'src')
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_mlp.c | 102 |
1 files changed, 81 insertions, 21 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index 3d9ac4d88..529d06855 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c | |||
@@ -1074,26 +1074,6 @@ static int mlp_create_problem_count_addresses ( | |||
1074 | } | 1074 | } |
1075 | 1075 | ||
1076 | 1076 | ||
1077 | /** | ||
1078 | * Create the | ||
1079 | * - address columns b and n | ||
1080 | * - address dependent constraint rows c1, c3 | ||
1081 | * - peer dependent rows c2 and c9 | ||
1082 | * - Set address dependent entries in problem matrix as well | ||
1083 | */ | ||
1084 | static void | ||
1085 | mlp_create_problem_add_address_information (struct GAS_MLP_Handle *mlp, struct MLP_Problem *p) | ||
1086 | { | ||
1087 | /* Add peer dependent constraints */ | ||
1088 | /* Add constraint c2 */ | ||
1089 | /* Add constraint c9 */ | ||
1090 | |||
1091 | /* Add address dependent constraints */ | ||
1092 | /* Add constraint c1 */ | ||
1093 | /* Add constraint c3 */ | ||
1094 | |||
1095 | |||
1096 | } | ||
1097 | 1077 | ||
1098 | static void | 1078 | static void |
1099 | mlp_create_problem_set_value (struct MLP_Problem *p, int row, int col, double val) | 1079 | mlp_create_problem_set_value (struct MLP_Problem *p, int row, int col, double val) |
@@ -1114,6 +1094,86 @@ mlp_create_problem_set_value (struct MLP_Problem *p, int row, int col, double va | |||
1114 | } | 1094 | } |
1115 | 1095 | ||
1116 | /** | 1096 | /** |
1097 | * Create the | ||
1098 | * - address columns b and n | ||
1099 | * - address dependent constraint rows c1, c3 | ||
1100 | * - peer dependent rows c2 and c9 | ||
1101 | * - Set address dependent entries in problem matrix as well | ||
1102 | */ | ||
1103 | static int | ||
1104 | mlp_create_problem_add_address_information (void *cls, const struct GNUNET_HashCode *key, void *value) | ||
1105 | { | ||
1106 | struct GAS_MLP_Handle *mlp = cls; | ||
1107 | struct MLP_Problem *p = &mlp->p; | ||
1108 | struct ATS_Address *address = value; | ||
1109 | struct ATS_Peer *peer; | ||
1110 | struct MLP_information *mlpi; | ||
1111 | unsigned int col; | ||
1112 | char *name; | ||
1113 | |||
1114 | /* Check if we have to add this peer due to a pending request */ | ||
1115 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(mlp->peers, key)) | ||
1116 | return GNUNET_OK; | ||
1117 | |||
1118 | /* Prepare solver information */ | ||
1119 | if (NULL != address->solver_information) | ||
1120 | { | ||
1121 | GNUNET_free (address->solver_information); | ||
1122 | address->solver_information = NULL; | ||
1123 | } | ||
1124 | mlpi = GNUNET_malloc (sizeof (struct MLP_information)); | ||
1125 | address->solver_information = mlpi; | ||
1126 | |||
1127 | /* 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); | ||
1132 | glp_set_col_name (p->prob, mlpi->c_b , name); | ||
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); | ||
1144 | |||
1145 | /* Add usage column */ | ||
1146 | GNUNET_asprintf (&name, "n_%s_%s", GNUNET_i2s (&address->peer), address->plugin); | ||
1147 | glp_set_col_name (p->prob, mlpi->c_n, name); | ||
1148 | /* Limit value : 0 <= value <= 1 */ | ||
1149 | glp_set_col_bnds (p->prob, mlpi->c_n, GLP_DB, 0.0, 1.0); | ||
1150 | /* Integer value*/ | ||
1151 | glp_set_col_kind (p->prob, mlpi->c_n, GLP_IV); | ||
1152 | /* Objective function coefficient == 0 */ | ||
1153 | glp_set_obj_coef (p->prob, mlpi->c_n, 0); | ||
1154 | #if DEBUG_MLP_PROBLEM_CREATION | ||
1155 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added column [%u] `%s': `%s' address %p\n", | ||
1156 | mlpi->c_n, name, GNUNET_i2s(&address->peer), address); | ||
1157 | #endif | ||
1158 | GNUNET_free (name); | ||
1159 | |||
1160 | /* Get peer */ | ||
1161 | peer = GNUNET_CONTAINER_multihashmap_get (mlp->peers, key); | ||
1162 | peer->processed = GNUNET_NO; | ||
1163 | |||
1164 | |||
1165 | /* Add peer dependent constraints */ | ||
1166 | /* Add constraint c2 */ | ||
1167 | /* Add constraint c9 */ | ||
1168 | |||
1169 | /* Add address dependent constraints */ | ||
1170 | /* Add constraint c1 */ | ||
1171 | /* Add constraint c3 */ | ||
1172 | |||
1173 | return GNUNET_OK; | ||
1174 | } | ||
1175 | |||
1176 | /** | ||
1117 | * Create the invariant columns c4, c6, c10, c8, c7 | 1177 | * Create the invariant columns c4, c6, c10, c8, c7 |
1118 | */ | 1178 | */ |
1119 | static void | 1179 | static void |
@@ -1324,7 +1384,7 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas | |||
1324 | mlp_create_problem_add_invariant_rows (mlp, p); | 1384 | mlp_create_problem_add_invariant_rows (mlp, p); |
1325 | 1385 | ||
1326 | /* Adding address independent constraint rows */ | 1386 | /* Adding address independent constraint rows */ |
1327 | mlp_create_problem_add_address_information (mlp, p); | 1387 | GNUNET_CONTAINER_multihashmap_iterate (addresses, &mlp_create_problem_add_address_information, mlp); |
1328 | 1388 | ||
1329 | #if 0 | 1389 | #if 0 |
1330 | /* Add columns for addresses */ | 1390 | /* Add columns for addresses */ |