* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/kernel/lmm/maxmin.hpp"
+#if SIMGRID_HAVE_EIGEN3
+#include "src/kernel/lmm/bmf.hpp"
+#endif
#include <boost/core/demangle.hpp>
#include <typeinfo>
int Variable::next_rank_ = 1;
int Constraint::next_rank_ = 1;
+Element::Element(Constraint* constraint, Variable* variable, double cweight)
+ : constraint(constraint), variable(variable), consumption_weight(cweight), max_consumption_weight(cweight)
+{
+}
+
int Element::get_concurrency() const
{
// Ignore element with weight less than one (e.g. cross-traffic)
"Concurrency limit overflow!");
}
+System* System::build(const std::string& solver_name, bool selective_update)
+{
+ System* system = nullptr;
+ if (solver_name == "bmf") {
+#if SIMGRID_HAVE_EIGEN3
+ system = new lmm::BmfSystem(selective_update);
+#endif
+ } else if (solver_name == "fairbottleneck") {
+ system = new FairBottleneck(selective_update);
+ } else {
+ system = new System(selective_update);
+ }
+ return system;
+}
+
+void System::validate_solver(const std::string& solver_name)
+{
+ static const std::vector<std::string> opts{"bmf", "maxmin", "fairbottleneck"};
+ if (solver_name == "bmf") {
+#if !SIMGRID_HAVE_EIGEN3
+ xbt_die("Cannot use the BMF solver without installing Eigen3.");
+#endif
+ }
+ if (std::find(opts.begin(), opts.end(), solver_name) == std::end(opts)) {
+ xbt_die("Invalid system solver, it should be one of: \"maxmin\", \"fairbottleneck\" or \"bmf\"");
+ }
+}
+
void System::check_concurrency() const
{
// These checks are very expensive, so do them only if we want to debug SURF LMM
xbt_assert(var->cnsts_.size() < var->cnsts_.capacity(), "Too much constraints");
- var->cnsts_.emplace_back();
+ var->cnsts_.emplace_back(cnst, var, consumption_weight);
Element& elem = var->cnsts_.back();
- elem.consumption_weight = consumption_weight;
- elem.constraint = cnst;
- elem.variable = var;
-
if (var->sharing_penalty_ != 0.0) {
elem.constraint->enabled_element_set_.push_front(elem);
elem.increase_concurrency();
if (var->sharing_penalty_ != 0.0)
elem.decrease_concurrency();
+ elem.max_consumption_weight = std::max(elem.max_consumption_weight, value);
if (cnst->sharing_policy_ != Constraint::SharingPolicy::FATPIPE)
elem.consumption_weight += value;
else