diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-05-12 16:47:50 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-05-12 16:47:50 +0000 |
commit | ac2be7dde06b71347d87ed491eb38d64a9163ad8 (patch) | |
tree | eb96137d65b0305ad3ab008292466f068c3632d5 /src/ats/plugin_ats_mlp.c | |
parent | 6f1bbf8034e41837c33c5e3a7270c603a02e9d2e (diff) | |
download | gnunet-ac2be7dde06b71347d87ed491eb38d64a9163ad8.tar.gz gnunet-ac2be7dde06b71347d87ed491eb38d64a9163ad8.zip |
fixes for the solver and perf tool
Diffstat (limited to 'src/ats/plugin_ats_mlp.c')
-rw-r--r-- | src/ats/plugin_ats_mlp.c | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c index 1cbfbddfa..27a502f13 100644 --- a/src/ats/plugin_ats_mlp.c +++ b/src/ats/plugin_ats_mlp.c | |||
@@ -736,12 +736,12 @@ mlp_create_problem_add_address_information (void *cls, | |||
736 | for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) | 736 | for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) |
737 | { | 737 | { |
738 | addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE); | 738 | addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE); |
739 | |||
739 | if (GNUNET_ATS_VALUE_UNDEFINED == addr_net) | 740 | if (GNUNET_ATS_VALUE_UNDEFINED == addr_net) |
740 | { | 741 | { |
741 | GNUNET_break (0); | 742 | GNUNET_break (0); |
742 | addr_net = GNUNET_ATS_NET_UNSPECIFIED; | 743 | addr_net = GNUNET_ATS_NET_UNSPECIFIED; |
743 | } | 744 | } |
744 | |||
745 | if (mlp->pv.quota_index[c] == addr_net) | 745 | if (mlp->pv.quota_index[c] == addr_net) |
746 | { | 746 | { |
747 | mlp_create_problem_set_value (p, p->r_quota[c], mlpi->c_b, 1, __LINE__); | 747 | mlp_create_problem_set_value (p, p->r_quota[c], mlpi->c_b, 1, __LINE__); |
@@ -753,8 +753,16 @@ mlp_create_problem_add_address_information (void *cls, | |||
753 | /* For all quality metrics, set quality of this address */ | 753 | /* For all quality metrics, set quality of this address */ |
754 | props = mlp->get_properties (mlp->get_properties_cls, address); | 754 | props = mlp->get_properties (mlp->get_properties_cls, address); |
755 | for (c = 0; c < mlp->pv.m_q; c++) | 755 | for (c = 0; c < mlp->pv.m_q; c++) |
756 | { | ||
757 | if ((props[c] < 1.0) && (props[c] > 2.0)) | ||
758 | { | ||
759 | fprintf (stderr, "PROP == %.3f \t ", props[c]); | ||
760 | GNUNET_break (0); | ||
761 | } | ||
756 | mlp_create_problem_set_value (p, p->r_q[c], mlpi->c_b, props[c], __LINE__); | 762 | mlp_create_problem_set_value (p, p->r_q[c], mlpi->c_b, props[c], __LINE__); |
763 | } | ||
757 | 764 | ||
765 | //fprintf (stderr, "\n"); | ||
758 | return GNUNET_OK; | 766 | return GNUNET_OK; |
759 | } | 767 | } |
760 | 768 | ||
@@ -1173,7 +1181,7 @@ GAS_mlp_solve_problem (void *solver) | |||
1173 | return GNUNET_SYSERR; | 1181 | return GNUNET_SYSERR; |
1174 | } | 1182 | } |
1175 | notify(mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_SUCCESS, GAS_INFO_FULL); | 1183 | notify(mlp, GAS_OP_SOLVE_SETUP_STOP, GAS_STAT_SUCCESS, GAS_INFO_FULL); |
1176 | mlp->control_param_lp.presolve = GLP_YES; | 1184 | mlp->control_param_lp.presolve = GLP_YES; /* LP presolver, we need lp solution */ |
1177 | mlp->control_param_mlp.presolve = GNUNET_NO; /* No presolver, we have LP solution */ | 1185 | mlp->control_param_mlp.presolve = GNUNET_NO; /* No presolver, we have LP solution */ |
1178 | } | 1186 | } |
1179 | else | 1187 | else |
@@ -1192,7 +1200,8 @@ GAS_mlp_solve_problem (void *solver) | |||
1192 | start_cur_op = GNUNET_TIME_absolute_get(); | 1200 | start_cur_op = GNUNET_TIME_absolute_get(); |
1193 | 1201 | ||
1194 | /* Solve LP */ | 1202 | /* Solve LP */ |
1195 | mlp->control_param_lp.presolve = GLP_YES; | 1203 | /* Only for debugging, always use LP presolver: |
1204 | * mlp->control_param_lp.presolve = GLP_YES; */ | ||
1196 | res_lp = mlp_solve_lp_problem(mlp); | 1205 | res_lp = mlp_solve_lp_problem(mlp); |
1197 | 1206 | ||
1198 | dur_lp = GNUNET_TIME_absolute_get_duration (start_cur_op); | 1207 | dur_lp = GNUNET_TIME_absolute_get_duration (start_cur_op); |
@@ -1200,6 +1209,7 @@ GAS_mlp_solve_problem (void *solver) | |||
1200 | (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, | 1209 | (GNUNET_OK == res_lp) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, |
1201 | (GNUNET_YES == mlp->stat_mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); | 1210 | (GNUNET_YES == mlp->stat_mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); |
1202 | 1211 | ||
1212 | res_lp = GNUNET_OK; | ||
1203 | 1213 | ||
1204 | /* Run MLP solver */ | 1214 | /* Run MLP solver */ |
1205 | if (GNUNET_OK == res_lp) | 1215 | if (GNUNET_OK == res_lp) |
@@ -1210,7 +1220,8 @@ GAS_mlp_solve_problem (void *solver) | |||
1210 | start_cur_op = GNUNET_TIME_absolute_get(); | 1220 | start_cur_op = GNUNET_TIME_absolute_get(); |
1211 | 1221 | ||
1212 | /* Solve MIP */ | 1222 | /* Solve MIP */ |
1213 | //mlp->control_param_mlp.presolve = GNUNET_YES; | 1223 | /* Only for debugging, always use MLP presolver: |
1224 | * mlp->control_param_mlp.presolve = GNUNET_YES; */ | ||
1214 | res_mip = mlp_solve_mlp_problem(mlp); | 1225 | res_mip = mlp_solve_mlp_problem(mlp); |
1215 | 1226 | ||
1216 | dur_mlp = GNUNET_TIME_absolute_get_duration (start_cur_op); | 1227 | dur_mlp = GNUNET_TIME_absolute_get_duration (start_cur_op); |
@@ -1225,6 +1236,7 @@ GAS_mlp_solve_problem (void *solver) | |||
1225 | /* Do not execute mip solver since lp solution is invalid */ | 1236 | /* Do not execute mip solver since lp solution is invalid */ |
1226 | dur_mlp = GNUNET_TIME_UNIT_ZERO; | 1237 | dur_mlp = GNUNET_TIME_UNIT_ZERO; |
1227 | dur_total = GNUNET_TIME_absolute_get_duration (start_total); | 1238 | dur_total = GNUNET_TIME_absolute_get_duration (start_total); |
1239 | //GNUNET_break(0); | ||
1228 | notify(mlp, GAS_OP_SOLVE_MLP_MLP_STOP, GAS_STAT_FAIL, | 1240 | notify(mlp, GAS_OP_SOLVE_MLP_MLP_STOP, GAS_STAT_FAIL, |
1229 | (GNUNET_YES == mlp->stat_mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); | 1241 | (GNUNET_YES == mlp->stat_mlp_prob_changed) ? GAS_INFO_FULL : GAS_INFO_UPDATED); |
1230 | res_mip = GNUNET_SYSERR; | 1242 | res_mip = GNUNET_SYSERR; |
@@ -1254,7 +1266,7 @@ GAS_mlp_solve_problem (void *solver) | |||
1254 | mlp->ps.p_elements = mlp->p.num_elements; | 1266 | mlp->ps.p_elements = mlp->p.num_elements; |
1255 | 1267 | ||
1256 | /* Propagate result*/ | 1268 | /* Propagate result*/ |
1257 | notify(mlp, GAS_OP_SOLVE_UPDATE_NOTIFICATION_START, | 1269 | notify (mlp, GAS_OP_SOLVE_UPDATE_NOTIFICATION_START, |
1258 | (GNUNET_OK == res_lp) && (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, | 1270 | (GNUNET_OK == res_lp) && (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, |
1259 | GAS_INFO_NONE); | 1271 | GAS_INFO_NONE); |
1260 | if ((GNUNET_OK == res_lp) && (GNUNET_OK == res_mip)) | 1272 | if ((GNUNET_OK == res_lp) && (GNUNET_OK == res_mip)) |
@@ -1262,7 +1274,7 @@ GAS_mlp_solve_problem (void *solver) | |||
1262 | GNUNET_CONTAINER_multipeermap_iterate(mlp->addresses, | 1274 | GNUNET_CONTAINER_multipeermap_iterate(mlp->addresses, |
1263 | &mlp_propagate_results, mlp); | 1275 | &mlp_propagate_results, mlp); |
1264 | } | 1276 | } |
1265 | notify(mlp, GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP, | 1277 | notify (mlp, GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP, |
1266 | (GNUNET_OK == res_lp) && (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, | 1278 | (GNUNET_OK == res_lp) && (GNUNET_OK == res_mip) ? GAS_STAT_SUCCESS : GAS_STAT_FAIL, |
1267 | GAS_INFO_NONE); | 1279 | GAS_INFO_NONE); |
1268 | 1280 | ||
@@ -1375,7 +1387,7 @@ GAS_mlp_address_property_changed (void *solver, | |||
1375 | 1387 | ||
1376 | if (NULL == mlpi) | 1388 | if (NULL == mlpi) |
1377 | { | 1389 | { |
1378 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1390 | LOG (GNUNET_ERROR_TYPE_INFO, |
1379 | _("Updating address property `%s' for peer `%s' %p not added before\n"), | 1391 | _("Updating address property `%s' for peer `%s' %p not added before\n"), |
1380 | GNUNET_ATS_print_property_type (type), | 1392 | GNUNET_ATS_print_property_type (type), |
1381 | GNUNET_i2s(&address->peer), | 1393 | GNUNET_i2s(&address->peer), |
@@ -1390,9 +1402,11 @@ GAS_mlp_address_property_changed (void *solver, | |||
1390 | /* Peer is not requested, so no need to update problem */ | 1402 | /* Peer is not requested, so no need to update problem */ |
1391 | return; | 1403 | return; |
1392 | } | 1404 | } |
1393 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating property `%s' address for peer `%s'\n", | 1405 | LOG (GNUNET_ERROR_TYPE_INFO, "Updating property `%s' address for peer `%s' to abs %llu rel %.3f\n", |
1394 | GNUNET_ATS_print_property_type (type), | 1406 | GNUNET_ATS_print_property_type (type), |
1395 | GNUNET_i2s(&address->peer)); | 1407 | GNUNET_i2s(&address->peer), |
1408 | abs_value, | ||
1409 | rel_value); | ||
1396 | 1410 | ||
1397 | /* Find row index */ | 1411 | /* Find row index */ |
1398 | type_index = -1; | 1412 | type_index = -1; |
@@ -1681,16 +1695,23 @@ get_peer_pref_value (struct GAS_MLP_Handle *mlp, const struct GNUNET_PeerIdentit | |||
1681 | int c; | 1695 | int c; |
1682 | preferences = mlp->get_preferences (mlp->get_preferences_cls, peer); | 1696 | preferences = mlp->get_preferences (mlp->get_preferences_cls, peer); |
1683 | 1697 | ||
1684 | res = 1.0; | 1698 | res = 0.0; |
1685 | for (c = 0; c < GNUNET_ATS_PreferenceCount; c++) | 1699 | for (c = 0; c < GNUNET_ATS_PreferenceCount; c++) |
1686 | { | 1700 | { |
1687 | if (c != GNUNET_ATS_PREFERENCE_END) | 1701 | if (c != GNUNET_ATS_PREFERENCE_END) |
1688 | { | 1702 | { |
1689 | //fprintf (stderr, "VALUE[%u] %s %.3f \n", c, GNUNET_i2s (&cur->addr->peer), t[c]); | 1703 | /* fprintf (stderr, "VALUE[%u] %s %.3f \n", |
1704 | * c, GNUNET_i2s (&cur->addr->peer), t[c]); */ | ||
1690 | res += preferences[c]; | 1705 | res += preferences[c]; |
1691 | } | 1706 | } |
1692 | } | 1707 | } |
1708 | |||
1693 | res /= (GNUNET_ATS_PreferenceCount -1); | 1709 | res /= (GNUNET_ATS_PreferenceCount -1); |
1710 | res += 1.0; | ||
1711 | |||
1712 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peer preference for peer `%s' == %.2f\n", | ||
1713 | GNUNET_i2s(peer), res); | ||
1714 | |||
1694 | return res; | 1715 | return res; |
1695 | } | 1716 | } |
1696 | 1717 | ||
@@ -1847,13 +1868,10 @@ GAS_mlp_address_change_preference (void *solver, | |||
1847 | /* Update relativity constraint c9 */ | 1868 | /* Update relativity constraint c9 */ |
1848 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, peer))) | 1869 | if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, peer))) |
1849 | { | 1870 | { |
1850 | LOG (GNUNET_ERROR_TYPE_ERROR, "Updating preference for unknown peer `%s'\n", GNUNET_i2s(peer)); | 1871 | LOG (GNUNET_ERROR_TYPE_INFO, "Updating preference for unknown peer `%s'\n", GNUNET_i2s(peer)); |
1851 | return; | 1872 | return; |
1852 | } | 1873 | } |
1853 | p->f = get_peer_pref_value (mlp, peer); | 1874 | p->f = get_peer_pref_value (mlp, peer); |
1854 | /* | ||
1855 | LOG (GNUNET_ERROR_TYPE_ERROR, "PEER PREF: %s %.2f\n", | ||
1856 | GNUNET_i2s(peer), p->f);*/ | ||
1857 | mlp_create_problem_update_value (&mlp->p, p->r_c9, mlp->p.c_r, -p->f, __LINE__); | 1875 | mlp_create_problem_update_value (&mlp->p, p->r_c9, mlp->p.c_r, -p->f, __LINE__); |
1858 | 1876 | ||
1859 | /* Problem size changed: new address for peer with pending request */ | 1877 | /* Problem size changed: new address for peer with pending request */ |