Skip to content

fix: default ftINIT MILP solving to single-threaded Gurobi#615

Merged
edkerk merged 1 commit into
developfrom
fix/ftinit-single-thread-milp
Jun 8, 2026
Merged

fix: default ftINIT MILP solving to single-threaded Gurobi#615
edkerk merged 1 commit into
developfrom
fix/ftinit-single-thread-milp

Conversation

@edkerk

@edkerk edkerk commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #607. ftINIT can fail with "Model is infeasible" / "Failed to find good enough solution within the time frame. MIPGap: Inf" for some cell types (e.g. vascularSmoothMuscleCells, pericyte) when building context-specific models from Human-GEM v2.0.0, while the same pipeline succeeds with v1.19.0.

As diagnosed by @mfcesur in #607, the cause is multi-threaded Gurobi solving the ftINIT MILP non-deterministically and spuriously returning infeasible. Forcing single-thread (Threads = 1) makes all cell types reconstruct, and is the more robust setting across Gurobi versions.

RAVEN already forces single-thread Gurobi, but only inside parallel workers (if ~isempty(getCurrentTask) in optimizeProb.m). In a normal serial ftINIT run getCurrentTask is empty, so Gurobi defaults to all cores — the failing condition.

Changes

  • INIT/ftINIT.m — default Threads = 1 for the per-step reconstruction MILP, set in the existing param-defaulting block (overridable via the step's MILPParams).
  • INIT/ftINITFillGapsMILP.m — same default for the gap-filling MILP.
  • INIT/INITStepDesc.m — document the new default/override on the MILPParams property.

The default is overridable: set Threads in a step's MILPParams (e.g. 0 = all cores) and it is respected (user params applied last via structUpdate). It is solver-safe: glpk is blocked for MILP, scip ignores params, and cobra only acts on Threads with a Gurobi backend. The existing getCurrentTask safeguard is retained — it also covers non-ftINIT parallel solves such as randomSampling.

Testing

  • checkcode clean on all three files.
  • tinitTests ran locally, but the ftINIT MILP test (testftINIT_T0001) was skipped on the dev machine (no Gurobi/SCIP installed); CI (with Gurobi) exercises it.
  • @mfcesur — could you confirm vascularSmoothMuscleCells/pericyte now reconstruct with default settings (no manual Threads edit)?

Multi-threaded Gurobi can non-deterministically report the ftINIT MILP as
infeasible, causing reconstruction to fail for some cell types (e.g.
vascularSmoothMuscleCells, pericyte) with Human-GEM v2.0.0 while succeeding
with v1.19.0. The existing single-thread safeguard in optimizeProb only
applies inside parallel workers (getCurrentTask), not in serial runs.

Default Threads=1 for the ftINIT MILP (overridable via the step MILPParams)
in both the main reconstruction loop (ftINIT.m) and the gap-filling MILP
(ftINITFillGapsMILP.m).

Resolves #607
@edkerk edkerk force-pushed the fix/ftinit-single-thread-milp branch from 6b7fb1d to 2d4b405 Compare June 8, 2026 08:57
@mfcesur

mfcesur commented Jun 8, 2026

Copy link
Copy Markdown

@edkerk, I tested the updated code and confirm that the issue is resolved on my side. I reran the reconstruction with the default settings (no manual Threads modification) for both problematic cell types and the Gurobi version/threshold combinations that previously failed.

With the new default single-threaded MILP setting introduced in this PR, both cell-type models were reconstructed successfully.

Thank you very much for the fix.

@edkerk edkerk merged commit 437c59a into develop Jun 8, 2026
1 check failed
@edkerk edkerk deleted the fix/ftinit-single-thread-milp branch June 8, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants