]> AND Private Git Repository - loba.git/blob - loba_fairstrategy.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
552f060bd0315dedc795b3049ee1abe4c096c05c
[loba.git] / loba_fairstrategy.cpp
1 #include <algorithm>
2 #include <xbt/log.h>
3
4 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(loba);
5
6 #include "loba_fairstrategy.h"
7
8 void loba_fairstrategy::load_balance()
9 {
10     const double delta = 0.001;
11
12     std::sort(pneigh.begin(), pneigh.end(), pneigh_load_greater());
13
14     print_loads_p(false, xbt_log_priority_debug);
15
16     bool found = true;
17
18     while (found) {
19         found = false;
20         for (unsigned i = 0 ; i < pneigh.size() ; ++i) {
21             if (pneigh[i]->get_load() <= get_load() - 2 * delta) {
22                 found = true;
23                 send(pneigh[i], delta);
24                 XBT_DEBUG("sent to %s", pneigh[i]->get_name());
25             }
26         }
27     }
28 }
29
30 // Local variables:
31 // mode: c++
32 // End: