return elem;
}
-void System::expand(Constraint* cnst, Variable* var, double consumption_weight)
+void System::expand(Constraint* cnst, Variable* var, double consumption_weight, bool force_creation)
{
modified_ = true;
auto elem_it =
std::find_if(begin(var->cnsts_), end(var->cnsts_), [&cnst](Element const& x) { return x.constraint == cnst; });
- if (elem_it != end(var->cnsts_) && var->sharing_penalty_ != 0.0) {
+
+ bool reuse_elem = elem_it != end(var->cnsts_) && not force_creation;
+ if (reuse_elem && var->sharing_penalty_ != 0.0) {
/* before changing it, decreases concurrency on constraint, it'll be added back later */
elem_it->decrease_concurrency();
}
- Element& elem = elem_it != end(var->cnsts_) ? expand_add_to_elem(*elem_it, cnst, consumption_weight)
- : expand_create_elem(cnst, var, consumption_weight);
+ Element& elem = reuse_elem ? expand_add_to_elem(*elem_it, cnst, consumption_weight)
+ : expand_create_elem(cnst, var, consumption_weight);
// Check if we need to disable the variable
if (var->sharing_penalty_ != 0) {
* @param cnst A constraint
* @param var A variable
* @param value The coefficient associated to the variable in the constraint
+ * @param force_creation Force the creation of new element linking the variable to the constraint. Should be used only
+ * by the model ptask_L07 to cope with ptasks composed of flows running on the same resource (see
+ * https://framagit.org/simgrid/simgrid/-/issues/111)
*/
- void expand(Constraint * cnst, Variable * var, double value);
+ void expand(Constraint* cnst, Variable* var, double value, bool force_creation = false);
/** @brief Update the bound of a variable */
void update_variable_bound(Variable * var, double bound);
* communication either */
for (size_t i = 0; i < host_nb; i++) {
model->get_maxmin_system()->expand(host_list[i]->get_cpu()->get_constraint(), get_variable(),
- (flops_amount == nullptr ? 0.0 : flops_amount[i]));
+ (flops_amount == nullptr ? 0.0 : flops_amount[i]), true);
}
if (bytes_amount != nullptr) {