sys-bio / roadrunner

libRoadRunner: A high-performance SBML simulator
http://libroadrunner.org/
Other
39 stars 25 forks source link

Setting tolerance for newton steady-state doesn't seem to do anything #801

Open hsauro opened 3 years ago

hsauro commented 3 years ago

Consider:

import tellurium as te

r = te.loada(""" J1: $Xo -> S1; Vm1/Km10(Xo-S1/Keq1)/(1 + Xo/Km10 + S1/Km11); J2: S1 -> S2; Vm2/Km20(S1-S2/Keq2)/(1 + S1/Km20 + S2/Km21); J3: S2 -> $X1; Vm3/Km30*(S2-X1/Keq3)/(1 + S2/Km30 + X1/Km31);

Vm1 = 5.36; Vm2 = 7.72; Vm3 = 2.40 Km10 = 6.67; Km11 = 4.51; Km20 = 4.70 Km21 = 6.53; Km30 = 3.25; Km31 = 5.02 Keq1 = 8.42; Keq2 = 9.70; Keq3 = 2.38 Xo = 1.00; X1 = 0; S1 = 0; S2 = 0; """)

r.setSteadyStateSolver('nleq1') result = r.steadyState() print (result)

r.reset() r.setSteadyStateSolver('newton') x = r.getSteadyStateSolver() x.approx_tolerance = 1E-6 result = r.steadyState() print (result)

r.reset() r.setSteadyStateSolver('newton') x = r.getSteadyStateSolver() x.approx_tolerance = 1E-19 result = r.steadyState() print (result)

1.1102230246251565e-16 2.7592038930278455e-10 2.7592038930278455e-10

Setting the tolerance makes no difference (note also newton gives a slightly less accurate solution presumably because of the tolerance setting)

CiaranWelsh commented 3 years ago

The two settings you want are func_norm_tol and scaled_step_tol, as per #800 here. Take a look at the docs for kinsol, specifically, look for the section called Nonlinear iteration stopping criteria under mathematical considerations.