3 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(loba);
5 #include "loba_makhoul.h"
7 void loba_makhoul::load_balance()
9 pneigh_sort_by_load(std::less<double>());
11 print_loads_p(false, xbt_log_priority_debug);
13 double alpha = 1.0 / (pneigh.size() + 1.0);
14 double myLoad = get_load();
15 for (unsigned i = 0; i < pneigh.size(); i++) {
16 double delta = std::max(myLoad - pneigh[i]->get_load(), 0.0);
17 double transfer = alpha * delta;
18 XBT_DEBUG("delta = %g ; transfer = %g", delta, transfer);
19 if (get_load() - 2 * transfer < pneigh[i]->get_load())
21 send(pneigh[i], transfer);
22 XBT_DEBUG("sent %g to %s", transfer, pneigh[i]->get_name());