aboutsummaryrefslogtreecommitdiff
path: root/src/ats/gnunet-service-ats-solver_mlp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats/gnunet-service-ats-solver_mlp.c')
-rw-r--r--src/ats/gnunet-service-ats-solver_mlp.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/ats/gnunet-service-ats-solver_mlp.c b/src/ats/gnunet-service-ats-solver_mlp.c
index f36a3808e..f32ad101a 100644
--- a/src/ats/gnunet-service-ats-solver_mlp.c
+++ b/src/ats/gnunet-service-ats-solver_mlp.c
@@ -177,8 +177,8 @@ mlp_term_hook (void *info, const char *s)
177 * @return GNUNET_OK 177 * @return GNUNET_OK
178 */ 178 */
179static int 179static int
180reset_peers (void *cls, 180reset_peers (void *cls,
181 const struct GNUNET_PeerIdentity *key, 181 const struct GNUNET_PeerIdentity *key,
182 void *value) 182 void *value)
183 { 183 {
184 struct ATS_Peer *peer = value; 184 struct ATS_Peer *peer = value;
@@ -239,7 +239,7 @@ mlp_delete_problem (struct GAS_MLP_Handle *mlp)
239 mlp->p.ci = MLP_UNDEFINED; 239 mlp->p.ci = MLP_UNDEFINED;
240 240
241 241
242 GNUNET_CONTAINER_multipeermap_iterate (mlp->requested_peers, 242 GNUNET_CONTAINER_multipeermap_iterate (mlp->requested_peers,
243 &reset_peers, NULL); 243 &reset_peers, NULL);
244} 244}
245 245
@@ -393,7 +393,7 @@ struct CountContext
393}; 393};
394 394
395static int 395static int
396mlp_create_problem_count_addresses_it (void *cls, 396mlp_create_problem_count_addresses_it (void *cls,
397 const struct GNUNET_PeerIdentity *key, 397 const struct GNUNET_PeerIdentity *key,
398 void *value) 398 void *value)
399{ 399{
@@ -406,7 +406,7 @@ mlp_create_problem_count_addresses_it (void *cls,
406} 406}
407 407
408 408
409static int 409static int
410mlp_create_problem_count_addresses (const struct GNUNET_CONTAINER_MultiPeerMap *peers, 410mlp_create_problem_count_addresses (const struct GNUNET_CONTAINER_MultiPeerMap *peers,
411 const struct GNUNET_CONTAINER_MultiPeerMap *addresses) 411 const struct GNUNET_CONTAINER_MultiPeerMap *addresses)
412{ 412{
@@ -414,7 +414,7 @@ mlp_create_problem_count_addresses (const struct GNUNET_CONTAINER_MultiPeerMap *
414 414
415 cctx.peers = peers; 415 cctx.peers = peers;
416 cctx.result = 0; 416 cctx.result = 0;
417 GNUNET_CONTAINER_multipeermap_iterate (addresses, 417 GNUNET_CONTAINER_multipeermap_iterate (addresses,
418 &mlp_create_problem_count_addresses_it, &cctx); 418 &mlp_create_problem_count_addresses_it, &cctx);
419 return cctx.result; 419 return cctx.result;
420} 420}
@@ -600,8 +600,8 @@ mlp_create_problem_create_constraint (struct MLP_Problem *p, char *name,
600 * - Set address dependent entries in problem matrix as well 600 * - Set address dependent entries in problem matrix as well
601 */ 601 */
602static int 602static int
603mlp_create_problem_add_address_information (void *cls, 603mlp_create_problem_add_address_information (void *cls,
604 const struct GNUNET_PeerIdentity *key, 604 const struct GNUNET_PeerIdentity *key,
605 void *value) 605 void *value)
606{ 606{
607 struct GAS_MLP_Handle *mlp = cls; 607 struct GAS_MLP_Handle *mlp = cls;
@@ -842,7 +842,7 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp)
842 LOG (GNUNET_ERROR_TYPE_DEBUG, 842 LOG (GNUNET_ERROR_TYPE_DEBUG,
843 "Rebuilding problem for %u peer(s) and %u addresse(s) and %u quality metrics == %u elements\n", 843 "Rebuilding problem for %u peer(s) and %u addresse(s) and %u quality metrics == %u elements\n",
844 p->num_peers, 844 p->num_peers,
845 p->num_addresses, 845 p->num_addresses,
846 mlp->pv.m_q, 846 mlp->pv.m_q,
847 p->num_elements); 847 p->num_elements);
848 848
@@ -874,8 +874,8 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp)
874 mlp_create_problem_add_invariant_rows (mlp, p); 874 mlp_create_problem_add_invariant_rows (mlp, p);
875 875
876 /* Adding address dependent columns constraint rows */ 876 /* Adding address dependent columns constraint rows */
877 GNUNET_CONTAINER_multipeermap_iterate (mlp->addresses, 877 GNUNET_CONTAINER_multipeermap_iterate (mlp->addresses,
878 &mlp_create_problem_add_address_information, 878 &mlp_create_problem_add_address_information,
879 mlp); 879 mlp);
880 880
881 /* Load the matrix */ 881 /* Load the matrix */
@@ -961,8 +961,8 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp)
961 * @return #GNUNET_OK to continue 961 * @return #GNUNET_OK to continue
962 */ 962 */
963int 963int
964mlp_propagate_results (void *cls, 964mlp_propagate_results (void *cls,
965 const struct GNUNET_PeerIdentity *key, 965 const struct GNUNET_PeerIdentity *key,
966 void *value) 966 void *value)
967{ 967{
968 struct GAS_MLP_Handle *mlp = cls; 968 struct GAS_MLP_Handle *mlp = cls;
@@ -973,7 +973,7 @@ mlp_propagate_results (void *cls,
973 double mlp_use = MLP_NaN; 973 double mlp_use = MLP_NaN;
974 974
975 /* Check if we have to add this peer due to a pending request */ 975 /* Check if we have to add this peer due to a pending request */
976 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (mlp->requested_peers, 976 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (mlp->requested_peers,
977 key)) 977 key))
978 { 978 {
979 return GNUNET_OK; 979 return GNUNET_OK;
@@ -1224,12 +1224,12 @@ GAS_mlp_address_add (void *solver,
1224 address->solver_information = GNUNET_new (struct MLP_information); 1224 address->solver_information = GNUNET_new (struct MLP_information);
1225 } 1225 }
1226 else 1226 else
1227 LOG (GNUNET_ERROR_TYPE_ERROR, 1227 LOG (GNUNET_ERROR_TYPE_ERROR,
1228 _("Adding address for peer `%s' multiple times\n"), 1228 _("Adding address for peer `%s' multiple times\n"),
1229 GNUNET_i2s(&address->peer)); 1229 GNUNET_i2s(&address->peer));
1230 1230
1231 /* Is this peer included in the problem? */ 1231 /* Is this peer included in the problem? */
1232 if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers, 1232 if (NULL == (p = GNUNET_CONTAINER_multipeermap_get (mlp->requested_peers,
1233 &address->peer))) 1233 &address->peer)))
1234 { 1234 {
1235 LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding address for peer `%s' without address request \n", GNUNET_i2s(&address->peer)); 1235 LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding address for peer `%s' without address request \n", GNUNET_i2s(&address->peer));
@@ -1529,8 +1529,8 @@ GAS_mlp_address_delete (void *solver,
1529 * @return GNUNET_OK 1529 * @return GNUNET_OK
1530 */ 1530 */
1531static int 1531static int
1532mlp_get_preferred_address_it (void *cls, 1532mlp_get_preferred_address_it (void *cls,
1533 const struct GNUNET_PeerIdentity *key, 1533 const struct GNUNET_PeerIdentity *key,
1534 void *value) 1534 void *value)
1535{ 1535{
1536 static int counter = 0; 1536 static int counter = 0;
@@ -1563,7 +1563,7 @@ mlp_get_preferred_address_it (void *cls,
1563} 1563}
1564 1564
1565 1565
1566static double 1566static double
1567get_peer_pref_value (struct GAS_MLP_Handle *mlp, const struct GNUNET_PeerIdentity *peer) 1567get_peer_pref_value (struct GAS_MLP_Handle *mlp, const struct GNUNET_PeerIdentity *peer)
1568{ 1568{
1569 double res; 1569 double res;
@@ -1616,8 +1616,8 @@ GAS_mlp_get_preferred_address (void *solver,
1616 p = GNUNET_malloc (sizeof (struct ATS_Peer)); 1616 p = GNUNET_malloc (sizeof (struct ATS_Peer));
1617 p->id = (*peer); 1617 p->id = (*peer);
1618 p->f = get_peer_pref_value (mlp, peer); 1618 p->f = get_peer_pref_value (mlp, peer);
1619 GNUNET_CONTAINER_multipeermap_put (mlp->requested_peers, 1619 GNUNET_CONTAINER_multipeermap_put (mlp->requested_peers,
1620 peer, p, 1620 peer, p,
1621 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 1621 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1622 1622
1623 /* Added new peer, we have to rebuild problem before solving */ 1623 /* Added new peer, we have to rebuild problem before solving */
@@ -1780,7 +1780,7 @@ GAS_mlp_address_preference_feedback (void *solver,
1780 1780
1781 1781
1782static int 1782static int
1783mlp_free_peers (void *cls, 1783mlp_free_peers (void *cls,
1784 const struct GNUNET_PeerIdentity *key, void *value) 1784 const struct GNUNET_PeerIdentity *key, void *value)
1785{ 1785{
1786 struct GNUNET_CONTAINER_MultiPeerMap *map = cls; 1786 struct GNUNET_CONTAINER_MultiPeerMap *map = cls;
@@ -1807,8 +1807,8 @@ GAS_mlp_done (void *solver)
1807 LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down mlp solver\n"); 1807 LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down mlp solver\n");
1808 mlp_delete_problem (mlp); 1808 mlp_delete_problem (mlp);
1809 1809
1810 GNUNET_CONTAINER_multipeermap_iterate (mlp->requested_peers, 1810 GNUNET_CONTAINER_multipeermap_iterate (mlp->requested_peers,
1811 &mlp_free_peers, 1811 &mlp_free_peers,
1812 mlp->requested_peers); 1812 mlp->requested_peers);
1813 GNUNET_CONTAINER_multipeermap_destroy (mlp->requested_peers); 1813 GNUNET_CONTAINER_multipeermap_destroy (mlp->requested_peers);
1814 mlp->requested_peers = NULL; 1814 mlp->requested_peers = NULL;