fix: default ftINIT MILP solving to single-threaded Gurobi#615
Merged
Conversation
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
6b7fb1d to
2d4b405
Compare
|
@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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #607.
ftINITcan 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)inoptimizeProb.m). In a normal serialftINITrungetCurrentTaskis empty, so Gurobi defaults to all cores — the failing condition.Changes
INIT/ftINIT.m— defaultThreads = 1for the per-step reconstruction MILP, set in the existing param-defaulting block (overridable via the step'sMILPParams).INIT/ftINITFillGapsMILP.m— same default for the gap-filling MILP.INIT/INITStepDesc.m— document the new default/override on theMILPParamsproperty.The default is overridable: set
Threadsin a step'sMILPParams(e.g.0= all cores) and it is respected (user params applied last viastructUpdate). It is solver-safe:glpkis blocked for MILP,scipignoresparams, andcobraonly acts onThreadswith a Gurobi backend. The existinggetCurrentTasksafeguard is retained — it also covers non-ftINIT parallel solves such asrandomSampling.Testing
checkcodeclean on all three files.tinitTestsran locally, but the ftINIT MILP test (testftINIT_T0001) was skipped on the dev machine (no Gurobi/SCIP installed); CI (with Gurobi) exercises it.vascularSmoothMuscleCells/pericytenow reconstruct with default settings (no manualThreadsedit)?