3 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(loba);
5 #include "loba_makhoul3.h"
7 void loba_makhoul3::load_balance()
9 pneigh_sort_by_load(std::less<double>());
10 print_loads_p(false, xbt_log_priority_debug);
12 int nb_less_loaded = 0;
13 for (unsigned i = 0 ; i < pneigh.size() ; ++i) {
14 nb_less_loaded += (pneigh[i]->get_load() <= get_load());
17 double alpha = 1.0 / (nb_less_loaded );
18 double my_load = get_load();
21 cont && i < pneigh.size() && pneigh[i]->get_load() < my_load ; ++i) {
23 double delta = my_load - pneigh[i]->get_load();
24 double transfer = alpha * delta;
25 XBT_DEBUG("delta = %g ; transfer = %g", delta, transfer);
26 if (pneigh[i]->get_load() + transfer <= get_load() - transfer) {
27 send(pneigh[i], transfer);
28 XBT_DEBUG("sent %g to %s", transfer, pneigh[i]->get_name());