Skip to content

account for heaviside functions in expressions#1382

Merged
FFroehlich merged 23 commits intodevelopfrom
fix_heaviside
Feb 1, 2021
Merged

account for heaviside functions in expressions#1382
FFroehlich merged 23 commits intodevelopfrom
fix_heaviside

Conversation

@FFroehlich
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Jan 26, 2021

Codecov Report

Merging #1382 (2f8efb2) into develop (b94525e) will increase coverage by 12.21%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##           develop    #1382       +/-   ##
============================================
+ Coverage    78.67%   90.88%   +12.21%     
============================================
  Files           63        2       -61     
  Lines         9925     1404     -8521     
============================================
- Hits          7808     1276     -6532     
+ Misses        2117      128     -1989     
Flag Coverage Δ
cpp ?
petab ?
python ?
sbmlsuite 90.88% <100.00%> (+2.77%) ⬆️

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

Impacted Files Coverage Δ
python/amici/ode_export.py 89.92% <100.00%> (-2.81%) ⬇️
python/amici/sbml_import.py 92.32% <100.00%> (-3.73%) ⬇️
src/solver_idas.cpp
include/amici/model_dae.h
python/amici/petab_simulate.py
python/amici/__init__.py
src/cblas.cpp
src/solver_cvodes.cpp
... and 51 more

Copy link
Contributor

@paulstapor paulstapor left a comment

Choose a reason for hiding this comment

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

should hopefully do the job...

Copy link
Member

@dilpath dilpath left a comment

Choose a reason for hiding this comment

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

Should have a test at some point I guess

@FFroehlich
Copy link
Member Author

Should have a test at some point I guess

will add Chen_MSB2009 which should now be working.

@FFroehlich FFroehlich self-assigned this Jan 30, 2021
Comment on lines 1626 to 1631
if isinstance(trigger, sp.core.relational.StrictLessThan):
# x < y => x - y < 0 => r < 0
return sp.Heaviside(-root)
return 1 - sp.Heaviside(root)
if isinstance(trigger, sp.core.relational.LessThan):
# x <= y => not(y < x) => not(y - x < 0) => not -r < 0
return 1 - sp.Heaviside(root)
return sp.Heaviside(-root)
Copy link
Member

Choose a reason for hiding this comment

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

What's the difference between 1-H(x) and H(-x)? Should the difference between < and <= be the value that H(x) is defined to take at x==0? Similarly for > and >= below?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, nevermind

double heaviside(double x) {
if (x <= 0.0) {
return 0.0;
}
return 1.0;
}

Copy link
Member

Choose a reason for hiding this comment

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

Hm, given this definition, x < 0 would correspond to H(-x)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, 1-H(x) and H(-x) should be equivalent... For the difference between < and <= I have to say: Hard to tell what will happen if x is a floating point number...

Copy link
Member

Choose a reason for hiding this comment

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

1-H(x) and H(-x) should be equivalent

Not equivalent for this implementation of the Heaviside function but agreed 👍 (equivalent everywhere except 0)

Copy link
Member Author

Choose a reason for hiding this comment

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

This implementation addresses the situation when the simulation starts at a point where some of the arguments of heaviside functions evaluates to 0 (which can happen when translating SBML piecewise functions), which led to errors previously. It looks like the cpp implementation needs to be updated as its not consistent with the internal implementation. Will add a short blurb about that to the documentation.

@FFroehlich
Copy link
Member Author

Should have a test at some point I guess

will add Chen_MSB2009 which should now be working.

Actually just disabling the model agains since that model is a mess (as reported before). I'm confident that implementation is correct, but llh values don't match. Also functionality is tested in Weber_BMC2015.

@FFroehlich FFroehlich merged commit 88ba9bd into develop Feb 1, 2021
@FFroehlich FFroehlich deleted the fix_heaviside branch February 1, 2021 20:12
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 1, 2021

@dweindl dweindl mentioned this pull request Feb 19, 2021
dweindl added a commit that referenced this pull request Feb 20, 2021
….13)

Breaking changes:
* AMICI requires Python>=3.7
* Updated package installation (PEP517/518): 
  Creating source distributions requires https://github.com/pypa/build (#1384)
  (but now handles all package building dependencies properly)

Features:
* More flexible state reinitialization (#1417)

Updated dependencies:
* Upgrade to sundials 5.7.0 (#1392)

Fixes:
* Python: account for heaviside functions in expressions (#1382)
* Python: allow loading of existing models in import_petab_problem (#1383)
* Python: Don't override user-provided compiler/linker flags (#1389)
* Python: PEtab import reinitialization fixes (#1417)
* Python: Fix PEtab observables for pysb models (#1390)
* Python: Substitute expressions in event condition expressions (#1404)
* Python: Unspecified initial states in PEtab conditions table default to SBML initial value (#1397)
* C++: Fix timepoint out of bounds access (#1402)
* C++: Fix exported CMake config (#1388)
* Fixed Dockerfile: add python3-venv (#1398, #1408)

Other:
* Slim exported swig interface (#1425)
* Updated documentation
    * Getting started tutorial (#1423)
    * List supported SBML test tags (#1428)
    * Add AMICI C++/Python/Matlab feature comparison (#1409)
    * ...
* Various minor CI improvements
* ...
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.

4 participants