+#include <algorithm>
+#include <xbt/log.h>
+
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(loba);
+
+#include "loba_makhoul.h"
+
+class compare {
+public:
+ bool operator()(const neighbor*a, const neighbor*b) {
+ return a->get_load() < b->get_load();
+ }
+};
+
+void loba_makhoul::load_balance()
+{
+ std::sort(pneigh.begin(), pneigh.end(), compare());
+
+ print_loads_p(false, xbt_log_priority_debug);
+
+ double alpha = 1.0 / (pneigh.size() + 1.0);
+ double delta;
+ for (unsigned i = 0 ;
+ i < pneigh.size() &&
+ (delta = get_load() - pneigh[i]->get_load()) > 0.0 ;
+ ++i) {
+ send(pneigh[i], delta * alpha);
+ }
+}
+
+// Local variables:
+// mode: c++
+// End: