AMICI-dev / AMICI

Advanced Multilanguage Interface to CVODES and IDAS
https://amici.readthedocs.io/
Other
108 stars 30 forks source link

how to set number of setMaxSteps in Lotka Volterra model? #1535

Closed harshitaojha closed 3 years ago

harshitaojha commented 3 years ago

What's setMaxSteps value by default? What value I should set it to? Also could you please tell how do I mention itif possible? I encountered the following error and need some help. [Warning] AMICI:simulation: AMICI forward simulation failed at t = 0.926795: AMICI failed to integrate the forward problem

dweindl commented 3 years ago

What's setMaxSteps value by default?

You can check that via https://amici.readthedocs.io/en/latest/generated/amici.amici.Solver.html#amici.amici.Solver.getMaxSteps

What value I should set it to? Also could you please tell how do I mention itif possible? I encountered the following error and need some help. [Warning] AMICI:simulation: AMICI forward simulation failed at t = 0.926795: AMICI failed to integrate the forward problem

The choice depends on your model (parameters) and the chosen integration tolerances (see respective getters/setters in https://amici.readthedocs.io/en/latest/generated/amici.amici.Solver.html#amici.amici.Solver). You can increase the maximum number of steps by a factor of 10 and see if it's enough for your problem. Alternatively you can relax the integration tolerances.

yannikschaelte commented 3 years ago

For the impact of integration tolerances (solver.setRelativeTolerance(tol) and solver.setAbsoluteTolerance(tol)) see also https://www.nature.com/articles/s41598-021-82196-2, usually values between 1e-8 and 1e-14 are fine.

harshitaojha commented 3 years ago

Thanks. My query was where I can see the setMaxSteps in my code to change it manually?Or how I can pass the setMaxSteps parameter value in my code? I saw the example where they assign it like solver.setMaxSteps(some_number), but I only see importer and problem variables in LV code. The step at it is giving the above warning is: result_dlib = optimize.minimize(problem=problem, optimizer=optimizer_dlib, engine=engine, history_options=history_options, n_starts=n_starts)

FFroehlich commented 3 years ago

Thanks. My query was where I can see the setMaxSteps in my code to change it manually?Or how I can pass the setMaxSteps parameter value in my code? I saw the example where they assign it like solver.setMaxSteps(some_number), but I only see importer and problem variables in LV code. The step at it is giving the above warning is: result_dlib = optimize.minimize(problem=problem, optimizer=optimizer_dlib, engine=engine, history_options=history_options, n_starts=n_starts)

The setMaxSteps function as well as other options needs to be applied to the objective solver object problem.objective.amici_solver, i.e, problem.objective.amici_solver.setMaxSteps(...). In cases where there are also parameter priors, this becomes a bit more complicated.

harshitaojha commented 3 years ago

Thanks. I think I just figured out how to prevent code to stop now. I defined a parameter called maxiter in optimizer, and decreased down the n_starts value = 10. E.g. optimizer_scipy_powell = optimize.ScipyOptimizer(method='Powell',options={'maxiter': 100}) optimizer_dlib = optimize.DlibOptimizer(options={'maxiter': 100})