+/** \brief Update the constraint set propagating recursively to
+ * other constraints so the system should not be entirely computed.
+ *
+ * \param sys the lmm_system_t
+ * \param cnst the lmm_constraint_t affected by the change
+ *
+ * A recursive algorithm to optimize the system recalculation selecting only
+ * constraints that have changed. Each constraint change is propagated
+ * to the list of constraints for each variable.
+ */
+static void lmm_update_modified_set(lmm_system_t sys, lmm_constraint_t cnst)
+{
+ lmm_element_t elem = NULL;
+ lmm_variable_t var = NULL;
+ xbt_swag_t elem_list = NULL;
+ int i;
+
+ /* return if selective update isn't active */
+ if (!sys->selective_update_active)
+ return;
+
+ //DEBUG1("Updating modified constraint set with constraint %d", cnst->id_int);
+
+ if (xbt_swag_belongs(cnst, &(sys->modified_constraint_set)))
+ return;
+
+ //DEBUG1("Inserting into modified constraint set %d", cnst->id_int);
+
+ /* add to modified set */
+ xbt_swag_insert(cnst, &(sys->modified_constraint_set));
+
+ elem_list = &(cnst->element_set);
+ xbt_swag_foreach(elem, elem_list) {
+ var = elem->variable;
+ for (i = 0; i < var->cnsts_number; i++)
+ if (cnst != var->cnsts[i].constraint) {
+ //DEBUG2("Updating modified %d calling for %d", cnst->id_int, var->cnsts[i].constraint->id_int);
+ lmm_update_modified_set(sys, var->cnsts[i].constraint);
+ }
+ }
+}
+
+/** \brief Remove all constraints of the modified_constraint_set.
+ *
+ * \param sys the lmm_system_t
+ */
+static void lmm_remove_all_modified_set(lmm_system_t sys)
+{
+ lmm_element_t elem = NULL;
+ lmm_element_t elem_next = NULL;
+ xbt_swag_t elem_list = NULL;
+
+ elem_list = &(sys->modified_constraint_set);
+ xbt_swag_foreach_safe(elem, elem_next, elem_list) {
+ xbt_swag_remove(elem, elem_list);
+ }
+}