Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requesting sensitivities for algebraic equations breaks simulation #2102

Open
dilpath opened this issue May 22, 2023 · 1 comment · May be fixed by #2101
Open

Requesting sensitivities for algebraic equations breaks simulation #2102

dilpath opened this issue May 22, 2023 · 1 comment · May be fixed by #2101
Labels
bug DAE related to differential algebraic equations

Comments

@dilpath
Copy link
Member

dilpath commented May 22, 2023

What did you expect to happen?
Sensitivities to be computed

What has happened instead?
rdata.x and rdata.sx are zero matrices

To Reproduce
Compile a model with algebraic expressions, e.g. SBML semantic test case 00039, simulate with and without computation of forward sensitivities.

sbml_file = "tests/sbml-test-suite/cases/semantic/00039/00039-sbml-l3v2.xml"

from pathlib import Path
model_name = "m00039"
model_dir = Path("amici_models") / model_name
model_dir.mkdir(parents=True, exist_ok=True)

import amici
import numpy as np

sbml_importer = amici.SbmlImporter(sbml_file)    
sbml_importer.sbml2amici(    
    model_name,    
    output_dir=model_dir,    
    generate_sensitivity_code=True,    
)    

model_module = amici.import_model_module(model_name, model_dir)
model = model_module.getModel()
solver = model.getSolver()

model.setTimepoints(np.linspace(0, 8, 51))
solver.setMaxSteps(int(1e6))

solver.setSensitivityOrder(amici.SensitivityOrder.first)
solver.setSensitivityMethod(amici.SensitivityMethod.forward)

rdata = amici.runAmiciSimulation(model, solver)
print(rdata.x) 
print(rdata.sx)

AMICI version and system environment

  • OS and version: Ubuntu 22.04
  • AMICI interface: Python
  • AMICI version: latest develop branch
  • Additional information: GCC 10.4.0, Python 3.10.6
@dilpath dilpath added the new Newly created label May 22, 2023
@dweindl dweindl linked a pull request May 23, 2023 that will close this issue
@dweindl
Copy link
Member

dweindl commented May 23, 2023

I agree that this is not the desired behavior. In case of errors, x and sx (and others) should be NaN. It seems there is a call to ReturnData::invalidate missing. Since rdata.status is AMICI_ERROR, it wouldn't consider this high priority, and would rather have the root cause fixed via #2101. (Volunteers?)

@dweindl dweindl added bug and removed new Newly created labels May 23, 2023
@dweindl dweindl added the DAE related to differential algebraic equations label Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug DAE related to differential algebraic equations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants