+lmm_system_t lmm_system_new(bool selective_update)
+{
+ s_lmm_variable_t var;
+ s_lmm_constraint_t cnst;
+
+ lmm_system_t l = xbt_new0(s_lmm_system_t, 1);
+
+ l->modified = 0;
+ l->selective_update_active = selective_update;
+ l->visited_counter = 1;
+
+ XBT_DEBUG("Setting selective_update_active flag to %d", l->selective_update_active);
+
+ xbt_swag_init(&(l->variable_set), xbt_swag_offset(var, variable_set_hookup));
+ xbt_swag_init(&(l->constraint_set), xbt_swag_offset(cnst, constraint_set_hookup));
+
+ xbt_swag_init(&(l->active_constraint_set), xbt_swag_offset(cnst, active_constraint_set_hookup));
+
+ xbt_swag_init(&(l->modified_constraint_set), xbt_swag_offset(cnst, modified_constraint_set_hookup));
+ xbt_swag_init(&(l->saturated_variable_set), xbt_swag_offset(var, saturated_variable_set_hookup));
+ xbt_swag_init(&(l->saturated_constraint_set), xbt_swag_offset(cnst, saturated_constraint_set_hookup));
+
+ l->variable_mallocator = xbt_mallocator_new(65536,
+ lmm_variable_mallocator_new_f,
+ lmm_variable_mallocator_free_f,
+ lmm_variable_mallocator_reset_f);
+
+ l->solve_fun = &lmm_solve;
+
+ return l;
+}
+
+void lmm_system_free(lmm_system_t sys)
+{
+ lmm_variable_t var = nullptr;
+ lmm_constraint_t cnst = nullptr;
+
+ if (sys == nullptr)
+ return;
+
+ while ((var = (lmm_variable_t) extract_variable(sys))) {
+ int status;
+ char* demangled = abi::__cxa_demangle(typeid(*var->id).name(), 0, 0, &status);
+
+ XBT_WARN("Probable bug: a %s variable (#%d) not removed before the LMM system destruction.", demangled,
+ var->id_int);
+ xbt_free(demangled);
+ lmm_var_free(sys, var);
+ }
+ while ((cnst = (lmm_constraint_t) extract_constraint(sys)))
+ lmm_cnst_free(sys, cnst);
+
+ xbt_mallocator_free(sys->variable_mallocator);
+ free(sys);
+}
+
+static inline void lmm_cnst_free(lmm_system_t sys, lmm_constraint_t cnst)