+
+ //We could get an assertion fail, because transiently there can be variables that are staged and could be activated.
+ //And we need to go through all constraints of the disabled var before getting back a coherent state.
+ //Anyway, caller functions all call lmm_check_concurrency() in the end.
+ // 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)
+{
+
+ xbt_assert(weight>=0,"Variable weight should not be negative!");
+
+ if (weight == var->weight)
+ return;
+
+ int enabling_var= (weight>0 && var->weight<=0);
+ int disabling_var= (weight<=0 && var->weight>0);
+
+ XBT_IN("(sys=%p, var=%p, weight=%f)", sys, var, weight);
+
+ sys->modified = 1;
+
+ //Are we enabling this variable?
+ if (enabling_var){
+ var->staged_weight = weight;
+ int minslack = lmm_cnstrs_min_concurrency_slack(var);
+ if (minslack < var->concurrency_share) {
+ XBT_DEBUG("Staging var (instead of enabling) because min concurrency slack %i, with weight %f and concurrency"
+ " share %i", minslack, weight, var->concurrency_share);
+ return;
+ }
+ XBT_DEBUG("Enabling var with min concurrency slack %i", minslack);
+ lmm_enable_var(sys,var);
+ } else if (disabling_var){
+ //Are we disabling this variable?
+ lmm_disable_var(sys,var);
+ } else {
+ var->weight=weight;
+ }
+
+ lmm_check_concurrency(sys);