You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there is a problem with event assignments to compartments (targeted by rate rules, others aren't supported yet), if
there are multiple event assignments for a single event, and
2a) the assignment to the compartment is not the last assignment, or
2b) there are assignments to multiple compartments
formula has the value of the most recently processed event assignments, independent on whether that was the respective compartment change.
Reproducer for case 2a:
importamicifromamici.antimony_importimportantimony2amicifromamici.testingimportTemporaryDirectoryWinSafeasTemporaryDirectoryfromnumpy.testingimportassert_allcloseant_model=""" model test_events_multiple_assignments compartment event_target = 1 event_target' = 0 species species_in_event_target in event_target = 1 unrelated = 1 # those two events produce identical results, but they don't # this one fails at (time > 10): unrelated = 2, event_target = 10 # this one works #at (time > 10): event_target = 10, unrelated = 2 # (note that antimony adds the event assignments to the sbml model # from right to left) end """module_name="test_multiple_event_assignment_with_compartment"withTemporaryDirectory(prefix=module_name, delete=False) asoutdir:
antimony2amici(
ant_model,
model_name=module_name,
output_dir=outdir,
verbose=True,
)
model_module=amici.import_model_module(
module_name=module_name, module_path=outdir
)
amici_model=model_module.getModel()
assertamici_model.ne==1assertamici_model.ne_solver==0assertamici_model.nx_rdata==3amici_model.setTimepoints(np.linspace(0, 15, 200))
amici_solver=amici_model.getSolver()
rdata=amici.runAmiciSimulation(amici_model, amici_solver)
assertrdata.status==amici.AMICI_SUCCESSidx_event_target=amici_model.getStateIds().index("event_target")
idx_unrelated=amici_model.getStateIds().index("unrelated")
idx_species_in_event_target=amici_model.getStateIds().index(
"species_in_event_target"
)
assert (rdata.x[rdata.ts<10, idx_event_target] ==1).all()
assert (rdata.x[rdata.ts>10, idx_event_target] ==10).all()
assert (rdata.x[rdata.ts<10, idx_unrelated] ==1).all()
assert (rdata.x[rdata.ts>10, idx_unrelated] ==2).all()
assert (rdata.x[rdata.ts<10, idx_species_in_event_target] ==1).all()
# fails, it's 0.5, because of division by the new value of `unrelated`assert_allclose(rdata.x[rdata.ts>10, idx_species_in_event_target], 0.1, rtol=0, atol=1e-15)
The text was updated successfully, but these errors were encountered:
Previously, in some cases (see AMICI-dev#2426), event assignments to compartments
would result in incorrect concentrations because an incorrect post-event
volume was used. This is fixed here.
ClosesAMICI-dev#2426.
I think there is a problem with event assignments to compartments (targeted by rate rules, others aren't supported yet), if
2a) the assignment to the compartment is not the last assignment, or
2b) there are assignments to multiple compartments
In this case, here:
AMICI/python/sdist/amici/sbml_import.py
Lines 1675 to 1677 in da19a55
formula
has the value of the most recently processed event assignments, independent on whether that was the respective compartment change.Reproducer for case 2a:
The text was updated successfully, but these errors were encountered: