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

Python splines #1515

Merged
merged 438 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 104 commits
Commits
Show all changes
438 commits
Select commit Hold shift + click to select a range
0d48add
Merge branch 'python_splines_before_merge' of https://github.com/AMIC…
lcontento Dec 9, 2021
ac596be
re-fix sbml exception
dweindl Dec 9, 2021
e30e3ce
Handle windows TemporaryDirectory cleanup failures
dweindl Dec 9, 2021
017e104
Fix windows PermissionError
dweindl Dec 9, 2021
5007143
remove unused import
lcontento Dec 9, 2021
5ab5c91
Revert "re-fix sbml exception"
dweindl Dec 9, 2021
588c0a5
Revert "remove unused import"
dweindl Dec 9, 2021
b956216
fix spline sensitivity test with no parameters
lcontento Dec 9, 2021
f37fa87
Merge branch 'python_splines_before_merge' of https://github.com/AMIC…
lcontento Dec 9, 2021
44ef12e
Fix some sphinx issues
dweindl Dec 9, 2021
af4b9be
Fix some sphinx issues
dweindl Dec 9, 2021
2aa13e5
Fix sphinx issues with TYPE_CHECKING
dweindl Dec 9, 2021
559c85f
Doxygen doc
dweindl Dec 9, 2021
77478ac
Temporary: Run sonar scanner before tests
dweindl Dec 10, 2021
ae0969a
cleanup
dweindl Dec 10, 2021
80fa316
Revert "cleanup"
dweindl Dec 10, 2021
7f7fefb
Cleanup
dweindl Dec 10, 2021
ffa060f
fix name
dweindl Dec 10, 2021
7860875
snakecase
dweindl Dec 10, 2021
19f567f
improve C++ docstrings
lcontento Dec 10, 2021
fa1b64e
Merge branch 'python_splines_before_merge' of https://github.com/AMIC…
lcontento Dec 10, 2021
3004a5a
cpp cleanup
dweindl Dec 10, 2021
d59782c
case
dweindl Dec 10, 2021
8e4574c
..
dweindl Dec 10, 2021
a1cfc40
fixup doxygen
dweindl Dec 10, 2021
ac663b2
snakecase
dweindl Dec 10, 2021
194ce85
typehints/case/..
dweindl Dec 10, 2021
7a06fbf
rename
dweindl Dec 10, 2021
6ae93c6
simplify
dweindl Dec 10, 2021
fee4f0f
exceptions
dweindl Dec 10, 2021
321b2d3
duplicated docs
dweindl Dec 10, 2021
fa2dff3
private
dweindl Dec 10, 2021
2272807
rename; swig ignore
dweindl Dec 10, 2021
4173836
snake, shadow
dweindl Dec 10, 2021
8d5e04d
simplify
dweindl Dec 10, 2021
8167775
adjust tolerances for spline tests
lcontento Dec 10, 2021
6a7c1fc
Merge branch 'python_splines_before_merge' of https://github.com/AMIC…
lcontento Dec 10, 2021
983d4cf
Revert "Temporary: Run sonar scanner before tests"
dweindl Dec 10, 2021
ccb9ef8
Merge branch 'develop' into python_splines_before_merge
dweindl Dec 11, 2021
f240954
Add test stub
dweindl Dec 13, 2021
4d1b4b4
Check ctor arguments
dweindl Dec 13, 2021
b744637
fix regression
lcontento Dec 16, 2021
3edcf76
fix floating point splines
lcontento Dec 16, 2021
e106388
draft of example notebook
lcontento Dec 16, 2021
554050e
Merge branch 'develop' into python_splines_before_merge
lcontento Dec 16, 2021
597ddc4
remove leftover code
lcontento Dec 16, 2021
8582e68
fix (maybe) signedness error on CI
lcontento Dec 16, 2021
f0fb1ea
Merge branch 'python_splines_before_merge' of https://github.com/AMIC…
lcontento Dec 16, 2021
2257636
test unit-tests
lcontento Dec 17, 2021
db8efa7
fix typo
lcontento Dec 17, 2021
0d9fe6c
switch to all float?
lcontento Dec 17, 2021
b84c384
fix typo in header too
lcontento Dec 17, 2021
93a5e47
fix float division
lcontento Dec 17, 2021
40fe2cb
split tests
lcontento Dec 17, 2021
327680b
fix finite differences
lcontento Dec 17, 2021
f8c3c3e
fix private
lcontento Dec 17, 2021
0956651
make spline exact on nodes
lcontento Dec 17, 2021
586005b
one more test spline
lcontento Dec 17, 2021
4a0bc42
remove python syntax
lcontento Dec 17, 2021
f777034
derivatives are given/computed in linear space
lcontento Dec 17, 2021
c759bed
test for logarithmic spline
lcontento Dec 17, 2021
bc5c1f0
approx tests
lcontento Dec 17, 2021
3e692e4
Merge branch 'develop' into python_splines_before_merge
dweindl Jan 13, 2022
31ceb3b
Merge branch 'develop' into python_splines_before_merge
lcontento Jan 19, 2022
fe32d48
Merge branch 'develop' into python_splines_before_merge
dweindl Feb 1, 2022
cb70d3e
Merge branch 'develop' into python_splines_before_merge
lcontento Feb 3, 2022
8b3c023
temporarily disable python tests
lcontento Feb 3, 2022
b927efa
fix extrapolation for all BCs
lcontento Feb 3, 2022
dee946d
use and check noExtrapolation
lcontento Feb 3, 2022
3317f44
extrapolation tests
lcontento Feb 3, 2022
d9d52b3
fix periodic bc in test
lcontento Feb 3, 2022
1481108
fix derivative computation for periodic bc
lcontento Feb 3, 2022
5f57e3a
fix missing include for AmiException
lcontento Feb 3, 2022
d413f81
fix missing commas
lcontento Feb 3, 2022
a4a7df9
bugfix
lcontento Feb 3, 2022
bcfc104
Merge branch 'develop' into python_splines_before_merge
dweindl Feb 7, 2022
a8bdf46
fix sensitivity computation for fd
lcontento Feb 14, 2022
a2fb585
test sensitivity (simplest case)
lcontento Feb 14, 2022
873a4dd
remove unused variables
lcontento Feb 14, 2022
26e757b
fix loop variable type
lcontento Feb 14, 2022
a5bcef2
Merge branch 'develop' into python_splines_before_merge
lcontento Feb 14, 2022
f0e2e4d
add atol in test
lcontento Feb 14, 2022
044cecf
fix botched merge
lcontento Feb 14, 2022
3102118
more tests
lcontento Feb 16, 2022
74c6d53
<= instead of < in testing
lcontento Feb 16, 2022
d0cdfec
forgot derivatives
lcontento Feb 16, 2022
394dfb3
fix precomputed sensitivities
lcontento Feb 16, 2022
ea8a1a3
relax tolerances
lcontento Feb 16, 2022
76d441c
fix sensitivities computation for logarithmic splines
lcontento Feb 16, 2022
a549ef4
relax tolerances
lcontento Mar 3, 2022
7dddd72
fix evaluation points for test
lcontento Mar 3, 2022
e872aca
relax tolerances
lcontento Mar 3, 2022
e2c60c6
fix loop
lcontento Mar 3, 2022
4ba2be6
small fixes
lcontento Nov 16, 2022
c775c6b
remove symlinks
lcontento Nov 17, 2022
526a57f
move python files
lcontento Nov 17, 2022
edeb69d
Merge branch 'develop' into python_splines_before_merge
lcontento Nov 17, 2022
88a3df0
post merge fixes
lcontento Nov 17, 2022
4d19fa5
add discard_annotations to import_model_sbml
lcontento Nov 17, 2022
8b1673a
fix small merge mistakes
lcontento Nov 17, 2022
f250595
Merge branch 'develop' into python_splines_before_merge
dweindl Nov 21, 2022
642a70d
regenerate test models
dweindl Nov 21, 2022
7234e73
Fix missing return
dweindl Nov 21, 2022
11538bb
-Werror in debug mode
dweindl Nov 21, 2022
466ed5e
fix NameError: name 'SBMLException' is not defined
dweindl Nov 21, 2022
a34ca15
const
dweindl Nov 21, 2022
4420338
final value tests
lcontento Nov 21, 2022
a8b2141
Merge branch 'python_splines_before_merge' of https://github.com/AMIC…
lcontento Nov 21, 2022
235786a
fix comments
lcontento Nov 21, 2022
f95e491
remove copy&paste leftover
lcontento Nov 21, 2022
5a60f37
make some more methods public
lcontento Nov 21, 2022
354c9f5
compute final values explicitly
lcontento Nov 21, 2022
f7c32e4
fix coefficients_extrapolate indexing
lcontento Nov 21, 2022
3ef2f52
more fixes for extrapolation sensitivity
lcontento Nov 21, 2022
94aa91c
remove unused variables
lcontento Nov 21, 2022
5eefe4f
missing namespace
lcontento Nov 21, 2022
04f228c
Merge remote-tracking branch 'origin/develop' into python_splines_bef…
dweindl Nov 21, 2022
67a9cce
notebook to sphinx doc
dweindl Nov 22, 2022
5b0d60a
Merge branch 'develop' into python_splines_before_merge
dweindl Dec 12, 2022
f53ccac
Merge branch 'develop' into python_splines_before_merge
dweindl Dec 28, 2022
51d663a
Merge branch 'develop' into python_splines_before_merge
lcontento Jan 2, 2023
eee8f67
Merge branch 'develop' into python_splines_before_merge
dweindl Jan 26, 2023
cf885dd
fic horner form
lcontento Mar 13, 2023
d3b1ada
rewrite python tests
lcontento Mar 13, 2023
cf98989
add more C++ tests
lcontento Mar 13, 2023
37c1842
python spline evaluation tests
lcontento Mar 13, 2023
1d680a9
update notebook
lcontento Mar 13, 2023
af11c3b
Merge branch 'python_splines_before_merge' of https://github.com/AMIC…
lcontento Mar 13, 2023
fd43d2f
fix for when slopes are specified
lcontento Mar 14, 2023
6a288ba
specify constant flag
lcontento Mar 24, 2023
e8de440
Merge remote-tracking branch 'origin/develop' into python_splines_bef…
lcontento Mar 27, 2023
f3cd179
change ode_export to de_export
lcontento Mar 27, 2023
97dc78b
fix duplicated test name
lcontento Mar 27, 2023
fa42ce5
try fixing sensitivity of final state with zero derivative and linear…
lcontento Mar 27, 2023
f2ff787
fix final value sensitivity inf in logscale
lcontento Mar 27, 2023
2877657
sensitivity with respect to plist
lcontento Mar 28, 2023
405ec8a
bugfix (C++ indexing is 0-based)
lcontento Mar 28, 2023
69d5516
Merge branch 'develop' into python_splines_before_merge
lcontento Apr 10, 2023
47c3681
Spline example notebooks
lcontento Apr 10, 2023
a99714e
remove leftover long output in notebook
lcontento Apr 11, 2023
2448778
Fixing typos in notebooks and adding symlink for docs
lcontento Apr 11, 2023
c0d69e1
fix typo in spline C++ docstrings
lcontento Apr 11, 2023
0d83deb
add spline notebooks to documentation
lcontento Apr 11, 2023
e967ba9
Expensive tests only for merges to master
dweindl Apr 11, 2023
1c8b363
Remove redundant class - fixes SBML suite?
dweindl Apr 11, 2023
b049635
nb kernel
dweindl Apr 11, 2023
b1e3662
nb kernel
dweindl Apr 11, 2023
8949ca3
merge_group
dweindl Apr 11, 2023
a0dcbfe
cmake
dweindl Apr 11, 2023
b85b30d
ignore-glob
dweindl Apr 12, 2023
7be15d3
..
dweindl Apr 12, 2023
6782d06
..
dweindl Apr 12, 2023
3ad1b11
fo the minimal amount of work in notebooks when running in a Github a…
lcontento Apr 12, 2023
6d287a4
split slow/fast spline tests
lcontento Apr 12, 2023
813cee0
more relaxed tolerances on windows
lcontento Apr 12, 2023
e1687f4
try pip install in notebook
lcontento Apr 13, 2023
66fb700
compute groundtruth only once per call to check_splines_full
lcontento Apr 13, 2023
9019486
add fides package to example notebook
lcontento Apr 13, 2023
4055ba0
precompute data for spline test
lcontento Apr 13, 2023
6cf1ed5
fix path
lcontento Apr 13, 2023
b182e37
split pip pypesto and fide
lcontento Apr 13, 2023
bc69979
use single core engine on github actions
lcontento Apr 13, 2023
9b64881
even less work on Github actions
lcontento Apr 13, 2023
a66e140
even less work whe running Github actions
lcontento Apr 13, 2023
202d2d3
fix unused folder argument
lcontento Apr 14, 2023
d1f7268
fix a possible edge case
lcontento Apr 14, 2023
4c92723
fix problem with unique folders
lcontento Apr 14, 2023
488f794
maybe windows does not like long paths
lcontento Apr 14, 2023
dfdd8db
Update python/sdist/amici/sbml_utils.py
lcontento Apr 14, 2023
1660f8a
Update python/sdist/amici/sbml_utils.py
lcontento Apr 14, 2023
4b58075
Update python/sdist/amici/sbml_utils.py
lcontento Apr 14, 2023
f4c58c4
Update python/sdist/amici/sbml_utils.py
lcontento Apr 14, 2023
2d05e12
Update src/splinefunctions.cpp
lcontento Apr 14, 2023
6d1b605
Update python/sdist/amici/sbml_utils.py
lcontento Apr 14, 2023
c72f009
Update python/sdist/amici/sbml_utils.py
lcontento Apr 14, 2023
ea10ef8
Update python/sdist/amici/sbml_utils.py
lcontento Apr 14, 2023
3a48d2b
Update python/sdist/amici/sbml_utils.py
lcontento Apr 14, 2023
dba2c6d
Update python/sdist/amici/sbml_utils.py
lcontento Apr 14, 2023
3104238
Update include/amici/abstract_model.h
lcontento Apr 14, 2023
8b77e13
small changes
lcontento Apr 14, 2023
f87e12a
Merge branch 'python_splines_before_merge' of https://github.com/AMIC…
lcontento Apr 14, 2023
329ba6c
Update include/amici/abstract_model.h
lcontento Apr 14, 2023
8dbb44a
Update python/tests/splines_utils.py
lcontento Apr 14, 2023
089fbf8
fix uuid
lcontento Apr 14, 2023
bb4dc83
add python type hints
lcontento Apr 14, 2023
fbd3f84
t_extrapolate
lcontento Apr 14, 2023
e57355a
more docstrings
lcontento Apr 14, 2023
9851eb3
more type hints
lcontento Apr 14, 2023
43243fe
more type hints
lcontento Apr 14, 2023
7eb4247
Update python/sdist/amici/sbml_utils.py
lcontento Apr 14, 2023
2f96555
mkdtemp
lcontento Apr 14, 2023
e454f73
Merge branch 'python_splines_before_merge' of https://github.com/AMIC…
lcontento Apr 14, 2023
f303394
Update python/sdist/amici/sbml_utils.py
lcontento Apr 14, 2023
0c65a1e
docstring
lcontento Apr 14, 2023
fccfe81
Merge branch 'python_splines_before_merge' of https://github.com/AMIC…
lcontento Apr 14, 2023
0251333
docstrings
lcontento Apr 14, 2023
38bd351
how to recompute precomputed results for spline tests
lcontento Apr 14, 2023
0aeafe4
Update python/examples/example_splines/ExampleSplines.ipynb
lcontento Apr 14, 2023
8be1236
Update python/examples/example_splines/ExampleSplines.ipynb
lcontento Apr 14, 2023
b62b1b8
notebook suggestions
lcontento Apr 14, 2023
2fc9b1f
move spline plotting to library
lcontento Apr 14, 2023
c172fcc
Merge branch 'develop' into python_splines_before_merge
lcontento Apr 14, 2023
c635f44
add a more informative error when there are no converged starts in CI
lcontento Apr 15, 2023
abd0dab
Merge branch 'develop' into python_splines_before_merge
lcontento Apr 15, 2023
12ee430
Merge branch 'python_splines_before_merge' of https://github.com/AMIC…
lcontento Apr 15, 2023
e966cf5
splines in observables
dweindl Apr 15, 2023
bd5bf0f
No hack?
dweindl Apr 17, 2023
5856bff
address Fabian's comments
lcontento Apr 17, 2023
515af68
Merge branch 'develop' into python_splines_before_merge
lcontento Apr 18, 2023
ee0aee6
finishing touches for assigning splines to species
lcontento Apr 18, 2023
cde382c
more expressive argument names in splines.py
lcontento Apr 18, 2023
d150922
real-world spline examples using species assignment
lcontento Apr 18, 2023
b9f9149
fix non-refactored bits
lcontento Apr 18, 2023
217e348
update example notebook
lcontento Apr 18, 2023
8a168e6
more interesting errors
lcontento Apr 19, 2023
cc4e753
upgrade sympy?
lcontento Apr 19, 2023
4bef57a
dwdw needs the spline
lcontento Apr 19, 2023
2ea49a6
revert debug changes
lcontento Apr 20, 2023
3f49397
try more starts in github
lcontento Apr 20, 2023
18b6210
Binder: update compilers
dweindl Apr 22, 2023
cb47188
Revert "Binder: update compilers"
dweindl Apr 22, 2023
3e539db
py311?
dweindl Apr 22, 2023
4302eff
timeout=600
dweindl Apr 22, 2023
56d3a0b
Revert "py311?"
dweindl Apr 22, 2023
5626ebf
Revert "timeout=600"
dweindl Apr 22, 2023
3c898bc
DBG artifacts
dweindl Apr 24, 2023
89686cd
Revert "DBG artifacts"
dweindl Apr 24, 2023
5f634d9
conservation laws / assignment rules
dweindl Apr 24, 2023
7fee6a4
Merge branch 'develop' into python_splines_before_merge
lcontento Apr 24, 2023
3088f38
notebook update
lcontento Apr 24, 2023
1f7a787
Merge branch 'python_splines_before_merge' of https://github.com/AMIC…
lcontento Apr 24, 2023
3f2c1bf
Merge remote-tracking branch 'origin/develop' into python_splines_bef…
dweindl Apr 25, 2023
c71f3f2
fix doc?
dweindl Apr 25, 2023
154f567
Revert "dwdw needs the spline"
lcontento Apr 25, 2023
9223f1b
increase multistarts for swameye
lcontento Apr 25, 2023
ed6bf29
Merge branch 'develop' into python_splines_before_merge
dweindl May 5, 2023
5e32637
Merge branch 'develop' into python_splines_before_merge
dweindl May 8, 2023
aa37d1a
Merge branch 'develop' into python_splines_before_merge
dweindl May 9, 2023
b58f47f
Merge branch 'develop' into python_splines_before_merge
dweindl May 9, 2023
c46aeaf
Merge branch 'develop' into python_splines_before_merge
dweindl May 9, 2023
3119367
Merge branch 'develop' into python_splines_before_merge
dweindl May 10, 2023
15788d9
Fix deprecation
dweindl May 11, 2023
9eedc54
Fix deprecation
dweindl May 11, 2023
6611947
remove assert
dweindl May 11, 2023
fc3b862
format
dweindl May 11, 2023
480fe63
cleanup
dweindl May 11, 2023
a73ca36
cleanup
dweindl May 11, 2023
1028a5c
Apply suggestions from code review
dweindl May 11, 2023
543446b
Revert "Fix deprecation"
dweindl May 11, 2023
71735b6
Increase timeout
dweindl May 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ add_custom_target(
# Library source files
set(AMICI_SRC_LIST
${CMAKE_SOURCE_DIR}/src/symbolic_functions.cpp
${CMAKE_SOURCE_DIR}/src/splinefunctions.cpp
${CMAKE_SOURCE_DIR}/src/cblas.cpp
${CMAKE_SOURCE_DIR}/src/amici.cpp
${CMAKE_SOURCE_DIR}/src/misc.cpp
Expand Down
44 changes: 40 additions & 4 deletions include/amici/abstract_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "amici/defines.h"
#include "amici/sundials_matrix_wrapper.h"
#include "amici/vector.h"
#include "amici/splinefunctions.h"

#include <sunmatrix/sunmatrix_band.h>
#include <sunmatrix/sunmatrix_dense.h>
Expand Down Expand Up @@ -728,10 +729,11 @@ class AbstractModel {
* @param k constants vector
* @param h Heaviside vector
* @param tcl total abundances for conservation laws
* @param spl spline value vector
*/
virtual void fw(realtype *w, const realtype t, const realtype *x,
const realtype *p, const realtype *k, const realtype *h,
const realtype *tcl);
const realtype *tcl, const realtype *spl);

/**
* @brief Model-specific sparse implementation of dwdp
Expand All @@ -744,11 +746,14 @@ class AbstractModel {
* @param w vector with helper variables
* @param tcl total abundances for conservation laws
* @param stcl sensitivities of total abundances for conservation laws
* @param spl spline value vector
* @param sspl sensitivities of spline values vector
lcontento marked this conversation as resolved.
Show resolved Hide resolved
*/
virtual void fdwdp(realtype *dwdp, const realtype t, const realtype *x,
const realtype *p, const realtype *k, const realtype *h,
const realtype *w, const realtype *tcl,
const realtype *stcl);
const realtype *stcl, const realtype *spl,
const realtype *sspl);

/**
* @brief Model-specific implementation for dwdp, column pointers
Expand Down Expand Up @@ -778,7 +783,8 @@ class AbstractModel {
virtual void fdwdp(realtype *dwdp, const realtype t, const realtype *x,
const realtype *p, const realtype *k, const realtype *h,
const realtype *w, const realtype *tcl,
const realtype *stcl, int ip);
const realtype *stcl, const realtype *spl,
const realtype *sspl, int ip);

/**
* @brief Model-specific implementation of dwdx, data part
Expand All @@ -790,10 +796,12 @@ class AbstractModel {
* @param h Heaviside vector
* @param w vector with helper variables
* @param tcl total abundances for conservation laws
* @param spl spline value vector
*/
virtual void fdwdx(realtype *dwdx, const realtype t, const realtype *x,
const realtype *p, const realtype *k, const realtype *h,
const realtype *w, const realtype *tcl);
const realtype *w, const realtype *tcl,
const realtype *spl);

/**
* @brief Model-specific implementation for dwdx, column pointers
Expand Down Expand Up @@ -833,6 +841,34 @@ class AbstractModel {
* @param dwdw sparse matrix to which rowvals will be written
*/
virtual void fdwdw_rowvals(SUNMatrixWrapper &dwdw);

/**
* @brief Model-specific implementation the spline constructors
lcontento marked this conversation as resolved.
Show resolved Hide resolved
* @param p parameter vector
* @param k constants vector
*/
virtual std::vector<HermiteSpline> fspline_constructors(const realtype *p,
const realtype *k);

/**
* @brief Model-specific implementation the parametric derivatives
* of spline node values
* @param dspline_valuesdp vector to which derivatives will be written
* @param p parameter vector
* @param k constants vector
*/
virtual void fdspline_valuesdp(realtype *dspline_valuesdp,
const realtype *p, const realtype *k);

/**
* @brief Model-specific implementation the parametric derivatives
* of slopevalues at spline nodes
* @param dspline_slopesdp vector to which derivatives will be written
* @param p parameter vector
* @param k constants vector
*/
virtual void fdspline_slopesdp(realtype *dspline_slopesdp,
const realtype *p, const realtype *k);
};

} // namespace amici
Expand Down
18 changes: 18 additions & 0 deletions include/amici/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,24 @@ enum class RDataReporting {
likelihood,
};

/** boundary conditions for splines */
enum class SplineBoundaryCondition {
given = -1,
zeroDerivative = 0,
natural = 1,
naturalZeroDerivative = 2,
periodic = 3,
};

/** extrapolation methods for splines */
enum class SplineExtrapolation {
noExtrapolation = -1,
constant = 0,
linear = 1,
polynomial = 2,
periodic = 3,
};

/**
* Type for function to process warnings or error messages.
*/
Expand Down
35 changes: 29 additions & 6 deletions include/amici/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "amici/simulation_parameters.h"
#include "amici/model_dimensions.h"
#include "amici/model_state.h"
#include "amici/splinefunctions.h"

#include <map>
#include <memory>
Expand Down Expand Up @@ -181,6 +182,13 @@ class Model : public AbstractModel, public ModelDimensions {
*/
void initializeStateSensitivities(AmiVectorArray &sx, const AmiVector &x);

/**
* @brief Initialization of spline functions
*/
void initializeSplines();

void initializeSplineSensitivities();

/**
* @brief Initialize the Heaviside variables `h` at the initial time `t0`.
*
Expand Down Expand Up @@ -642,7 +650,7 @@ class Model : public AbstractModel, public ModelDimensions {
throw AmiException("Mismatch in conservation law sensitivity size");
state_ = state;
};

/**
* @brief Sets the estimated lower boundary for sigma_y. When :meth:`setAddSigmaResiduals` is
* activated, this lower boundary must ensure that log(sigma) + min_sigma > 0.
Expand All @@ -651,15 +659,15 @@ class Model : public AbstractModel, public ModelDimensions {
void setMinimumSigmaResiduals(double min_sigma) {
min_sigma_ = min_sigma;
}

/**
* @brief Gets the specified estimated lower boundary for sigma_y.
* @return lower boundary
*/
realtype getMinimumSigmaResiduals() const {
return min_sigma_;
}

/**
* @brief Specifies whether residuals should be added to account for parameter dependent sigma.
*
Expand All @@ -673,7 +681,7 @@ class Model : public AbstractModel, public ModelDimensions {
void setAddSigmaResiduals(bool sigma_res) {
sigma_res_ = sigma_res;
}

/**
* @brief Checks whether residuals should be added to account for parameter dependent sigma.
* @return sigma_res
Expand Down Expand Up @@ -1589,6 +1597,18 @@ class Model : public AbstractModel, public ModelDimensions {
void fdJrzdsigma(const int ie, const int nroots, const realtype t,
const AmiVector &x, const ExpData &edata);

/**
* @brief Spline functions
* @param t timepoint
*/
void fspl(realtype t);

/**
* @brief Parametric derivatives of splines functions
* @param t timepoint
*/
void fsspl(realtype t);

/**
* @brief Compute recurring terms in xdot.
* @param t Timepoint
Expand Down Expand Up @@ -1713,6 +1733,9 @@ class Model : public AbstractModel, public ModelDimensions {
*/
ModelStateDerived derived_state_;

/** Storage for splines of the model */
std::vector<HermiteSpline> splines_;

/** index indicating to which event an event output belongs */
std::vector<int> z2event_;

Expand Down Expand Up @@ -1743,10 +1766,10 @@ class Model : public AbstractModel, public ModelDimensions {
* checked for finiteness
*/
bool always_check_finite_ {false};

/** indicates whether sigma residuals are to be added for every datapoint */
bool sigma_res_ {false};

/** offset to ensure positivity of sigma residuals, only has an effect when `sigma_res_` is `true` */
realtype min_sigma_ {50.0};

Expand Down
3 changes: 3 additions & 0 deletions include/amici/model_dimensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ struct ModelDimensions {
/** Number of event outputs in the unaugmented system */
int nztrue{0};

/** numer of spline functions in the model */
int nspl{0};

/** Number of events */
int ne{0};

Expand Down
6 changes: 6 additions & 0 deletions include/amici/model_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ struct ModelState {
* (dimension: nplist)
*/
std::vector<int> plist;

/** temporary storage for spline values */
std::vector<realtype> spl_;
};


Expand Down Expand Up @@ -263,6 +266,9 @@ struct ModelStateDerived {
*/
std::vector<realtype> deltaqB_;

/** temporary storage for sensitivity values of splines */
SUNMatrixWrapper sspl_;

/** temporary storage of positified state variables according to
* stateIsNonNegative (dimension: `nx_solver`) */
AmiVector x_pos_tmp_ {0};
Expand Down
Loading