+ xbt_swag_insert_at_tail(elem, &(elem->constraint->element_set));
+
+ xbt_swag_remove(elem, &(elem->constraint->active_element_set));
+
+ lmm_decrease_concurrency(elem->constraint);
+ }
+
+ var->weight=0.0;
+ var->staged_weight=0.0;
+ var->value = 0.0;
+ lmm_check_concurrency(sys);
+}
+
+/* /brief Find variables that can be enabled and enable them.
+ *
+ * Assuming that the variable has already been removed from non-zero weights
+ * Can we find a staged variable to add?
+ * If yes, check that none of the constraints that this variable is involved in is at the limit of its concurrency
+ * And then add it to active variables
+ */
+void lmm_on_disabled_var(lmm_system_t sys, lmm_constraint_t cnstr){
+
+ lmm_element_t elem;
+ if(cnstr->concurrency_limit<0)
+ return;
+
+ int concurrency=0;
+ xbt_swag_foreach(elem, &(cnstr->element_set)) {
+
+ //active variables are checked to see if we already reached the maximum (SHOULD NOT HAPPEN BECAUSE WE SHOULD HAVE JUST DEACTIVATED ONE)
+ if (elem->variable->weight > 0){
+ concurrency++;
+ xbt_assert(elem->variable->staged_weight==0.0,"Staged weight should have been reset");
+ } else if (elem->variable->staged_weight>0 )
+ {
+ //Found a staged variable
+ //TODOLATER: Add random timing function to model reservation protocol fuzziness? Then how to make sure that staged variables will eventually be called?
+ if(lmm_can_enable_var(elem->variable)){
+ lmm_enable_var(sys,elem->variable);
+ concurrency++;
+ }
+ }
+
+ xbt_assert(concurrency<=cnstr->concurrency_limit,"Concurrency overflow!");
+ if(concurrency==cnstr->concurrency_limit)
+ break;
+ }
+
+ lmm_check_concurrency(sys);
+
+}
+
+/* \brief update the weight of a variable, and enable/disable it.
+ * @return Returns whether a change was made
+ */
+void lmm_update_variable_weight(lmm_system_t sys, lmm_variable_t var,
+ double weight)
+{
+ int minslack;
+
+ xbt_assert(weight>=0,"Variable weight should not be negative!");
+
+ if (weight == var->weight)
+ return;