From: Arnaud Giersch Date: Wed, 9 Mar 2022 08:56:38 +0000 (+0100) Subject: Provide constructor with parameters for lmm::Element. X-Git-Tag: v3.31~172 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/2b47959f389e1fad5f0c1682095754ef8723027b Provide constructor with parameters for lmm::Element. --- diff --git a/src/kernel/lmm/maxmin.cpp b/src/kernel/lmm/maxmin.cpp index 69493b6c0c..be1490391a 100644 --- a/src/kernel/lmm/maxmin.cpp +++ b/src/kernel/lmm/maxmin.cpp @@ -22,6 +22,11 @@ using dyn_light_t = std::vector; 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) @@ -236,14 +241,9 @@ void System::expand(Constraint* cnst, Variable* var, double consumption_weight) 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.max_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(); diff --git a/src/kernel/lmm/maxmin.hpp b/src/kernel/lmm/maxmin.hpp index cae7c20661..3f5a2f2d5e 100644 --- a/src/kernel/lmm/maxmin.hpp +++ b/src/kernel/lmm/maxmin.hpp @@ -146,7 +146,7 @@ class XBT_PUBLIC Element { public: // Use rule-of-three, and implicitely disable the move constructor which should be 'noexcept' according to C++ Core // Guidelines. - Element() = default; + Element(Constraint* constraint, Variable* variable, double cweight); Element(const Element&) = default; ~Element() = default; @@ -170,7 +170,7 @@ public: // - If network, then 1 in forward direction and 0.05 backward for the ACKs double consumption_weight; // maximum consumption weight (can be different from consumption_weight with subflows/ptasks) - double max_consumption_weight = 0; + double max_consumption_weight; }; class ConstraintLight { @@ -192,7 +192,6 @@ class XBT_PUBLIC Constraint { public: enum class SharingPolicy { NONLINEAR = 2, SHARED = 1, FATPIPE = 0 }; - Constraint() = delete; Constraint(resource::Resource* id_value, double bound_value); /** @brief Unshare a constraint. */