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

Private GIT Repository
Use std::vector and stl algorithms for cost_func.
[loba.git] / loba_makhoul.cpp
1 #include <xbt/log.h>
2
3 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(loba);
4
5 #include "loba_makhoul.h"
6
7 void loba_makhoul::load_balance()
8 {
9     pneigh_sort_by_load(std::less<double>());
10
11     print_loads_p(false, xbt_log_priority_debug);
12
13     double alpha = 1.0 / (pneigh.size() + 1.0);
14     double delta;
15     for (unsigned i = 0 ;
16          i < pneigh.size() &&
17              (delta = get_load() - pneigh[i]->get_load()) > 0.0 ;
18          ++i) {
19         send(pneigh[i], delta * alpha);
20     }
21 }
22
23 // Local variables:
24 // mode: c++
25 // End: