Not tested.
--- /dev/null
+#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:
--- /dev/null
+#ifndef LOBA_MAKHOUL_H
+#define LOBA_MAKHOUL_H
+
+#include "process.h"
+
+class loba_makhoul: public process {
+public:
+ loba_makhoul(int argc, char* argv[]): process(argc, argv) { }
+ ~loba_makhoul() { }
+
+private:
+ void load_balance();
+};
+
+#endif //!LOBA_MAKHOUL_H
+
+// Local variables:
+// mode: c++
+// End:
#include "process.h"
#include "loba_simple.h"
#include "loba_fairstrategy.h"
+#include "loba_makhoul.h"
#include "options.h"
loba_algorithms_type::loba_algorithms_type()
{
NOL_INSERT("fairstrategy", "balance with fair strategy", loba_fairstrategy);
+ NOL_INSERT("makhoul", "balance with Makhoul's PhD algorithm", loba_makhoul);
NOL_INSERT("none", "no load-balancing (for testing only)", process);
NOL_INSERT("simple", "balance with least loaded neighbor", loba_simple);
}