diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-02-21 15:50:22 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-02-21 15:50:22 +0000 |
commit | 96f4d3db52d746a12c848370beb625df3b1aac4a (patch) | |
tree | a0aaeffb8bede8d0fec7ad1f3e8b20e2bcbb6d05 /src | |
parent | 2e7a719b552a1729684e90c6620553c42260576a (diff) | |
download | gnunet-96f4d3db52d746a12c848370beb625df3b1aac4a.tar.gz gnunet-96f4d3db52d746a12c848370beb625df3b1aac4a.zip |
auto_solve
Diffstat (limited to 'src')
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_mlp.c | 27 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_mlp.h | 14 |
2 files changed, 28 insertions, 13 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index ac82a6a12..74b54026c 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c | |||
@@ -554,7 +554,6 @@ update_quality (struct GAS_MLP_Handle *mlp, struct ATS_Address * address) | |||
554 | 554 | ||
555 | /** | 555 | /** |
556 | * Add constraints that are iterating over "forall addresses" | 556 | * Add constraints that are iterating over "forall addresses" |
557 | * and collects all existing peers for "forall peers" constraints | ||
558 | * | 557 | * |
559 | * @param cls GAS_MLP_Handle | 558 | * @param cls GAS_MLP_Handle |
560 | * @param key Hashcode | 559 | * @param key Hashcode |
@@ -568,6 +567,7 @@ mlp_create_constraint_it (void *cls, const struct GNUNET_HashCode * key, void *v | |||
568 | struct GAS_MLP_Handle *mlp = cls; | 567 | struct GAS_MLP_Handle *mlp = cls; |
569 | struct MLP_Problem *p = &mlp->p; | 568 | struct MLP_Problem *p = &mlp->p; |
570 | struct ATS_Address *address = value; | 569 | struct ATS_Address *address = value; |
570 | struct ATS_Peer *peer = NULL; | ||
571 | struct MLP_information *mlpi; | 571 | struct MLP_information *mlpi; |
572 | unsigned int row_index; | 572 | unsigned int row_index; |
573 | char *name; | 573 | char *name; |
@@ -576,6 +576,16 @@ mlp_create_constraint_it (void *cls, const struct GNUNET_HashCode * key, void *v | |||
576 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(mlp->peers, key)) | 576 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(mlp->peers, key)) |
577 | return GNUNET_OK; | 577 | return GNUNET_OK; |
578 | 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 | |||
579 | GNUNET_assert (address->solver_information != NULL); | 589 | GNUNET_assert (address->solver_information != NULL); |
580 | mlpi = (struct MLP_information *) address->solver_information; | 590 | mlpi = (struct MLP_information *) address->solver_information; |
581 | 591 | ||
@@ -845,13 +855,13 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON | |||
845 | { | 855 | { |
846 | p->r_quota[c] = glp_add_rows (p->prob, 1); | 856 | p->r_quota[c] = glp_add_rows (p->prob, 1); |
847 | char * text; | 857 | char * text; |
848 | GNUNET_asprintf(&text, "quota_ats_%i", mlp->pv.quota_index[c]); | 858 | GNUNET_asprintf(&text, "quota_ats_%s", GNUNET_ATS_print_network_type(mlp->pv.quota_index[c])); |
849 | glp_set_row_name (p->prob, p->r_quota[c], text); | 859 | glp_set_row_name (p->prob, p->r_quota[c], text); |
850 | /* Set bounds to 0 <= x <= quota_out */ | 860 | /* Set bounds to 0 <= x <= quota_out */ |
851 | glp_set_row_bnds (p->prob, p->r_quota[c], GLP_UP, 0.0, mlp->pv.quota_out[c]); | 861 | glp_set_row_bnds (p->prob, p->r_quota[c], GLP_UP, 0.0, mlp->pv.quota_out[c]); |
852 | #if DEBUG_MLP_PROBLEM_CREATION | 862 | #if DEBUG_MLP_PROBLEM_CREATION |
853 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added row [%u] `%s': %s %u\n", | 863 | LOG (GNUNET_ERROR_TYPE_DEBUG, "[P]: Added row [%u] `%s': %s %u\n", |
854 | p->r_quota[c], name, | 864 | p->r_quota[c], text, |
855 | "<=", mlp->pv.quota_out[c]); | 865 | "<=", mlp->pv.quota_out[c]); |
856 | #endif | 866 | #endif |
857 | GNUNET_free (text); | 867 | GNUNET_free (text); |
@@ -1584,7 +1594,8 @@ GAS_mlp_address_add (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addres | |||
1584 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding address for peer `%s' with address request \n", GNUNET_i2s(&address->peer)); | 1594 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding address for peer `%s' with address request \n", GNUNET_i2s(&address->peer)); |
1585 | /* Problem size changed: new address for peer with pending request */ | 1595 | /* Problem size changed: new address for peer with pending request */ |
1586 | mlp->mlp_prob_changed = GNUNET_YES; | 1596 | mlp->mlp_prob_changed = GNUNET_YES; |
1587 | GAS_mlp_solve_problem (solver, addresses); | 1597 | if (GNUNET_YES == mlp->mlp_auto_solve) |
1598 | GAS_mlp_solve_problem (solver, addresses); | ||
1588 | } | 1599 | } |
1589 | 1600 | ||
1590 | /** | 1601 | /** |
@@ -1633,7 +1644,8 @@ GAS_mlp_address_update (void *solver, | |||
1633 | 1644 | ||
1634 | /* Problem size changed: new address for peer with pending request */ | 1645 | /* Problem size changed: new address for peer with pending request */ |
1635 | mlp->mlp_prob_updated = GNUNET_YES; | 1646 | mlp->mlp_prob_updated = GNUNET_YES; |
1636 | GAS_mlp_solve_problem (solver, addresses); | 1647 | if (GNUNET_YES == mlp->mlp_auto_solve) |
1648 | GAS_mlp_solve_problem (solver, addresses); | ||
1637 | return; | 1649 | return; |
1638 | 1650 | ||
1639 | #if 0 | 1651 | #if 0 |
@@ -1765,7 +1777,8 @@ GAS_mlp_address_delete (void *solver, | |||
1765 | 1777 | ||
1766 | /* Problem size changed: new address for peer with pending request */ | 1778 | /* Problem size changed: new address for peer with pending request */ |
1767 | mlp->mlp_prob_changed = GNUNET_YES; | 1779 | mlp->mlp_prob_changed = GNUNET_YES; |
1768 | GAS_mlp_solve_problem (solver, addresses); | 1780 | if (GNUNET_YES == mlp->mlp_auto_solve) |
1781 | GAS_mlp_solve_problem (solver, addresses); | ||
1769 | return; | 1782 | return; |
1770 | 1783 | ||
1771 | #if 0 | 1784 | #if 0 |
@@ -2200,7 +2213,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
2200 | mlp->pv.m_q = GNUNET_ATS_QualityPropertiesCount; | 2213 | mlp->pv.m_q = GNUNET_ATS_QualityPropertiesCount; |
2201 | mlp->mlp_prob_changed = GNUNET_NO; | 2214 | mlp->mlp_prob_changed = GNUNET_NO; |
2202 | mlp->mlp_prob_updated = GNUNET_NO; | 2215 | mlp->mlp_prob_updated = GNUNET_NO; |
2203 | 2216 | mlp->mlp_auto_solve = GNUNET_YES; | |
2204 | mlp->peers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); | 2217 | mlp->peers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); |
2205 | 2218 | ||
2206 | /* Setup GLPK */ | 2219 | /* Setup GLPK */ |
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h index efb819c60..04ead545e 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.h +++ b/src/ats/gnunet-service-ats_addresses_mlp.h | |||
@@ -258,6 +258,14 @@ struct GAS_MLP_Handle | |||
258 | int mlp_prob_changed; | 258 | int mlp_prob_changed; |
259 | 259 | ||
260 | 260 | ||
261 | /** | ||
262 | * Solve the problem automatically when updates occur? | ||
263 | * Default: GNUNET_YES | ||
264 | * Can be disabled for test and measurements | ||
265 | */ | ||
266 | int mlp_auto_solve; | ||
267 | |||
268 | |||
261 | #if 0 | 269 | #if 0 |
262 | /** | 270 | /** |
263 | * Interval between scheduled problem solving | 271 | * Interval between scheduled problem solving |
@@ -274,12 +282,6 @@ struct GAS_MLP_Handle | |||
274 | */ | 282 | */ |
275 | unsigned int max_iterations; | 283 | unsigned int max_iterations; |
276 | 284 | ||
277 | /** | ||
278 | * Solve the problem automatically when updates occur? | ||
279 | * Default: GNUNET_YES | ||
280 | * Can be disabled for test and measurements | ||
281 | */ | ||
282 | int auto_solve; | ||
283 | 285 | ||
284 | /** | 286 | /** |
285 | * Is a solution attemp running? | 287 | * Is a solution attemp running? |