Skip to content

AMICI failed to integrate the forward problem in PEtab problem, encountered NaN values #1796

@matthiaskoenig

Description

@matthiaskoenig

Hi all,
when running the attached PETab Problem I see failing forward integration.

icg_sd.zip

I tried to simulate the model with

petab_problem = petab.Problem.from_yaml(yaml_file)
model = import_petab_problem(petab_problem)
simulate_petab(petab_problem, model)

and get the following errors

[Warning] AMICI:NaN: AMICI encountered a NaN value for xdot[0] (Cre_plasma_icg)
[Warning] AMICI:NaN: AMICI encountered a NaN value for w[27]!
[Warning] AMICI:CVODES:CVode:OTHER: AMICI ERROR: in module CVODES in function CVode : The right-hand side routine failed at the first call. 
[Warning] AMICI:simulation: AMICI forward simulation failed at t = 0.000000:
AMICI failed to integrate the forward problem

[Warning] AMICI:CVODES:CVode:WARNING: AMICI ERROR: in module CVODES in function CVode : At the end of the first step, there are still some root functions identically 0. This warning will not be issued again. 
[Warning] AMICI:CVODES:CVode:WARNING: AMICI ERROR: in module CVODES in function CVode : At the end of the first step, there are still some root functions identically 0. This warning will not be issued again. 
[Warning] AMICI:NaN: AMICI encountered a NaN value for xdot[0] (Cre_plasma_icg)
[Warning] AMICI:NaN: AMICI encountered a NaN value for w[26]!
[Warning] AMICI:CVODES:CVode:OTHER: AMICI ERROR: in module CVODES in function CVode : The right-hand side routine failed at the first call. 
[Warning] AMICI:simulation: AMICI forward simulation failed at t = 0.000000:
AMICI failed to integrate the forward problem

Directly loading the model with AMICI and simulating it works without problems, i.e. the following code is successful for the model file

    sbml_importer = amici.SbmlImporter(model_file)
    model_dir = output_dir / "amici" / mid
    sbml_importer.sbml2amici(mid, model_dir)

    # load the model module
    model_module = amici.import_model_module(mid, model_dir)
    # instantiate model
    model = model_module.getModel()

    # model properties
    print("Model parameters:", list(model.getParameterIds()), "\n")
    print("Model const parameters:", list(model.getFixedParameterIds()), "\n")
    print("Model outputs:", list(model.getObservableIds()), "\n")
    print("Model states:", list(model.getStateIds()), "\n")

    # instantiate solver
    solver = model.getSolver()
    solver.setAbsoluteTolerance(1e-10)

    # run forward simulation
    t = np.linspace(0, 20, num=5)
    model.setTimepoints(t)
    rdata = amici.runAmiciSimulation(model, solver)
    print(t)
    print(rdata.x)

resulting in

--- amici ---
Model parameters: ['conversion_ml_per_l', 'conversion_l_per_ml', 'BW', 'HEIGHT', 'COBW', 'Fblood', 'HCT', 'FVgi', 'FVbi', 'FVli', 'FVlu', 'FVve', 'FVar', 'FVpo', 'FVhv', 'FQgi', 'FQh', 'FQlu', 'f_cirrhosis', 'f_shunts', 'f_tissue_loss', 'f_bloodflow', 'f_cardiac_output', 'f_exercise', 'resection_rate', 'Mr_icg', 'ti_icg', 'Ri_icg', 'LI__ICGIM_Vmax', 'LI__ICGIM_Km', 'LI__ICGIM_ki_bil', 'LI__f_oatp1b3', 'LI__ICGLI2CA_Vmax', 'LI__ICGLI2CA_Km', 'LI__ICGLI2BI_Vmax'] 

Model const parameters: [] 

Model outputs: ['yCre_plasma_icg', 'yCgi_plasma_icg', 'yCli_plasma_icg', 'yClu_plasma_icg', 'yCve_icg', 'yCar_icg', 'yCpo_icg', 'yChv_icg', 'yAfeces_icg', 'yLI__bil_ext', 'yLI__icg', 'yLI__icg_bi', 'yIVDOSE_icg', 'ycum_dose_icg', 'yFVre', 'yFQre', 'yBSA', 'yCO', 'yQC', 'yQlu', 'yQre', 'yQh', 'yQgi', 'yQpo', 'yQha', 'yKi_icg', 'yAre_plasma_icg', 'yXre_plasma_icg', 'yMre_plasma_icg', 'yAgi_plasma_icg', 'yXgi_plasma_icg', 'yMgi_plasma_icg', 'yAli_plasma_icg', 'yXli_plasma_icg', 'yMli_plasma_icg', 'yAlu_plasma_icg', 'yXlu_plasma_icg', 'yMlu_plasma_icg', 'yAve_icg', 'yXve_icg', 'yMve_icg', 'yAar_icg', 'yXar_icg', 'yMar_icg', 'yApo_icg', 'yXpo_icg', 'yMpo_icg', 'yAhv_icg', 'yXhv_icg', 'yMhv_icg', 'yER_icg', 'yCLinfusion_icg', 'yVbi', 'yVgi', 'yVli', 'yVlu', 'yVre', 'yVve', 'yVar', 'yVpo', 'yVhv', 'yVre_plasma', 'yVre_tissue', 'yVgi_plasma', 'yVgi_tissue', 'yVli_plasma', 'yVli_tissue', 'yVlu_plasma', 'yVlu_tissue', 'yVfeces'] 

Model states: ['Cre_plasma_icg', 'Cgi_plasma_icg', 'Cli_plasma_icg', 'Clu_plasma_icg', 'Cve_icg', 'Car_icg', 'Cpo_icg', 'Chv_icg', 'Afeces_icg', 'LI__bil_ext', 'LI__icg', 'LI__icg_bi', 'IVDOSE_icg', 'cum_dose_icg'] 

[ 0.  5. 10. 15. 20.]
[[0.   0.   0.   0.   0.   0.   0.   0.   0.   0.01 0.   0.   0.   0.  ]
 [0.   0.   0.   0.   0.   0.   0.   0.   0.   0.01 0.   0.   0.   0.  ]
 [0.   0.   0.   0.   0.   0.   0.   0.   0.   0.01 0.   0.   0.   0.  ]
 [0.   0.   0.   0.   0.   0.   0.   0.   0.   0.01 0.   0.   0.   0.  ]
 [0.   0.   0.   0.   0.   0.   0.   0.   0.   0.01 0.   0.   0.   0.  ]]

Best Matthias

Metadata

Metadata

Assignees

No one assigned

    Labels

    newNewly created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions