X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/96354e7d7c0f2985a2e8c08ec0f1ce64c6775628..94b462631204e69491f6cb175ca210830bb11088:/loba_makhoul2.cpp?ds=sidebyside diff --git a/loba_makhoul2.cpp b/loba_makhoul2.cpp index 6d7d12e..e6f629d 100644 --- a/loba_makhoul2.cpp +++ b/loba_makhoul2.cpp @@ -9,18 +9,20 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(loba); void loba_makhoul2::load_balance() { pneigh_sort_by_load(std::less()); - print_loads_p(false, xbt_log_priority_debug); double alpha = 1.0 / (pneigh.size() + 1.0); double neighborLoadMax = 0.0; // maximum load of neighbors to // which something has been sent for (unsigned i = 0; - i < pneigh.size() && pneigh[i]->get_load() < get_load(); i++) { + i < pneigh.size() && pneigh[i]->get_load() < get_load(); ++i) + { + double delta = get_load() - pneigh[i]->get_load(); // do not violate ping-pong condition double transfer = std::min(alpha * delta, get_load() - neighborLoadMax); + // note: alpha <= 1/2 XBT_DEBUG("delta = %g ; transfer = %g", delta, transfer); send(pneigh[i], transfer);