The purpose of this guide is to showcase how AMICI can be combined with differentiable programming in JAX. We will do so by reimplementing the parameter transformations available in AMICI in JAX and comparing it to the native implementation.

[1]:
import jax
import jax.numpy as jnp

Preparation

To get started we will import a model using the petab. To this end, we will use the benchmark collection, which features a variety of different models. For more details about petab import, see the respective notebook petab notebook.

[2]:
!git clone --depth 1 https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab.git tmp/benchmark-models || (cd tmp/benchmark-models && git pull)
from pathlib import Path
folder_base = Path('.') / "tmp" / "benchmark-models" / "Benchmark-Models"
Cloning into 'tmp/benchmark-models'...
remote: Enumerating objects: 336, done.
remote: Counting objects: 100% (336/336), done.
remote: Compressing objects: 100% (285/285), done.
remote: Total 336 (delta 88), reused 216 (delta 39), pack-reused 0
Receiving objects: 100% (336/336), 2.11 MiB | 7.48 MiB/s, done.
Resolving deltas: 100% (88/88), done.

From the benchmark collection, we now import the Boehm model.

[3]:
import petab
model_name = "Boehm_JProteomeRes2014"
yaml_file = folder_base / model_name / (model_name + ".yaml")
petab_problem = petab.Problem.from_yaml(yaml_file)

The petab problem includes information about parameter scaling in it’s the parameter table. For the boehm model, all estimated parameters (petab.ESTIMATE column equal to 1) have a petab.LOG10 as parameter scaling.

[4]:
petab_problem.parameter_df
[4]:
parameterName parameterScale lowerBound upperBound nominalValue estimate
parameterId
Epo_degradation_BaF3 EPO_{degradation,BaF3} log10 0.00001 100000 0.026983 1
k_exp_hetero k_{exp,hetero} log10 0.00001 100000 0.000010 1
k_exp_homo k_{exp,homo} log10 0.00001 100000 0.006170 1
k_imp_hetero k_{imp,hetero} log10 0.00001 100000 0.016368 1
k_imp_homo k_{imp,homo} log10 0.00001 100000 97749.379402 1
k_phos k_{phos} log10 0.00001 100000 15766.507020 1
ratio ratio lin -5.00000 5 0.693000 0
sd_pSTAT5A_rel \sigma_{pSTAT5A,rel} log10 0.00001 100000 3.852612 1
sd_pSTAT5B_rel \sigma_{pSTAT5B,rel} log10 0.00001 100000 6.591478 1
sd_rSTAT5A_rel \sigma_{rSTAT5A,rel} log10 0.00001 100000 3.152713 1
specC17 specC17 lin -5.00000 5 0.107000 0

We now import the petab problem using `amici.petab_import <https://amici.readthedocs.io/en/latest/generated/amici.petab_import.html#amici.petab_import.import_petab_problem>`__.

[5]:
from amici.petab_import import import_petab_problem
amici_model = import_petab_problem(petab_problem, force_compile=True)
2023-02-16 12:37:18.049 - amici.petab_import - INFO - Importing model ...
2023-02-16 12:37:18.050 - amici.petab_import - INFO - Validating PEtab problem ...
2023-02-16 12:37:18.343 - amici.petab_import - INFO - Model name is 'Boehm_JProteomeRes2014'.
Writing model code to '/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014'.
2023-02-16 12:37:18.344 - amici.petab_import - INFO - Species: 8
2023-02-16 12:37:18.344 - amici.petab_import - INFO - Global parameters: 9
2023-02-16 12:37:18.344 - amici.petab_import - INFO - Reactions: 9
2023-02-16 12:37:18.353 - amici.petab_import - INFO - Observables: 3
2023-02-16 12:37:18.353 - amici.petab_import - INFO - Sigmas: 3
2023-02-16 12:37:18.357 - amici.petab_import - DEBUG - Adding output parameters to model: ['noiseParameter1_pSTAT5A_rel', 'noiseParameter1_pSTAT5B_rel', 'noiseParameter1_rSTAT5A_rel']
2023-02-16 12:37:18.357 - amici.petab_import - DEBUG - Adding initial assignments for []
2023-02-16 12:37:18.363 - amici.petab_import - DEBUG - Condition table: (1, 1)
2023-02-16 12:37:18.364 - amici.petab_import - DEBUG - Fixed parameters are ['ratio', 'specC17']
2023-02-16 12:37:18.364 - amici.petab_import - INFO - Overall fixed parameters: 2
2023-02-16 12:37:18.364 - amici.petab_import - INFO - Variable parameters: 10
2023-02-16 12:37:18.398 - amici.sbml_import - DEBUG - Finished gathering local SBML symbols       ++ (1.08E-02s)
2023-02-16 12:37:18.403 - amici.sbml_import - DEBUG - Finished processing SBML parameters         ++ (2.27E-03s)
2023-02-16 12:37:18.405 - amici.sbml_import - DEBUG - Finished processing SBML compartments       ++ (1.18E-04s)
2023-02-16 12:37:18.411 - amici.sbml_import - DEBUG - Finished processing SBML species initials  +++ (2.19E-03s)
2023-02-16 12:37:18.413 - amici.sbml_import - DEBUG - Finished processing SBML rate rules        +++ (1.46E-05s)
2023-02-16 12:37:18.413 - amici.sbml_import - DEBUG - Finished processing SBML species            ++ (5.96E-03s)
2023-02-16 12:37:18.417 - amici.sbml_import - DEBUG - Finished processing SBML reactions          ++ (1.01E-03s)
2023-02-16 12:37:18.420 - amici.sbml_import - DEBUG - Finished processing SBML rules              ++ (1.15E-03s)
2023-02-16 12:37:18.422 - amici.sbml_import - DEBUG - Finished processing SBML initial assignments++ (4.30E-05s)
2023-02-16 12:37:18.424 - amici.sbml_import - DEBUG - Finished processing SBML species references ++ (1.96E-04s)
2023-02-16 12:37:18.426 - amici.sbml_import - DEBUG - Finished processing SBML events             ++ (3.40E-05s)
2023-02-16 12:37:18.426 - amici.sbml_import - DEBUG - Finished importing SBML                      + (4.08E-02s)
2023-02-16 12:37:18.457 - amici.sbml_import - DEBUG - Finished processing SBML observables         + (2.87E-02s)
2023-02-16 12:37:18.460 - amici.sbml_import - DEBUG - Finished processing SBML event observables   + (1.12E-06s)
2023-02-16 12:37:18.476 - amici.ode_export - DEBUG - Finished running smart_multiply              ++ (1.06E-03s)
2023-02-16 12:37:18.499 - amici.ode_export - DEBUG - Finished importing SbmlImporter               + (2.54E-02s)
2023-02-16 12:37:18.520 - amici.ode_export - DEBUG - Finished simplifying Jy                    ++++ (1.33E-02s)
2023-02-16 12:37:18.521 - amici.ode_export - DEBUG - Finished computing Jy                       +++ (1.53E-02s)
2023-02-16 12:37:18.549 - amici.ode_export - DEBUG - Finished simplifying y                     ++++ (2.28E-02s)
2023-02-16 12:37:18.549 - amici.ode_export - DEBUG - Finished computing y                        +++ (2.48E-02s)
2023-02-16 12:37:18.554 - amici.ode_export - DEBUG - Finished simplifying sigmay                ++++ (7.19E-05s)
2023-02-16 12:37:18.554 - amici.ode_export - DEBUG - Finished computing sigmay                   +++ (2.17E-03s)
2023-02-16 12:37:18.570 - amici.ode_export - DEBUG - Finished writing Jy.cpp                      ++ (6.58E-02s)
2023-02-16 12:37:18.592 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (1.63E-02s)
2023-02-16 12:37:18.601 - amici.ode_export - DEBUG - Finished simplifying dJydsigma             ++++ (5.78E-03s)
2023-02-16 12:37:18.601 - amici.ode_export - DEBUG - Finished computing dJydsigma                +++ (2.73E-02s)
2023-02-16 12:37:18.604 - amici.ode_export - DEBUG - Finished writing dJydsigma.cpp               ++ (3.18E-02s)
2023-02-16 12:37:18.619 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (9.30E-03s)
2023-02-16 12:37:18.630 - amici.ode_export - DEBUG - Finished simplifying dJydy                 ++++ (7.63E-03s)
2023-02-16 12:37:18.630 - amici.ode_export - DEBUG - Finished computing dJydy                    +++ (2.19E-02s)
2023-02-16 12:37:18.635 - amici.ode_export - DEBUG - Finished writing dJydy.cpp                   ++ (2.79E-02s)
2023-02-16 12:37:18.640 - amici.ode_export - DEBUG - Finished simplifying Jz                    ++++ (3.06E-05s)
2023-02-16 12:37:18.641 - amici.ode_export - DEBUG - Finished computing Jz                       +++ (1.71E-03s)
2023-02-16 12:37:18.643 - amici.ode_export - DEBUG - Finished computing z                        +++ (6.17E-05s)
2023-02-16 12:37:18.647 - amici.ode_export - DEBUG - Finished simplifying sigmaz                ++++ (2.92E-05s)
2023-02-16 12:37:18.647 - amici.ode_export - DEBUG - Finished computing sigmaz                   +++ (2.01E-03s)
2023-02-16 12:37:18.647 - amici.ode_export - DEBUG - Finished writing Jz.cpp                      ++ (9.91E-03s)
2023-02-16 12:37:18.653 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (2.68E-05s)
2023-02-16 12:37:18.655 - amici.ode_export - DEBUG - Finished simplifying dJzdsigma             ++++ (3.75E-05s)
2023-02-16 12:37:18.656 - amici.ode_export - DEBUG - Finished computing dJzdsigma                +++ (4.13E-03s)
2023-02-16 12:37:18.656 - amici.ode_export - DEBUG - Finished writing dJzdsigma.cpp               ++ (6.25E-03s)
2023-02-16 12:37:18.661 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (2.62E-05s)
2023-02-16 12:37:18.663 - amici.ode_export - DEBUG - Finished simplifying dJzdz                 ++++ (3.29E-05s)
2023-02-16 12:37:18.664 - amici.ode_export - DEBUG - Finished computing dJzdz                    +++ (3.72E-03s)
2023-02-16 12:37:18.664 - amici.ode_export - DEBUG - Finished writing dJzdz.cpp                   ++ (5.33E-03s)
2023-02-16 12:37:18.669 - amici.ode_export - DEBUG - Finished simplifying Jrz                   ++++ (3.16E-05s)
2023-02-16 12:37:18.670 - amici.ode_export - DEBUG - Finished computing Jrz                      +++ (1.69E-03s)
2023-02-16 12:37:18.672 - amici.ode_export - DEBUG - Finished computing rz                       +++ (5.45E-05s)
2023-02-16 12:37:18.672 - amici.ode_export - DEBUG - Finished writing Jrz.cpp                     ++ (5.46E-03s)
2023-02-16 12:37:18.677 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (2.60E-05s)
2023-02-16 12:37:18.679 - amici.ode_export - DEBUG - Finished simplifying dJrzdsigma            ++++ (3.63E-05s)
2023-02-16 12:37:18.679 - amici.ode_export - DEBUG - Finished computing dJrzdsigma               +++ (3.57E-03s)
2023-02-16 12:37:18.679 - amici.ode_export - DEBUG - Finished writing dJrzdsigma.cpp              ++ (5.15E-03s)
2023-02-16 12:37:18.684 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (2.39E-05s)
2023-02-16 12:37:18.686 - amici.ode_export - DEBUG - Finished simplifying dJrzdz                ++++ (3.45E-05s)
2023-02-16 12:37:18.687 - amici.ode_export - DEBUG - Finished computing dJrzdz                   +++ (3.68E-03s)
2023-02-16 12:37:18.687 - amici.ode_export - DEBUG - Finished writing dJrzdz.cpp                  ++ (5.31E-03s)
2023-02-16 12:37:18.692 - amici.ode_export - DEBUG - Finished simplifying root                  ++++ (3.28E-05s)
2023-02-16 12:37:18.693 - amici.ode_export - DEBUG - Finished computing root                     +++ (1.74E-03s)
2023-02-16 12:37:18.693 - amici.ode_export - DEBUG - Finished writing root.cpp                    ++ (3.46E-03s)
2023-02-16 12:37:18.707 - amici.ode_export - DEBUG - Finished simplifying w                    +++++ (7.04E-03s)
2023-02-16 12:37:18.707 - amici.ode_export - DEBUG - Finished computing w                       ++++ (8.93E-03s)
2023-02-16 12:37:18.719 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (9.60E-03s)
2023-02-16 12:37:18.726 - amici.ode_export - DEBUG - Finished simplifying dwdp                  ++++ (4.59E-03s)
2023-02-16 12:37:18.726 - amici.ode_export - DEBUG - Finished computing dwdp                     +++ (2.93E-02s)
2023-02-16 12:37:18.730 - amici.ode_export - DEBUG - Finished writing dwdp.cpp                    ++ (3.43E-02s)
2023-02-16 12:37:18.743 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (8.10E-03s)
2023-02-16 12:37:18.749 - amici.ode_export - DEBUG - Finished simplifying dwdx                  ++++ (3.24E-03s)
2023-02-16 12:37:18.749 - amici.ode_export - DEBUG - Finished computing dwdx                     +++ (1.54E-02s)
2023-02-16 12:37:18.753 - amici.ode_export - DEBUG - Finished writing dwdx.cpp                    ++ (2.02E-02s)
2023-02-16 12:37:18.762 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (3.16E-03s)
2023-02-16 12:37:18.767 - amici.ode_export - DEBUG - Finished simplifying dwdw                  ++++ (2.23E-03s)
2023-02-16 12:37:18.767 - amici.ode_export - DEBUG - Finished computing dwdw                     +++ (9.56E-03s)
2023-02-16 12:37:18.769 - amici.ode_export - DEBUG - Finished writing dwdw.cpp                    ++ (1.30E-02s)
2023-02-16 12:37:18.780 - amici.ode_export - DEBUG - Finished simplifying xdot                 +++++ (3.54E-03s)
2023-02-16 12:37:18.780 - amici.ode_export - DEBUG - Finished computing xdot                    ++++ (5.53E-03s)
2023-02-16 12:37:18.790 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (6.83E-03s)
2023-02-16 12:37:18.792 - amici.ode_export - DEBUG - Finished simplifying dxdotdw               ++++ (2.24E-04s)
2023-02-16 12:37:18.793 - amici.ode_export - DEBUG - Finished computing dxdotdw                  +++ (1.98E-02s)
2023-02-16 12:37:18.797 - amici.ode_export - DEBUG - Finished writing dxdotdw.cpp                 ++ (2.55E-02s)
2023-02-16 12:37:18.804 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (5.02E-04s)
2023-02-16 12:37:18.806 - amici.ode_export - DEBUG - Finished simplifying dxdotdx_explicit      ++++ (3.57E-05s)
2023-02-16 12:37:18.806 - amici.ode_export - DEBUG - Finished computing dxdotdx_explicit         +++ (4.47E-03s)
2023-02-16 12:37:18.806 - amici.ode_export - DEBUG - Finished writing dxdotdx_explicit.cpp        ++ (6.56E-03s)
2023-02-16 12:37:18.812 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (5.50E-04s)
2023-02-16 12:37:18.814 - amici.ode_export - DEBUG - Finished simplifying dxdotdp_explicit      ++++ (3.08E-05s)
2023-02-16 12:37:18.815 - amici.ode_export - DEBUG - Finished computing dxdotdp_explicit         +++ (4.37E-03s)
2023-02-16 12:37:18.815 - amici.ode_export - DEBUG - Finished writing dxdotdp_explicit.cpp        ++ (6.87E-03s)
2023-02-16 12:37:18.854 - amici.ode_export - DEBUG - Finished running smart_jacobian           +++++ (3.12E-02s)
2023-02-16 12:37:18.897 - amici.ode_export - DEBUG - Finished simplifying dydx                 +++++ (4.02E-02s)
2023-02-16 12:37:18.898 - amici.ode_export - DEBUG - Finished computing dydx                    ++++ (7.70E-02s)
2023-02-16 12:37:18.903 - amici.ode_export - DEBUG - Finished running smart_jacobian           +++++ (4.23E-04s)
2023-02-16 12:37:18.905 - amici.ode_export - DEBUG - Finished simplifying dydw                 +++++ (2.99E-05s)
2023-02-16 12:37:18.906 - amici.ode_export - DEBUG - Finished computing dydw                    ++++ (4.61E-03s)
2023-02-16 12:37:18.942 - amici.ode_export - DEBUG - Finished simplifying dydx                  ++++ (3.36E-02s)
2023-02-16 12:37:18.942 - amici.ode_export - DEBUG - Finished computing dydx                     +++ (1.23E-01s)
2023-02-16 12:37:18.958 - amici.ode_export - DEBUG - Finished writing dydx.cpp                    ++ (1.40E-01s)
2023-02-16 12:37:18.966 - amici.ode_export - DEBUG - Finished running smart_jacobian           +++++ (3.85E-04s)
2023-02-16 12:37:18.968 - amici.ode_export - DEBUG - Finished simplifying dydp                 +++++ (3.45E-05s)
2023-02-16 12:37:18.968 - amici.ode_export - DEBUG - Finished computing dydp                    ++++ (4.15E-03s)
2023-02-16 12:37:18.971 - amici.ode_export - DEBUG - Finished simplifying dydp                  ++++ (3.38E-05s)
2023-02-16 12:37:18.971 - amici.ode_export - DEBUG - Finished computing dydp                     +++ (8.39E-03s)
2023-02-16 12:37:18.971 - amici.ode_export - DEBUG - Finished writing dydp.cpp                    ++ (1.04E-02s)
2023-02-16 12:37:18.975 - amici.ode_export - DEBUG - Finished computing dzdx                     +++ (5.68E-05s)
2023-02-16 12:37:18.975 - amici.ode_export - DEBUG - Finished writing dzdx.cpp                    ++ (1.63E-03s)
2023-02-16 12:37:18.979 - amici.ode_export - DEBUG - Finished computing dzdp                     +++ (4.66E-05s)
2023-02-16 12:37:18.979 - amici.ode_export - DEBUG - Finished writing dzdp.cpp                    ++ (1.61E-03s)
2023-02-16 12:37:18.982 - amici.ode_export - DEBUG - Finished computing drzdx                    +++ (4.78E-05s)
2023-02-16 12:37:18.983 - amici.ode_export - DEBUG - Finished writing drzdx.cpp                   ++ (1.67E-03s)
2023-02-16 12:37:18.986 - amici.ode_export - DEBUG - Finished computing drzdp                    +++ (5.38E-05s)
2023-02-16 12:37:18.986 - amici.ode_export - DEBUG - Finished writing drzdp.cpp                   ++ (1.69E-03s)
2023-02-16 12:37:18.992 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (1.11E-04s)
2023-02-16 12:37:18.994 - amici.ode_export - DEBUG - Finished simplifying dsigmaydy             ++++ (3.44E-05s)
2023-02-16 12:37:18.994 - amici.ode_export - DEBUG - Finished computing dsigmaydy                +++ (3.81E-03s)
2023-02-16 12:37:18.994 - amici.ode_export - DEBUG - Finished writing dsigmaydy.cpp               ++ (5.42E-03s)
2023-02-16 12:37:19.000 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (4.32E-04s)
2023-02-16 12:37:19.002 - amici.ode_export - DEBUG - Finished simplifying dsigmaydp             ++++ (7.44E-05s)
2023-02-16 12:37:19.002 - amici.ode_export - DEBUG - Finished computing dsigmaydp                +++ (4.23E-03s)
2023-02-16 12:37:19.003 - amici.ode_export - DEBUG - Finished writing dsigmaydp.cpp               ++ (6.96E-03s)
2023-02-16 12:37:19.006 - amici.ode_export - DEBUG - Finished writing sigmay.cpp                  ++ (5.00E-04s)
2023-02-16 12:37:19.011 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (2.56E-05s)
2023-02-16 12:37:19.013 - amici.ode_export - DEBUG - Finished simplifying dsigmazdp             ++++ (3.78E-05s)
2023-02-16 12:37:19.013 - amici.ode_export - DEBUG - Finished computing dsigmazdp                +++ (3.67E-03s)
2023-02-16 12:37:19.014 - amici.ode_export - DEBUG - Finished writing dsigmazdp.cpp               ++ (5.26E-03s)
2023-02-16 12:37:19.016 - amici.ode_export - DEBUG - Finished writing sigmaz.cpp                  ++ (1.64E-05s)
2023-02-16 12:37:19.019 - amici.ode_export - DEBUG - Finished computing stau                     +++ (5.81E-05s)
2023-02-16 12:37:19.019 - amici.ode_export - DEBUG - Finished writing stau.cpp                    ++ (1.65E-03s)
2023-02-16 12:37:19.023 - amici.ode_export - DEBUG - Finished computing deltax                   +++ (5.10E-05s)
2023-02-16 12:37:19.024 - amici.ode_export - DEBUG - Finished writing deltax.cpp                  ++ (1.91E-03s)
2023-02-16 12:37:19.027 - amici.ode_export - DEBUG - Finished computing deltasx                  +++ (5.45E-05s)
2023-02-16 12:37:19.028 - amici.ode_export - DEBUG - Finished writing deltasx.cpp                 ++ (1.86E-03s)
2023-02-16 12:37:19.032 - amici.ode_export - DEBUG - Finished writing w.cpp                       ++ (2.53E-03s)
2023-02-16 12:37:19.038 - amici.ode_export - DEBUG - Finished simplifying x0                    ++++ (8.98E-04s)
2023-02-16 12:37:19.038 - amici.ode_export - DEBUG - Finished computing x0                       +++ (2.79E-03s)
2023-02-16 12:37:19.040 - amici.ode_export - DEBUG - Finished writing x0.cpp                      ++ (5.34E-03s)
2023-02-16 12:37:19.046 - amici.ode_export - DEBUG - Finished simplifying x0_fixedParameters    ++++ (3.45E-04s)
2023-02-16 12:37:19.046 - amici.ode_export - DEBUG - Finished computing x0_fixedParameters       +++ (2.33E-03s)
2023-02-16 12:37:19.047 - amici.ode_export - DEBUG - Finished writing x0_fixedParameters.cpp      ++ (4.79E-03s)
2023-02-16 12:37:19.053 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (9.02E-04s)
2023-02-16 12:37:19.055 - amici.ode_export - DEBUG - Finished simplifying sx0                   ++++ (3.90E-05s)
2023-02-16 12:37:19.055 - amici.ode_export - DEBUG - Finished computing sx0                      +++ (4.79E-03s)
2023-02-16 12:37:19.056 - amici.ode_export - DEBUG - Finished writing sx0.cpp                     ++ (6.54E-03s)
2023-02-16 12:37:19.061 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (8.95E-05s)
2023-02-16 12:37:19.063 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (1.41E-04s)
2023-02-16 12:37:19.066 - amici.ode_export - DEBUG - Finished simplifying sx0_fixedParameters   ++++ (2.92E-05s)
2023-02-16 12:37:19.066 - amici.ode_export - DEBUG - Finished computing sx0_fixedParameters      +++ (6.44E-03s)
2023-02-16 12:37:19.067 - amici.ode_export - DEBUG - Finished writing sx0_fixedParameters.cpp     ++ (8.77E-03s)
2023-02-16 12:37:19.075 - amici.ode_export - DEBUG - Finished writing xdot.cpp                    ++ (5.99E-03s)
2023-02-16 12:37:19.080 - amici.ode_export - DEBUG - Finished writing y.cpp                       ++ (2.52E-03s)
2023-02-16 12:37:19.085 - amici.ode_export - DEBUG - Finished simplifying x_rdata               ++++ (7.20E-05s)
2023-02-16 12:37:19.086 - amici.ode_export - DEBUG - Finished computing x_rdata                  +++ (2.21E-03s)
2023-02-16 12:37:19.087 - amici.ode_export - DEBUG - Finished writing x_rdata.cpp                 ++ (4.64E-03s)
2023-02-16 12:37:19.092 - amici.ode_export - DEBUG - Finished simplifying total_cl              ++++ (3.50E-05s)
2023-02-16 12:37:19.093 - amici.ode_export - DEBUG - Finished computing total_cl                 +++ (1.79E-03s)
2023-02-16 12:37:19.093 - amici.ode_export - DEBUG - Finished writing total_cl.cpp                ++ (3.50E-03s)
2023-02-16 12:37:19.098 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (2.68E-05s)
2023-02-16 12:37:19.100 - amici.ode_export - DEBUG - Finished simplifying dtotal_cldp           ++++ (3.98E-05s)
2023-02-16 12:37:19.100 - amici.ode_export - DEBUG - Finished computing dtotal_cldp              +++ (3.62E-03s)
2023-02-16 12:37:19.100 - amici.ode_export - DEBUG - Finished writing dtotal_cldp.cpp             ++ (5.25E-03s)
2023-02-16 12:37:19.105 - amici.ode_export - DEBUG - Finished simplifying dtotal_cldx_rdata     ++++ (2.96E-05s)
2023-02-16 12:37:19.106 - amici.ode_export - DEBUG - Finished computing dtotal_cldx_rdata        +++ (1.73E-03s)
2023-02-16 12:37:19.106 - amici.ode_export - DEBUG - Finished writing dtotal_cldx_rdata.cpp       ++ (3.50E-03s)
2023-02-16 12:37:19.111 - amici.ode_export - DEBUG - Finished simplifying x_solver              ++++ (7.02E-05s)
2023-02-16 12:37:19.112 - amici.ode_export - DEBUG - Finished computing x_solver                 +++ (1.82E-03s)
2023-02-16 12:37:19.113 - amici.ode_export - DEBUG - Finished writing x_solver.cpp                ++ (4.36E-03s)
2023-02-16 12:37:19.118 - amici.ode_export - DEBUG - Finished simplifying dx_rdatadx_solver     ++++ (2.82E-04s)
2023-02-16 12:37:19.118 - amici.ode_export - DEBUG - Finished computing dx_rdatadx_solver        +++ (1.94E-03s)
2023-02-16 12:37:19.119 - amici.ode_export - DEBUG - Finished writing dx_rdatadx_solver.cpp       ++ (4.05E-03s)
2023-02-16 12:37:19.125 - amici.ode_export - DEBUG - Finished simplifying dx_rdatadp            ++++ (3.14E-04s)
2023-02-16 12:37:19.125 - amici.ode_export - DEBUG - Finished computing dx_rdatadp               +++ (2.11E-03s)
2023-02-16 12:37:19.126 - amici.ode_export - DEBUG - Finished writing dx_rdatadp.cpp              ++ (4.04E-03s)
2023-02-16 12:37:19.131 - amici.ode_export - DEBUG - Finished running smart_jacobian            ++++ (2.58E-05s)
2023-02-16 12:37:19.133 - amici.ode_export - DEBUG - Finished simplifying dx_rdatadtcl          ++++ (3.95E-05s)
2023-02-16 12:37:19.133 - amici.ode_export - DEBUG - Finished computing dx_rdatadtcl             +++ (3.71E-03s)
2023-02-16 12:37:19.133 - amici.ode_export - DEBUG - Finished writing dx_rdatadtcl.cpp            ++ (5.36E-03s)
2023-02-16 12:37:19.136 - amici.ode_export - DEBUG - Finished writing z.cpp                       ++ (1.84E-05s)
2023-02-16 12:37:19.138 - amici.ode_export - DEBUG - Finished writing rz.cpp                      ++ (1.69E-05s)
2023-02-16 12:37:19.147 - amici.ode_export - DEBUG - Finished generating cpp code                  + (6.45E-01s)
2023-02-16 12:37:31.424 - amici.ode_export - DEBUG - Finished compiling cpp code                   + (1.23E+01s)
running AmiciInstall
hdf5.h found in /opt/homebrew/Cellar/hdf5/1.12.2_2/include
libhdf5.a found in /opt/homebrew/Cellar/hdf5/1.12.2_2/lib
running build_ext
Changed extra_compile_args for unix to ['-std=c++14']
Building model extension in /Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014
building 'Boehm_JProteomeRes2014._Boehm_JProteomeRes2014' extension
Testing SWIG executable swig4.0... FAILED.
Testing SWIG executable swig3.0... FAILED.
Testing SWIG executable swig... SUCCEEDED.
swigging swig/Boehm_JProteomeRes2014.i to swig/Boehm_JProteomeRes2014_wrap.cpp
swig -python -c++ -modern -outdir Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/swig -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -o swig/Boehm_JProteomeRes2014_wrap.cpp swig/Boehm_JProteomeRes2014.i
Deprecated command line option: -modern. Ignored, this option is now always on.
creating build
creating build/temp.macosx-13-arm64-cpython-310
creating build/temp.macosx-13-arm64-cpython-310/swig
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_Jy.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_Jy.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dJydsigma.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dJydsigma.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dJydy.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dJydy.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dJydy_colptrs.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dJydy_colptrs.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dJydy_rowvals.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dJydy_rowvals.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dsigmaydp.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dsigmaydp.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dwdp.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdp.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dwdp_colptrs.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdp_colptrs.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dwdp_rowvals.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdp_rowvals.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dwdw.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdw.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dwdw_colptrs.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdw_colptrs.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dwdw_rowvals.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdw_rowvals.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dwdx.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdx.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dwdx_colptrs.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdx_colptrs.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dwdx_rowvals.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdx_rowvals.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dxdotdw.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dxdotdw.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dxdotdw_colptrs.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dxdotdw_colptrs.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dxdotdw_rowvals.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dxdotdw_rowvals.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_dydx.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dydx.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_sigmay.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_sigmay.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_sx0_fixedParameters.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_sx0_fixedParameters.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_w.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_w.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_x0.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_x0.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_x0_fixedParameters.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_x0_fixedParameters.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_x_rdata.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_x_rdata.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_x_solver.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_x_solver.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_xdot.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_xdot.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c Boehm_JProteomeRes2014_y.cpp -o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_y.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c swig/Boehm_JProteomeRes2014_wrap.cpp -o build/temp.macosx-13-arm64-cpython-310/swig/Boehm_JProteomeRes2014_wrap.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk -I/Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014 -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/gsl -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/sundials/include -I/Users/fabian/Documents/projects/AMICI/python/sdist/amici/ThirdParty/SuiteSparse/include -I/opt/homebrew/Cellar/hdf5/1.12.2_2/include -I/Users/fabian/Documents/projects/AMICI/build/venv/include -I/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c wrapfunctions.cpp -o build/temp.macosx-13-arm64-cpython-310/wrapfunctions.o -std=c++14
clang++ -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_Jy.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dJydsigma.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dJydy.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dJydy_colptrs.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dJydy_rowvals.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dsigmaydp.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdp.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdp_colptrs.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdp_rowvals.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdw.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdw_colptrs.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdw_rowvals.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdx.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdx_colptrs.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dwdx_rowvals.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dxdotdw.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dxdotdw_colptrs.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dxdotdw_rowvals.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_dydx.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_sigmay.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_sx0_fixedParameters.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_w.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_x0.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_x0_fixedParameters.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_x_rdata.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_x_solver.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_xdot.o build/temp.macosx-13-arm64-cpython-310/Boehm_JProteomeRes2014_y.o build/temp.macosx-13-arm64-cpython-310/swig/Boehm_JProteomeRes2014_wrap.o build/temp.macosx-13-arm64-cpython-310/wrapfunctions.o -L/opt/homebrew/Cellar/hdf5/1.12.2_2/lib -L/Users/fabian/Documents/projects/AMICI/python/sdist/amici/libs -lamici -lsundials -lsuitesparse -lcblas -lhdf5_hl_cpp -lhdf5_hl -lhdf5_cpp -lhdf5 -o /Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014/Boehm_JProteomeRes2014/_Boehm_JProteomeRes2014.cpython-310-darwin.so
ld: warning: -undefined dynamic_lookup may not work with chained fixups

2023-02-16 12:37:31.673 - amici.petab_import - INFO - Finished Importing PEtab model                (1.36E+01s)
2023-02-16 12:37:31.684 - amici.petab_import - INFO - Successfully loaded model Boehm_JProteomeRes2014 from /Users/fabian/Documents/projects/AMICI/documentation/amici_models/Boehm_JProteomeRes2014.

JAX implementation

For full jax support, we would have to implement a new primitive, which would require quite a bit of engineering, and in the end wouldn’t add much benefit since AMICI can’t run on GPUs. Instead will interface AMICI using the experimental jax module `host_callback <https://jax.readthedocs.io/en/latest/jax.experimental.host_callback.html>`__.

To do so, we define a base function that only takes a single argument (the parameters) and runs simulation using petab via `simulate_petab <https://amici.readthedocs.io/en/latest/generated/amici.petab_objective.html#amici.petab_objective.simulate_petab>`__. To enable gradient computation later on, we create a solver object and set the sensitivity order to first order and pass it to simulate_petab. Moreover, simulate_petab expects a dictionary of parameters, so we create a dictionary using the free parameter ids from the petab problem. As we want to implement parameter transformation in JAX, we disable parameter scaling in petab by passing scaled_parameters=True.

[6]:
from amici.petab_objective import simulate_petab
import amici
amici_solver = amici_model.getSolver()
amici_solver.setSensitivityOrder(amici.SensitivityOrder.first)

def amici_hcb_base(parameters: jnp.array):
    return simulate_petab(
        petab_problem,
        amici_model,
        problem_parameters=dict(zip(petab_problem.x_free_ids, parameters)),
        scaled_parameters=True,
        solver=amici_solver,
    )

Now we can use this base function to create two functions separate functions that compute the log-likelihood (llh) and it’s gradient (sllh) in two individual routines. Note that, as we are using the same base function here, the log-likelihood computation will also run with sensitivities which is not necessary and will add some overhead. This is only out of convenience and should be fixed in an application where efficiency is important.

[7]:
def amici_hcb_llh(parameters: jnp.array):
    return amici_hcb_base(parameters)['llh']

def amici_hcb_sllh(parameters: jnp.array):
    sllh = amici_hcb_base(parameters)['sllh']
    return jnp.asarray(tuple(
        sllh[par_id] for par_id in petab_problem.x_free_ids
    ))

Now we can finally define the JAX function that runs amici simulation using the host callback. We add a custom_jvp decorater so that we can define a custom jacobian vector product function in the next step. More details about custom jacobian vector product functions can be found in the JAX documentation

[8]:
import jax.experimental.host_callback as hcb
from jax import custom_jvp

import numpy as np
@custom_jvp
def jax_objective(parameters: jnp.array):
    return hcb.call(
        amici_hcb_llh,
        parameters,
        result_shape=jax.ShapeDtypeStruct((), np.float64),
    )

Now we define the function that implement the jacobian vector product. This effectively just returns the objective function value (computed using the previously defined jax_objective) as well as the inner product of the gradient (computed using a host callback to the previously defined amici_hcb_sllh) and the tangents vector. Note that this implementation performs two simulation runs, one for the function value and one for the gradient, which is inefficient and could be avoided by caching solutions.

[9]:
@jax_objective.defjvp
def jax_objective_jvp(primals: jnp.array, tangents: jnp.array):
    (parameters,) = primals
    (x_dot,) = tangents
    llh = jax_objective(parameters)
    sllh = hcb.call(
        amici_hcb_sllh,
        parameters,
        result_shape=jax.ShapeDtypeStruct((petab_problem.parameter_df.estimate.sum(),), np.float64),
    )
    return llh, sllh.dot(x_dot)

As last step, we implement the parameter transformation in jax. This effectively just extracts parameter scales from the petab problem, implements rescaling in jax and then passes the scaled parameters to the previously objective function we previously defined. We add the value_and_grad decorator such that the generated jax function returns both function value and function gradient in a tuple. Moreover, we add the jax.jit decorator such that the function is just in time compiled upon the first function call.

[10]:
from jax import value_and_grad

parameter_scales = petab_problem.parameter_df.loc[petab_problem.x_free_ids, petab.PARAMETER_SCALE].values

@jax.jit
@value_and_grad
def jax_objective_with_parameter_transform(parameters: jnp.array):
    par_scaled = jnp.asarray(tuple(
        value if scale == petab.LIN
        else jnp.log(value) if scale == petab.LOG
        else jnp.log10(value)
        for value, scale in zip(parameters, parameter_scales)
    ))
    return jax_objective(par_scaled)

Testing

We can now run the function to compute the log-likelihood and the gradient.

[11]:
llh_jax, sllh_jax = jax_objective_with_parameter_transform(petab_problem.x_nominal_free)

As a sanity check, we compare the computed value to native parameter transformation in amici.

[12]:
r = simulate_petab(petab_problem, amici_model, solver=amici_solver)
# TODO remove me as soon as sllh in simulate_petab is fixed
sllh = {
    name: value / (np.log(10) * par_value)
    for (name, value), par_value in zip(r['sllh'].items(), petab_problem.x_nominal_free)
}
[13]:
import pandas as pd
pd.Series(dict(amici=r['llh'], jax=float(llh_jax)))
[13]:
amici   -138.221997
jax     -138.222000
dtype: float64
[14]:
pd.DataFrame(index=sllh.keys(), data=dict(amici=sllh.values(), jax=np.asarray(sllh_jax)))
[14]:
amici jax
Epo_degradation_BaF3 -3.546026e-01 -3.640394e-01
k_exp_hetero -2.401005e+03 -2.401010e+03
k_exp_homo -4.073832e-01 -4.106763e-01
k_imp_hetero -1.432855e-01 -1.639030e-01
k_imp_homo 2.006412e-10 2.006412e-10
k_phos -2.179950e-07 -2.089803e-07
sd_pSTAT5A_rel -1.215545e-03 -1.222887e-03
sd_pSTAT5B_rel -1.583889e-03 -1.580870e-03
sd_rSTAT5A_rel -2.643776e-03 -2.641361e-03

We see quite some differences in the gradient calculation. The primary reason is that running JAX in default configuration will use float32 precision for the parameters that are passed to AMICI, which uses float64, and the derivative of the parameter transformation As AMICI simulations that run on the CPU are the most expensive operation, there is barely any tradeoff for using float32 vs float64 in JAX. Therefore we configure JAX to use float64 instead and rerun simulations.

[15]:
jax.config.update("jax_enable_x64", True)
llh_jax, sllh_jax = jax_objective_with_parameter_transform(petab_problem.x_nominal_free)

We can now evaluate the results again and see that differences between pure AMICI and AMICI/JAX implementations are now much smaller.

[16]:
pd.Series(dict(amici=r['llh'], jax=float(llh_jax)))
[16]:
amici   -138.221997
jax     -138.221997
dtype: float64
[17]:
pd.DataFrame(index=sllh.keys(), data=dict(amici=sllh.values(), jax=np.asarray(sllh_jax)))
[17]:
amici jax
Epo_degradation_BaF3 -3.546026e-01 -3.546504e-01
k_exp_hetero -2.401005e+03 -2.401005e+03
k_exp_homo -4.073832e-01 -4.074248e-01
k_imp_hetero -1.432855e-01 -1.433139e-01
k_imp_homo 2.006412e-10 2.006412e-10
k_phos -2.179950e-07 -2.179076e-07
sd_pSTAT5A_rel -1.215545e-03 -1.215596e-03
sd_pSTAT5B_rel -1.583889e-03 -1.583805e-03
sd_rSTAT5A_rel -2.643776e-03 -2.643703e-03