return (cnst->sharing_policy);
}
-/* @brief Remove a constraint
+/* @brief Remove a constraint
* Currently this is dead code, but it is exposed in maxmin.h
- * Apparently, this call was designed assuming that constraint would no more have elements in it.
+ * Apparently, this call was designed assuming that constraint would no more have elements in it.
* If not the case, assertion will fail, and you need to add calls e.g. to lmm_shrink before effectively removing it.
*/
inline void lmm_constraint_free(lmm_system_t sys,lmm_constraint_t cnst)
make_constraint_inactive(sys, cnst);
else {
//Check maxconcurrency to see if we can enable new variables
- lmm_on_disabled_var(sys,elem->constraint);
+ lmm_on_disabled_var(sys,elem->constraint);
}
lmm_check_concurrency(sys);
}
}
- //Check if we need to disable the variable
+ //Check if we need to disable the variable
if(var->weight>0 && var->concurrency_share-current_share>lmm_concurrency_slack(cnst)) {
double weight = var->weight;
lmm_disable_var(sys,var);
if (*elem == nullptr)
*elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->disabled_element_set));
} else {
- *elem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->disabled_element_set.offset);
+ *elem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->disabled_element_set.offset);
}
}
if (*elem)
if (*nextelem == nullptr)
*nextelem = (lmm_element_t) xbt_swag_getFirst(&(cnst->disabled_element_set));
} else {
- *nextelem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->disabled_element_set.offset);
+ *nextelem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->disabled_element_set.offset);
}
return (*elem)->variable;
}else
static inline void saturated_variable_set_update(s_lmm_constraint_light_t *cnst_light_tab,
dyn_light_t saturated_constraint_set, lmm_system_t sys)
{
- /* Add active variables (i.e. variables that need to be set) from the set of constraints to saturate (cnst_light_tab)*/
+ /* Add active variables (i.e. variables that need to be set) from the set of constraints to saturate (cnst_light_tab)*/
lmm_constraint_light_t cnst = nullptr;
void *_elem;
lmm_element_t elem = nullptr;
std::to_string(elem->variable->value) + ")" + ((cnst->sharing_policy) ? " + " : " , ");
if(cnst->sharing_policy)
sum += elem->value * elem->variable->value;
- else
+ else
sum = MAX(sum,elem->value * elem->variable->value);
}
//TODO: Adding disabled elements only for test compatibility, but do we really want them to be printed?
std::to_string(elem->variable->value) + ")" + ((cnst->sharing_policy) ? " + " : " , ");
if(cnst->sharing_policy)
sum += elem->value * elem->variable->value;
- else
+ else
sum = MAX(sum,elem->value * elem->variable->value);
}
}
/** \brief Attribute the value bound to var->bound.
- *
+ *
* \param sys the lmm_system_t
* \param var the lmm_variable_t
* \param bound the new bound to associate with var
- *
+ *
* Makes var->bound equal to bound. Whenever this function is called a change is signed in the system. To
* avoid false system changing detection it is a good idea to test (bound != 0) before calling it.
*/
if(cnstr->concurrency_limit<0)
return 666;
- return cnstr->concurrency_limit - cnstr->concurrency_current;
+ return cnstr->concurrency_limit - cnstr->concurrency_current;
}
/** \brief Measure the minimum concurrency slack across all constraints where the given var is involved */
/* /Check if a variable can be enabled
*
- * Make sure to set staged_weight before, if your intent is only to check concurrency
+ * Make sure to set staged_weight before, if your intent is only to check concurrency
*/
int lmm_can_enable_var(lmm_variable_t var){
return var->staged_weight>0 && lmm_cnstrs_min_concurrency_slack(var)>=var->concurrency_share;
//When used within lmm_on_disabled_var, we would get an assertion fail, because transiently there can be variables
// that are staged and could be activated.
- //Anyway, caller functions all call lmm_check_concurrency() in the end.
+ //Anyway, caller functions all call lmm_check_concurrency() in the end.
// lmm_check_concurrency(sys);
}
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
//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.
+ //Anyway, caller functions all call lmm_check_concurrency() in the end.
// lmm_check_concurrency(sys);
}
lmm_update_modified_set_rec(sys, cnsts[i].constraint);
}
}
- //var will be ignored in later visits as long as sys->visited_counter does not move
+ //var will be ignored in later visits as long as sys->visited_counter does not move
var->visited = sys->visited_counter;
}
}
void *_var;
xbt_swag_foreach(_var, &sys->variable_set)
((lmm_variable_t)_var)->visited = 0;
- }
+ }
xbt_swag_reset(&sys->modified_constraint_set);
}
}
return usage;
}
+int lmm_constraint_get_variable_amount(lmm_constraint_t cnst) {
+ int usage = 0;
+ xbt_swag_t elem_list = &(cnst->enabled_element_set);
+ void *_elem;
+
+ xbt_swag_foreach(_elem, elem_list) {
+ lmm_element_t elem = (lmm_element_t)_elem;
+ if (elem->value > 0)
+ usage++;
+ }
+ return usage;
+}
void lmm_check_concurrency(lmm_system_t sys){
//These checks are very expensive, so do them only if we want to debug SURF LMM