CovertLab / wcEcoli

Whole Cell Model of E. coli
Other
18 stars 4 forks source link

Sometimes the simulation prints "Warning: numerical instability (primal simplex, phase II)" #165

Open 1fish2 opened 6 years ago

1fish2 commented 6 years ago

These "numerical instability" warnings only seem to occur in a few early time steps. Why do they happen? Why is it inconsistent? How to fix it?

Time (s)  Dry mass     Dry mass      Protein          RNA    Small mol     Expected
              (fg)  fold change  fold change  fold change  fold change  fold change
========  ========  ===========  ===========  ===========  ===========  ===========
    0.00    402.97        1.000        1.000        1.000        1.000        1.000
    0.20    403.07        1.000        1.000        1.000        1.000        1.000
    0.40    403.14        1.000        1.000        1.000        1.001        1.000
    0.60    403.18        1.001        1.000        1.000        1.001        1.000
    0.80    403.22        1.001        1.000        1.000        1.001        1.000
    1.00    403.34        1.001        1.000        1.000        1.002        1.000
    1.89    403.59        1.002        1.001        1.001        1.003        1.000
Warning: numerical instability (primal simplex, phase II)
    2.79    403.66        1.002        1.001        1.001        1.003        1.001
    3.68    403.90        1.002        1.001        1.001        1.004        1.001
Warning: numerical instability (primal simplex, phase II)
    4.57    403.95        1.002        1.001        1.001        1.004        1.001
jmason42 commented 6 years ago

I'm not sure if it's really an issue, or, further, whether it can be fixed. Part of the issue is that the constraint matrix is ill-conditioned - can't change that too much, although some minor rescaling is possible. Second, I think the kinetics violation penalties are so small that some are probably underflowing, which the solver might see as numerical instability. I don't know whether the solver is running 32-bit or 64-bit floats but I suspect it's the former, which probably aggravates the problem. Finally, the first few timesteps are a mess due to initialization challenges. During this period, metabolism is behaving unusually while it tries to settle out. The homeostatic objective and partitioning add complexities that make it difficult to properly initialize.

There are other types of solvers that might work better. At the moment I don't think it's really broken, but identifying what causes the instability could be illuminating.

ggsun commented 6 years ago

This might be an issue we need to address - running the simulation with seed values 54, 86, 102, 122, 129, 187, 190 currently results in an (almost?) infinite loop of numerical instability warnings after 4-5 timesteps of the first generation. For seed values 154 and 211, the same thing happens at the fourth and seventh generation, respectively.

Time (s)  Dry mass     Dry mass      Protein          RNA    Small mol     Expected
              (fg)  fold change  fold change  fold change  fold change  fold change
========  ========  ===========  ===========  ===========  ===========  ===========
    0.00    374.83        1.000        1.000        1.000        1.000        1.000
    0.20    374.93        1.000        1.000        1.000        1.001        1.000
    0.40    374.99        1.000        1.000        1.000        1.001        1.000
Warning: numerical instability (primal simplex, phase II)
    0.60    375.04        1.001        1.000        1.000        1.001        1.000
    0.80    375.09        1.001        1.000        1.000        1.001        1.000
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)
Warning: numerical instability (primal simplex, phase II)