From: Arnaud Giersch Date: Wed, 23 Feb 2011 17:20:20 +0000 (+0100) Subject: Fix loba_simple. X-Git-Tag: v0.1~115 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/ed20272a081c9c5fe276cd8e7815662e23b79318?ds=inline;hp=--cc Fix loba_simple. It was not doing exactly what was envisioned. --- ed20272a081c9c5fe276cd8e7815662e23b79318 diff --git a/loba_simple.cpp b/loba_simple.cpp index 3858acc..5a0a153 100644 --- a/loba_simple.cpp +++ b/loba_simple.cpp @@ -27,10 +27,11 @@ void loba_simple::load_balance() max = l; } } - if (imin != -1) { - // found someone - double balance = (get_load() - max) / 2; - XBT_DEBUG("%d:%g %d:%g %g %g", imin, min, imax, max, get_load(), balance); + if (imin != -1) { // found someone + double balance = std::min((get_load() - min) / 2.0, + (get_load() - max)); + XBT_DEBUG("%d:%g %d:%g %g %g", + imin, min, imax, max, get_load(), balance); send(pneigh[imin], balance); } }