Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Provide constructor with parameters for lmm::Element.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 9 Mar 2022 08:56:38 +0000 (09:56 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 9 Mar 2022 09:42:27 +0000 (10:42 +0100)
src/kernel/lmm/maxmin.cpp
src/kernel/lmm/maxmin.hpp

index 69493b6..be14903 100644 (file)
@@ -22,6 +22,11 @@ using dyn_light_t = std::vector<int>;
 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();
index cae7c20..3f5a2f2 100644 (file)
@@ -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. */