- if (!found) {
- XBT_DEBUG("cnst %p is not found in var %p", cnst, var);
- return;
- }
-
- sys->modified = 1;
-
- XBT_DEBUG("remove elem(value %f, cnst %p, var %p) in var %p",
- elem->value, elem->constraint, elem->variable, var);
-
- /* We are going to change the constraint object and the variable object.
- * Propagate this change to other objects. Calling here before removing variable from not active elements (inactive elements are not visited)
- */
- lmm_update_modified_set(sys, cnst);
- //Useful in case var was already removed from the constraint
- lmm_update_modified_set(sys, var->cnsts[0].constraint); // will look up element_set of this constraint, and then each var in the element_set, and each var->cnsts[i].
-
- if(xbt_swag_remove(elem, &(elem->constraint->element_set)) && var->weight>0)
- lmm_decrease_concurrency(elem->constraint);
-
- xbt_swag_remove(elem, &(elem->constraint->active_element_set));
- elem->constraint = NULL;
- elem->variable = NULL;
- elem->value = 0;
-
- var->cnsts_number -= 1;
-
- //No variable in this constraint -> make it inactive
- if (xbt_swag_size(&(cnst->element_set)) == 0)
- make_constraint_inactive(sys, cnst);
- else {
- //Check maxconcurrency to see if we can enable new variables
- lmm_on_disabled_var(sys,elem->constraint);
- }
-
- lmm_check_concurrency(sys);
-}
-
-void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst,
- lmm_variable_t var, double value)
-{
- lmm_element_t elem = NULL;
- double weight;
- int i;
-
- sys->modified = 1;
-
- if(var->weight>0 && lmm_concurrency_slack(cnst)==0){
- weight=var->weight;
- lmm_disable_var(sys,var);
- for (i = 0; i < var->cnsts_number; i++)
- lmm_on_disabled_var(sys,var->cnsts[i].constraint);
- value=0;
+ //Check if we need to disable the variable
+ if (var->sharing_weight > 0 && var->concurrency_share - current_share > cnst->get_concurrency_slack()) {
+ double weight = var->sharing_weight;
+ disable_var(var);
+ for (s_lmm_element_t const& elem : var->cnsts)
+ on_disabled_var(elem.constraint);
+ consumption_weight = 0;