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

Private GIT Repository
Add units in XML files.
[loba.git] / loba_2besteffort.cpp
index 820c7a5f813a6a0d2deba0b4a6c72a691506400c..5573714463bb607fe9b3cdb10246e78e1925eff1 100644 (file)
@@ -1,5 +1,4 @@
 #include <cmath>                // std::isfinite
 #include <cmath>                // std::isfinite
-#include <functional>
 #include <numeric>
 #include <xbt/log.h>
 
 #include <numeric>
 #include <xbt/log.h>
 
@@ -9,16 +8,14 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(loba);
 
 void loba_2besteffort::load_balance()
 {
 
 void loba_2besteffort::load_balance()
 {
-    using std::placeholders::_1;
-    using std::placeholders::_2;
-
     pneigh_sort_by_load(std::less<double>());
     print_loads_p(false, xbt_log_priority_debug);
 
     double sum = get_load() +
         std::accumulate(pneigh.begin(), pneigh.end(), 0.0,
     pneigh_sort_by_load(std::less<double>());
     print_loads_p(false, xbt_log_priority_debug);
 
     double sum = get_load() +
         std::accumulate(pneigh.begin(), pneigh.end(), 0.0,
-                        std::bind(std::plus<double>(), _1,
-                                  std::bind(&neighbor::get_load, _2)));
+                        [](double x, const neighbor* n) {
+                            return x + n->get_load();
+                        });
     double mean = sum / (pneigh.size() + 1);
     XBT_DEBUG("sum = %g ; mean = %g", sum, mean);
 
     double mean = sum / (pneigh.size() + 1);
     XBT_DEBUG("sum = %g ; mean = %g", sum, mean);
 
@@ -31,8 +28,8 @@ void loba_2besteffort::load_balance()
         // don't continue if get_load() <= mean, or pneigh[i]->get_load >= mean
         if (transfer <= 0.0)
             break;
         // don't continue if get_load() <= mean, or pneigh[i]->get_load >= mean
         if (transfer <= 0.0)
             break;
-        if (opt::option_x)
-            transfer /= opt::option_x; // HACK!!!
+        if (opt::loba_best_divisor)
+            transfer /= opt::loba_best_divisor;
         send(pneigh[i], transfer);
         XBT_DEBUG("sent %g to %s", transfer, pneigh[i]->get_name());
     }
         send(pneigh[i], transfer);
         XBT_DEBUG("sent %g to %s", transfer, pneigh[i]->get_name());
     }