+
+#ifdef HAVE_LATENCY_BOUND_TRACKING
+XBT_INLINE int lmm_is_variable_limited_by_latency(lmm_variable_t var)
+{
+ return (double_equals(var->bound, var->value));
+}
+#endif
+
+
+/** \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_rec(lmm_system_t sys,
+ lmm_constraint_t cnst)
+{
+ lmm_element_t elem;
+
+ xbt_swag_foreach(elem, &cnst->element_set) {
+ lmm_variable_t var = elem->variable;
+ s_lmm_element_t *cnsts = var->cnsts;
+ int i;
+ for (i = 0; var->visited != sys->visited_counter
+ && i < var->cnsts_number ; i++) {
+ if (cnsts[i].constraint != cnst
+ && !xbt_swag_belongs(cnsts[i].constraint,
+ &sys->modified_constraint_set)) {
+ xbt_swag_insert(cnsts[i].constraint, &sys->modified_constraint_set);
+ lmm_update_modified_set_rec(sys, cnsts[i].constraint);
+ }
+ }
+ var->visited = sys->visited_counter;
+ }
+}
+
+static void lmm_update_modified_set(lmm_system_t sys,
+ lmm_constraint_t cnst)
+{
+ /* nothing to do if selective update isn't active */
+ if (sys->selective_update_active
+ && !xbt_swag_belongs(cnst, &sys->modified_constraint_set)) {
+ xbt_swag_insert(cnst, &sys->modified_constraint_set);
+ lmm_update_modified_set_rec(sys, cnst);
+ }
+}
+
+/** \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)
+{
+ if (++sys->visited_counter == 1) {
+ /* the counter wrapped around, reset each variable->visited */
+ lmm_variable_t var;
+ xbt_swag_foreach(var, &sys->variable_set)
+ var->visited = 0;
+ }
+ xbt_swag_reset(&sys->modified_constraint_set);
+}