]> AND Private Git Repository - loba.git/blobdiff - loba_makhoul2.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Use a do..while() loop instead of this ugly continue statement.
[loba.git] / loba_makhoul2.cpp
index 6d7d12edb914ef77156b4869723af47c4a56f9aa..e6f629d6b6a93abc7c0183e733dc581af103666e 100644 (file)
@@ -9,18 +9,20 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(loba);
 void loba_makhoul2::load_balance()
 {
     pneigh_sort_by_load(std::less<double>());
 void loba_makhoul2::load_balance()
 {
     pneigh_sort_by_load(std::less<double>());
-
     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;
     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);
         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);
         XBT_DEBUG("delta = %g ; transfer = %g", delta, transfer);
 
         send(pneigh[i], transfer);