ICB-DCM / pyPESTO

python Parameter EStimation TOolbox
https://pypesto.readthedocs.io
BSD 3-Clause "New" or "Revised" License
206 stars 44 forks source link

Aggregated Objective does not return expected outputs using `return_dict` #1410

Open arrjon opened 1 month ago

arrjon commented 1 month ago

Bug description The functions available in pypesto.visualize.model_fit cannot work with an AggregatedObjective and hence fail. There are two reasons:

Expected behavior The visuslization routines should still work properly. Also I would expect pypesto_problem.objective(x, return_dict=True) to return non empty rdatas. Calling pypesto_problem.objective._objectives[0](x, return_dict=True) instead works and does return non empty rdatas.

To reproduce I attached a minimal example using the Blasi model and PeTab. minimal example.zip

Environment

arrjon commented 1 month ago

maybe @dweindl can help here?

dweindl commented 4 weeks ago

maybe @dweindl can help here?

I am not too familiar with either AggregatedObjective or pypesto.visualize.model_fit, but I agree that it should either work, or raise an informative error.

the amici model is not available by objective.amici_model

That makes sense, because often AggregatedObjective won't have only a single model (https://github.com/ICB-DCM/pyPESTO/issues/439).

(I already fixed that issue in the branch visualize_aggregated by adding a new property to the AggregatedObjective)

I would rather handle AggregatedObjective separately in the visualization code instead of adding amici_model to AggregatedObjective, since there will probably be multiple models.

arrjon commented 4 weeks ago

I would rather handle AggregatedObjective separately in the visualization code instead of adding amici_model to AggregatedObjective, since there will probably be multiple models.

Okay, I thought that AggregatedObjective is usually an AmiciObjective and NegLogPriors and not multiple models. This makes it rather complicated to write a general visualization function.

dweindl commented 4 weeks ago

I don't know how it's currently used, but one of the goals would be using it with PEtab problems comprising multiple models (https://github.com/ICB-DCM/pyPESTO/issues/439) and I wouldn't add anything that will complicate this.

I think it's nevertheless possible to provide some meaningful visualizations. Just iterate over the objectives and visualize what's possible and give a warning if any of those cannot be handled.