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

SBML import: Alternative algorithm for identifying conservation laws #1748

Merged
merged 20 commits into from
Mar 30, 2022

Conversation

dweindl
Copy link
Member

@dweindl dweindl commented Mar 28, 2022

... without Monte Carlo mumbo-jumbo.

Compute left nullspace of S via (numerical) Gaussian elimination. Going via SVD would be faster and numerically safer, but this seems to lead to weird coefficients.

For the model in test_compute_moiety_conservation_laws_demartino2014, this algorithm is slower than the one already implemented (~1min vs ~10s), but at least it's deterministic and not highly dependent on RNG seeds. For another model of similar size, the new algorithm takes ~2.5min instead of previously 1h20.

@codecov
Copy link

codecov bot commented Mar 28, 2022

Codecov Report

Merging #1748 (7facd35) into develop (7c7851c) will increase coverage by 0.02%.
The diff coverage is 88.65%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1748      +/-   ##
===========================================
+ Coverage    77.72%   77.74%   +0.02%     
===========================================
  Files           73       74       +1     
  Lines        11923    12012      +89     
===========================================
+ Hits          9267     9339      +72     
- Misses        2656     2673      +17     
Flag Coverage Δ
cpp 74.83% <ø> (+0.09%) ⬆️
petab 59.26% <79.38%> (-3.30%) ⬇️
python 68.20% <85.56%> (+0.10%) ⬆️
sbmlsuite 86.81% <78.04%> (-1.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
python/amici/conserved_quantities_demartino.py 65.55% <ø> (ø)
python/amici/sbml_import.py 93.17% <78.04%> (-2.80%) ⬇️
python/amici/conserved_quantities_rref.py 96.42% <96.42%> (ø)
src/exception.cpp 75.67% <0.00%> (ø)
src/solver_cvodes.cpp 70.26% <0.00%> (ø)
src/amici.cpp 73.13% <0.00%> (+5.22%) ⬆️

@dweindl dweindl changed the title SBML import: Alterantive algorithm for identifying conservation laws SBML import: Alternative algorithm for identifying conservation laws Mar 28, 2022
@dweindl dweindl requested a review from FFroehlich March 29, 2022 10:49
python/amici/sbml_import.py Outdated Show resolved Hide resolved
Comment on lines 1591 to 1594
if algorithm.lower() == "demartino":
raw_cls = self._get_conservation_laws_demartino(ode_model)
else:
raw_cls = self._get_conservation_laws_new()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideas for better algorithm names?

I'd still keep the previous algorithm as an option, at least for another while.

coefficients),)
return raw_cls

def _get_conservation_laws_new(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def _get_conservation_laws_new(
def _get_conservation_laws_rref(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be somewhat confusing, as the other algorithm is also doing that as a first step, but I don't have a better idea 😅

# indices of retained species
species_solver = list(range(ode_model.num_states_rdata()))

algorithm = os.environ.get("AMICI_EXPERIMENTAL_SBML_NONCONST_CLS", "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we wan't to document this option? run demartino by default if rref fails?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, should be documented. I think I'd prefer having a closer look at any failures instead of an auto-fallback.

@dweindl dweindl marked this pull request as ready for review March 30, 2022 09:17
@sonarcloud
Copy link

sonarcloud bot commented Mar 30, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 16 Code Smells

58.6% 58.6% Coverage
6.3% 6.3% Duplication

@dweindl dweindl merged commit da56a08 into develop Mar 30, 2022
@dweindl dweindl deleted the new_cls branch March 30, 2022 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants