pyPESTO icon indicating copy to clipboard operation
pyPESTO copied to clipboard

Hierarchical optimization: avoid extra simulations

Open dweindl opened this issue 3 years ago • 4 comments

When using hierarchical optimization, there are currently two simulations performed during each objective evaluations. This could be avoided if the gradient is not required and could significantly improve performance.

See here: https://github.com/ICB-DCM/pyPESTO/blob/cfd673d070d7e9feb8338e64855fd8f340c219cd/pypesto/hierarchical/calculator.py#L139-L141

Ideally after https://github.com/AMICI-dev/AMICI/issues/2215

dweindl avatar Nov 15 '22 15:11 dweindl

Will look into and update

Doresic avatar Dec 04 '23 14:12 Doresic

@Doresic : This is finished, right?

dweindl avatar Apr 19 '24 09:04 dweindl

Yes, mostly done. That's the calculate_directly call of the RelativeCalculator.

Amici is still called twice through call_amici_twice in some special cases. One of those is also if 2 is in sensi_orders. This is a part that can be further optimized. As far as I know, amici doesn't really calculate 2nd order sensitivities but uses FIM or some BFGS-type of approximation. This is something that could be implemented in the calculate_directly call as well. In that case, one would not have to call amici twice even when requesting 2nd order derivatives.

One special case of calling with 2nd order sensitivities, but can already be used with calculate_directly, is optimization with fides. If one just uses pypesto.optimizer.FidesOptimizer() then it will be used with call_amici_twice as fides always calls for second order sensitivities which are then returned by amici as some approximation. However, one can instead select pypesto.optimizer.FidesOptimizer(hessian_update = fides.BFGS) which will make fides calculate 2nd order approximations itself, so it will not request them from the objective. Then, the model will not be simulated twice and calcualte_directly will be used.

TLDR: can be closed, but can also be slightly improved.

Doresic avatar Apr 19 '24 09:04 Doresic

Ah, right. Thanks for the update.

dweindl avatar Apr 19 '24 09:04 dweindl