3 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(loba);
5 #include "loba_makhoul2.h"
7 // Note: adapted from Makhoul's code
9 void loba_makhoul2::load_balance()
11 pneigh_sort_by_load(std::less<double>());
13 print_loads_p(false, xbt_log_priority_debug);
15 double alpha = 1.0 / (pneigh.size() + 1.0);
16 double neighborLoadMax = 0.0; // maximum load of neighbors to
17 // which something has been sent
19 i < pneigh.size() && pneigh[i]->get_load() < get_load(); ++i)
22 double delta = get_load() - pneigh[i]->get_load();
24 // do not violate ping-pong condition
25 double transfer = std::min(alpha * delta, get_load() - neighborLoadMax);
27 XBT_DEBUG("delta = %g ; transfer = %g", delta, transfer);
29 send(pneigh[i], transfer);
30 XBT_DEBUG("sent %g to %s", transfer, pneigh[i]->get_name());
32 double newNeighborLoad = pneigh[i]->get_load();
33 if (newNeighborLoad > neighborLoadMax)
34 neighborLoadMax = newNeighborLoad;