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

Feature/adjoint odes #1905

Merged
merged 236 commits into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
236 commits
Select commit Hold shift + click to select a range
0389837
Revert "Revert back to forward mode sensitivity for cvodes (to make s…
bbbales2 May 22, 2020
7811368
Merge branch 'feature/parameter-pack-odes' into feature/adjoint-odes
bbbales2 May 22, 2020
fb36702
Merge remote-tracking branch 'origin/develop' into feature/adjoint-od…
wds15 Jan 2, 2021
27fbb73
add adjoint integrator first version
wds15 Jan 2, 2021
c480212
adding sho tests
wds15 Jan 2, 2021
942dd51
reroute ode_adams to ode_bdf_adjoint
wds15 Jan 2, 2021
d86cbc9
bump
wds15 Jan 2, 2021
6383fa3
introduce plain_type_t
wds15 Jan 3, 2021
f978440
fix eigen expression stuff for cvodes_integrator_adjoint
wds15 Jan 3, 2021
79cfeca
Changed how tuples initialized in ODE adjoint memory
bbbales2 Jan 3, 2021
a65573c
Merge branch 'feature/adjoint-odes-v2' of https://github.com/stan-dev…
wds15 Jan 3, 2021
cdddc43
more expression things
wds15 Jan 3, 2021
c27331b
Merge branch 'feature/adjoint-odes-v2' into feature/adjoint-odes
wds15 Jan 3, 2021
c4f530a
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 3, 2021
37ec72c
add simple benchmark in the form of a test
wds15 Jan 3, 2021
91aaaa2
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 3, 2021
64acf4a
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 3, 2021
ccc5026
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 3, 2021
edea9b0
recycle argument vari's
wds15 Jan 3, 2021
c81e6aa
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 3, 2021
418c0c1
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 3, 2021
fd9d531
fix
wds15 Jan 4, 2021
bd35bd9
add plain_type_t
wds15 Jan 4, 2021
b649c25
Merge commit 'b2eaa329ee3427245dbe06482ee937569cb6032f' into HEAD
yashikno Jan 4, 2021
e0a4e40
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 4, 2021
b6b8782
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 4, 2021
a15e58a
bump
wds15 Jan 4, 2021
2adfcc0
route calls correctly
wds15 Jan 4, 2021
b15c7b1
bump
wds15 Jan 4, 2021
47abeb8
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 4, 2021
2a2bce5
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 5, 2021
cfcc616
too much work error message
wds15 Jan 5, 2021
83d7c41
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 5, 2021
78f87e0
bump
wds15 Jan 5, 2021
c940514
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 5, 2021
9da66fb
Merge commit '7d5f626b55d822f2544138cc5fbeabbd4d86a92c' into HEAD
yashikno Jan 5, 2021
6be8f54
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 5, 2021
6fff468
add maximal number of steps option to backward solve
wds15 Jan 6, 2021
e553c23
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 6, 2021
a09696b
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 6, 2021
7e78900
add scaling test
wds15 Jan 7, 2021
724ddec
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 7, 2021
2d1a65d
Merge commit 'aa1c1c48372fb8e60da9ca7af6f0403b83f99d9d' into HEAD
yashikno Jan 7, 2021
4bb9482
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 7, 2021
c4e8280
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 7, 2021
a1fd530
align tolerances
wds15 Jan 7, 2021
72cbc3f
fix scaling benchmark
wds15 Jan 11, 2021
12f9b53
Merge commit '3b0ddba22615efe779da52f7185ec15863b0a7e6' into HEAD
yashikno Jan 11, 2021
4d68049
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 11, 2021
94012ea
Set adjoints to 1 in benchmark test.
charlesm93 Jan 11, 2021
6fa6208
Merge commit '222e1ad9426ba13c364a8a65d2f3958104047b54' into HEAD
yashikno Jan 11, 2021
14dc05d
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 11, 2021
9a87420
add toy model
wds15 Jan 13, 2021
67eb800
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 13, 2021
1ce94e2
Merge commit '7085ef69bdb399db7d918240659f56305885a2fd' into HEAD
yashikno Jan 13, 2021
c5509e7
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 13, 2021
4934995
fix
wds15 Jan 13, 2021
89b60fd
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 13, 2021
9926246
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 13, 2021
999f766
fix cvodes init / reinit logic
wds15 Jan 13, 2021
6480b4d
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 13, 2021
90e6f93
Merge commit '6ac9c2e5ab14bb53a5f4a0e31d3a783015fe1dd7' into HEAD
yashikno Jan 13, 2021
12b8408
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 13, 2021
1d85054
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 13, 2021
18ff5b3
add sum test
wds15 Jan 14, 2021
964e87e
Merge commit 'd2e485cf1597d1a30fbfdf9330540033c432683c' into HEAD
yashikno Jan 14, 2021
71cefa1
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 14, 2021
d1280cf
fix linked mass flow example
wds15 Jan 14, 2021
1615e23
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 14, 2021
61aa6f8
add SBC codes
weberse2 Jan 17, 2021
4cbdb04
bump
weberse2 Jan 17, 2021
ff1571f
adding eval and some notes on how the math works out
wds15 Jan 18, 2021
ac36f82
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 18, 2021
f49a7b3
Merge commit '7a0d613e607fecd3b6f039dca796456559f18856' into HEAD
yashikno Jan 18, 2021
ed3ce6e
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Jan 18, 2021
d36b62f
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Jan 18, 2021
5c47c05
Merge remote-tracking branch 'origin/develop' into feature/adjoint-odes
wds15 Feb 22, 2021
9735ffd
revert adams back to actual adams
wds15 Feb 22, 2021
920fc7c
make signature work as decribed in design doc
wds15 Feb 22, 2021
59eb1d8
make first test work with new function
wds15 Feb 22, 2021
1c4482c
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Feb 22, 2021
3157e49
make vector absolute tolerance work and expose solver choice
wds15 Feb 23, 2021
0acc62e
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Feb 23, 2021
1eda2f9
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Feb 23, 2021
475216e
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Feb 24, 2021
1faf260
add tol call
wds15 Feb 24, 2021
9f2b1c7
Merge commit '94e16d87d9cb464b4e05b8914f6cbbc8ea20ac0b' into HEAD
yashikno Feb 24, 2021
5d74d68
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Feb 24, 2021
6a1efb2
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Feb 24, 2021
3413734
add various benchmarks
wds15 Feb 26, 2021
ff87fd5
tune sparse matrix support
wds15 Mar 2, 2021
db633c2
Merge commit '5533797fb87828108b4412e80537084fc168b092' into HEAD
yashikno Mar 2, 2021
69e2e91
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Mar 2, 2021
4a8afdf
disable sparse matrix stuff on CVODES and switch to new function name…
wds15 Mar 4, 2021
d8ce935
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Mar 4, 2021
73041c1
enable more tests
wds15 Mar 4, 2021
9e30580
Merge commit 'b7eff4c4d5d0f6b55523be91e4b757c8b766d676' into HEAD
yashikno Mar 4, 2021
6e238d7
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Mar 4, 2021
ee94ed3
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Mar 4, 2021
efba64e
use vector for abs_tol_b
rok-cesnovar Mar 5, 2021
6db3dad
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Mar 5, 2021
024e94a
fix test model
rok-cesnovar Mar 5, 2021
4450cca
Switch to reference types
bbbales2 Mar 6, 2021
4c478fd
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Mar 7, 2021
149c649
align defaults of simplified ode_adjoint_tol interface with doc
weberse2 Mar 11, 2021
b31a728
revert to hermite polynomials which appear more stable
weberse2 Mar 11, 2021
fd74b60
bump examples
weberse2 Mar 11, 2021
a382fee
fix
weberse2 Mar 11, 2021
d72dd8a
align notation with user guide
weberse2 Mar 12, 2021
217f077
export all tolerances for example
weberse2 Mar 15, 2021
5f0f2b7
make use of Eigen vector expressions and use coeff indexing
weberse2 Mar 15, 2021
0e90995
put apply call in separate function to clean code
weberse2 Mar 15, 2021
86f586f
Merge commit '8a3ebcb864c92343fda00360278013622e171bc0' into HEAD
yashikno Mar 15, 2021
f4bde7e
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Mar 15, 2021
b315e77
Merge branch 'feature/adjoint-odes' of https://github.com/stan-dev/ma…
wds15 Mar 22, 2021
681ab4f
Merge remote-tracking branch 'origin/develop' into feature/adjoint-odes
wds15 Mar 31, 2021
4738307
Merge remote-tracking branch 'origin/develop' into feature/adjoint-odes
wds15 Apr 15, 2021
338de15
backport adjoint code and integrate into testing framework in a first…
wds15 Apr 15, 2021
4abf989
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Apr 15, 2021
c2e9e39
cpplint
wds15 Apr 16, 2021
f637c3a
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 Apr 16, 2021
9390361
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Apr 16, 2021
74f6e0c
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 Apr 16, 2021
527fa2e
cpplint
wds15 Apr 16, 2021
4377411
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Apr 16, 2021
3e2e653
lint
wds15 Apr 19, 2021
5c0179a
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 Apr 19, 2021
8f4aa86
refactor adjoint solver to not use extra memory object
wds15 Apr 22, 2021
b393615
some more simplifcations
wds15 Apr 22, 2021
1de856d
move build_varis function inside cvodes_integrator_adjoint
wds15 Apr 22, 2021
db528e0
undo last change
wds15 Apr 22, 2021
a710e79
Merge commit 'eae2d6d1f526e31f97286829737329d789897544' into HEAD
yashikno Apr 22, 2021
bbb3bd2
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Apr 22, 2021
d0e76a3
make benchmarks work with newer interface
wds15 Apr 22, 2021
bcd09f6
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 Apr 22, 2021
5ee531a
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Apr 22, 2021
2b887ca
remove obsolete test
wds15 Apr 22, 2021
abbdebf
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 Apr 22, 2021
7e02e5d
get rid of helper build_vari and replace it with overload withing var…
wds15 Apr 22, 2021
dbd07ea
mark methods as const where possible
wds15 Apr 22, 2021
0d46d07
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Apr 22, 2021
643c602
reorder freeing
wds15 Apr 22, 2021
7afcd30
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 Apr 22, 2021
fa3dbb2
port over changes from review3 branch
wds15 Apr 26, 2021
9d55a24
mark functions const as appropiate
wds15 Apr 26, 2021
7b6dd5e
more merging from review3
wds15 Apr 26, 2021
ace3931
optimize ts only var case
wds15 Apr 26, 2021
a314b0a
Merge commit 'f1905f68276b9cc578bb1c7ab3f8e42266e0074a' into HEAD
yashikno Apr 26, 2021
6e10a7d
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Apr 26, 2021
a836ff6
headers compliance
wds15 Apr 27, 2021
efe107f
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 Apr 27, 2021
1654918
update zero_adjoints test
SteveBronder Apr 27, 2021
c5b8b71
Merge remote-tracking branch 'origin/develop' into feature/adjoint-odes
SteveBronder Apr 27, 2021
6eff162
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Apr 27, 2021
1641cdb
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 Apr 27, 2021
d99f69e
remove obsolete benchmarks
wds15 Apr 27, 2021
e8138b8
delete benchmark R code and move ode functor into chainable_alloc cla…
wds15 Apr 27, 2021
d14f9f0
cleanups & added some more inline & constexpr as appropiate
wds15 Apr 27, 2021
875082b
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Apr 27, 2021
fd6fd13
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 Apr 28, 2021
c619587
fix memory issues
wds15 Apr 28, 2021
ee27184
Merge commit '2e6fdbaef13d208d47c69c8349a258bd65dd2eb7' into HEAD
yashikno Apr 28, 2021
0150ed6
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Apr 28, 2021
bd6073a
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 Apr 28, 2021
273a82b
some more const declarations
wds15 Apr 28, 2021
c6510f8
cleanup
wds15 Apr 28, 2021
18ecc0d
fix recover memory issues of ode test framework
wds15 Apr 28, 2021
a2af67d
fix leak in coupled ode system and move the nested to be local in the…
SteveBronder Apr 28, 2021
62281d2
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Apr 28, 2021
e721414
adding extra bad tests for ode_adjoint_tol_ctl interface
wds15 Apr 28, 2021
976f237
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 Apr 28, 2021
c513e94
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot Apr 28, 2021
c645587
fix cpplint error
SteveBronder Apr 28, 2021
8db9c2e
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 May 1, 2021
ab4acbe
Update stan/math/rev/functor/cvodes_integrator_adjoint.hpp
wds15 May 1, 2021
7f87d1c
Merge commit 'eec0ad1dffa5906e7717db9afac675171260ce49' into HEAD
yashikno May 1, 2021
ea7e808
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot May 1, 2021
9ec431a
Update stan/math/rev/functor/cvodes_integrator_adjoint.hpp
wds15 May 1, 2021
2adc594
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 May 1, 2021
7d914d1
review comments
wds15 May 1, 2021
f0104fc
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot May 1, 2021
3ab73f1
update adjoint ode to not have to make seperate vari
SteveBronder May 3, 2021
ba82ee4
remove num_vars
SteveBronder May 3, 2021
784be28
remove num_vars
SteveBronder May 3, 2021
6015c6b
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 May 4, 2021
894e55b
Merge remote-tracking branch 'origin/develop' into review/ode-adjoint4
SteveBronder May 4, 2021
528441e
Merge remote-tracking branch 'origin/develop' into feature/adjoint-odes
SteveBronder May 4, 2021
fb84cfe
Merge branch 'review/ode-adjoint4' into feature/adjoint-odes
SteveBronder May 4, 2021
3f91c24
more testing
wds15 May 4, 2021
a5b7b9f
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 May 4, 2021
19774a2
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot May 4, 2021
8a4525a
doc and review comments
wds15 May 4, 2021
13b7224
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 May 4, 2021
eb62f8c
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot May 4, 2021
12b4a92
move functor into deallocated solve object
wds15 May 4, 2021
d779c7a
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 May 4, 2021
c0fa201
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot May 4, 2021
1e1602f
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 May 4, 2021
2bf6d94
fix get
SteveBronder May 4, 2021
49ad007
Merge branch 'feature/adjoint-odes' of github.com:stan-dev/math into …
SteveBronder May 4, 2021
79f0970
return value for const ref input for get()
SteveBronder May 4, 2021
46412b1
return value for scalar const ref in get()
SteveBronder May 4, 2021
e1b7960
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 May 5, 2021
ff16c04
fix tests (hopefully)
wds15 May 5, 2021
0c42867
Merge remote-tracking branch 'origin/develop' into feature/adjoint-odes
SteveBronder May 7, 2021
3320504
1. Cleaning up the actual functions these are called from in order to…
SteveBronder May 9, 2021
0b73247
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot May 9, 2021
8612ac6
remove extra whitespace for cpplint
SteveBronder May 9, 2021
cf07e1a
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 May 10, 2021
68c3f88
address review comments (split tests, test for no vari on stack when …
wds15 May 10, 2021
828f409
save function name in a string
wds15 May 10, 2021
cc488c0
register solver adjoint only in case of AD
wds15 May 10, 2021
e5ad9c1
optimize case when only ts is a var
wds15 May 10, 2021
459d64b
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot May 10, 2021
3bedb86
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 May 10, 2021
0749581
nest adjoint ODE integrator vari call for double only case
wds15 May 11, 2021
a83fbd6
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot May 11, 2021
2f618c9
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 May 11, 2021
8b01a90
make use of adjoint_of where it works
wds15 May 11, 2021
437791c
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot May 11, 2021
ae9521a
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 May 11, 2021
c26a82f
fix
wds15 May 11, 2021
d88e021
fix tests
wds15 May 11, 2021
ba01fad
improve error messages
wds15 May 15, 2021
826e0c9
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot May 15, 2021
86d32bf
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 May 15, 2021
784226c
revert harmonic oscillator
wds15 May 16, 2021
69158dd
make Eigen inputs expression compatible
wds15 May 16, 2021
8d71067
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot May 16, 2021
1b00008
move ode argument tuple into the cvodes_solvers object
wds15 May 16, 2021
3ef833f
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 May 16, 2021
67c7c8f
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot May 16, 2021
03d50c6
add in decay_t again as before
wds15 May 16, 2021
de69763
Merge branch 'feature/adjoint-odes' of ssh://github.com/stan-dev/math…
wds15 May 16, 2021
630e1ed
review comments
wds15 May 16, 2021
01c9fa1
[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.0…
stan-buildbot May 16, 2021
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
154 changes: 154 additions & 0 deletions ode-adjoint/linked-mass-flow-buggy.stan
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
functions {

vector linked_mass_flow(real t, vector y,
vector kt, vector e50, vector k12, vector k21) {

int num_main_states = num_elements(kt);
int num_states = 2 * num_main_states;

vector[num_states] dydt;
vector[num_main_states] ksat;

for (i in 1:num_main_states) {
int m = 2 * (i-1) + 1; // main state
int a = m + 1; // auxilary state
ksat[i] = kt[i] * y[m] / (y[m] + e50[i]);

dydt[m] = -ksat[i] * y[m] - k12[i] * y[m] + k21[i] * y[a];
dydt[a] = +k12[i] * y[m] - k21[i] * y[a];

if (i != 1) {
dydt[m] += ksat[i-1] * y[2 * (i - 1) + 1];
}
}
return dydt;

}

vector sample_vector_rng(real m, real s, int N) {
vector[N] sample;
for(i in 1:N)
sample[i] = normal_rng(m, s);
return sample;
}

vector[] simulate_mean(real t0, vector log_a0, real[] ts, int adjoint_integrator,
real rel_tol, real abs_tol, int max_num_steps,
vector log_kt, vector log_e50, vector log_k12, vector log_k21) {
int num_sim = num_elements(ts);
int num_states = num_elements(log_a0);
vector[num_states] y[num_sim];

if(adjoint_integrator) {
y = ode_adams_tol(linked_mass_flow, exp(log_a0), t0, ts, rel_tol, abs_tol, max_num_steps,
exp(log_kt), exp(log_e50), exp(log_k12), exp(log_k21));
} else {
y = ode_bdf_tol(linked_mass_flow, exp(log_a0), t0, ts, rel_tol, abs_tol, max_num_steps,
exp(log_kt), exp(log_e50), exp(log_k12), exp(log_k21));
}

return y;
}

}
data {
real<lower=0> rel_tol;
real<lower=0> abs_tol;
int<lower=0,upper=1> adjoint_integrator;
int<lower=1> max_num_steps;
int<lower=1> system_size;
int<lower=1> num_obs;
real<lower=0> sigma_sim;
real<lower=0> sigma_y;
}
transformed data {
int num_states = 2 * system_size;

vector[system_size] log_kt_ = sample_vector_rng(0.0, sigma_sim, system_size);
vector[system_size] log_e50_ = sample_vector_rng(0.0, sigma_sim, system_size);
vector[system_size] log_k12_ = sample_vector_rng(0.0, sigma_sim, system_size);
vector[system_size] log_k21_ = sample_vector_rng(0.0, sigma_sim, system_size);
vector[system_size] log_sigma_y_ = sample_vector_rng(0.0, sigma_y, system_size);
vector[num_states] log_a0_ = sample_vector_rng(0.0, sigma_sim, num_states);
vector[num_states] y_[num_obs];
real ts[num_obs];
real t0 = 0.0;

ts[1] = 1.0;
for(i in 2:num_obs) {
ts[i] = 1.5 * ts[i-1];
}

y_ = simulate_mean(t0, log_a0_, ts, 0, rel_tol, abs_tol, max_num_steps,
log_kt_, log_e50_, log_k12_, log_k21_);

for(i in 1:num_obs) {
for(j in 1:system_size) {
int m = 2*(j-1) + 1;
y_[i,m] = lognormal_rng(log(y_[i,m]+1E-3), exp(log_sigma_y_[j]));
}
}

if(adjoint_integrator) {
print("Using bdf_adjoint integrator.");
} else {
print("Using bdf integrator.");
}
print("relative tolerance: ", rel_tol);
print("absolute tolerance: ", abs_tol);
print("maximum number of steps: ", max_num_steps);
print("number of time points: ", num_obs);
print("system size: ", system_size);
print("time points: ", ts);
print("y_: ", y_);
}
parameters {
vector[system_size] log_kt;
vector[system_size] log_e50;
vector[system_size] log_k12;
vector[system_size] log_k21;
vector[system_size] log_sigma_y;
vector[num_states] log_a0;
}
transformed parameters {
}
model {
vector[num_states] mu[num_obs] = simulate_mean(t0, log_a0, ts, adjoint_integrator, rel_tol, abs_tol, max_num_steps,
log_kt, log_e50, log_k12, log_k21);

target += normal_lpdf(log_kt| 0.0, sigma_sim);
target += normal_lpdf(log_e50| 0.0, sigma_sim);
target += normal_lpdf(log_k12| 0.0, sigma_sim);
target += normal_lpdf(log_k21| 0.0, sigma_sim);
target += normal_lpdf(log_a0| 0.0, sigma_sim);
target += normal_lpdf(log_sigma_y| 0.0, sigma_y);

for(j in 1:system_size) {
int m = 2*(j-1) + 1;
target += lognormal_lpdf(to_vector(y_[:,m])| log(to_vector(mu[:,m])+1E-3), exp(log_sigma_y[j]));
}
}
generated quantities {
int rank_log_kt[system_size];
int rank_log_e50[system_size];
int rank_log_k12[system_size];
int rank_log_k21[system_size];
int rank_log_sigma_y[system_size];
int rank_log_a0[system_size];
vector[system_size] bias_log_kt = log_kt - log_kt_;
vector[system_size] bias_log_e50 = log_e50 - log_e50_;
vector[system_size] bias_log_k12 = log_k12 - log_k12_;
vector[system_size] bias_log_k21 = log_k21 - log_k21_;
vector[system_size] bias_log_sigma_y = log_sigma_y - log_sigma_y_;
vector[system_size] bias_log_a0 = log_a0 - log_a0_;

for(i in 1:system_size) {
rank_log_kt[i] = (log_kt[i] > log_kt_[i] ? 1 : 0);
rank_log_e50[i] = (log_e50[i] > log_e50_[i] ? 1 : 0);
rank_log_k12[i] = (log_k12[i] > log_k12_[i] ? 1 : 0);
rank_log_k21[i] = (log_k21[i] > log_k21_[i] ? 1 : 0);
rank_log_sigma_y[i] = (log_sigma_y[i] > log_sigma_y_[i] ? 1 : 0);
rank_log_a0[i] = (log_a0[i] > log_a0_[i] ? 1 : 0);
}

}
84 changes: 84 additions & 0 deletions ode-adjoint/linked-mass-flow.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
##install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

library(cmdstanr)
library(posterior)
library(bayesplot)
color_scheme_set("brightblue")

set_cmdstan_path("~/work/cmdstan")

stan_model_file <- "linked-mass-flow.stan"

mod <- cmdstan_model(stan_model_file)

base_data <- list(rel_tol=1e-6,
abs_tol=1e-6,
max_num_steps=10000,
adjoint_integrator=0,
system_size=2,
num_obs=8,
sigma_sim=2.0,
sigma_y=0.2)

run_benchmark <- function(..., num_iter=250, adapt_delta=0.8) {
fit_args <- list(...)
fit_data <- modifyList(base_data, fit_args)
print(str(fit_data))
fit <- mod$sample(
data = fit_data,
iter_warmup = num_iter,
iter_sampling = num_iter,
seed = 123,
chains = 1,
parallel_chains = 1,
refresh = round(num_iter/5),
save_warmup=TRUE,
adapt_delta=adapt_delta
##verbose=TRUE
)
fit
}

bdf_fit <- run_benchmark(adjoint_integrator=0)
adjoint_fit <- run_benchmark(adjoint_integrator=1)

if(FALSE) {
adjoint_fit_2 <- run_benchmark(adjoint_integrator=1, adapt_delta=0.65)
adjoint_fit_3 <- run_benchmark(adjoint_integrator=1, adapt_delta=0.95)
adjoint_fit_4 <- run_benchmark(adjoint_integrator=1, abs_tol=1E-10, rel_tol=1E-10)
}

summarize_benchmark <- function(fit) {
sdiag_all <- fit$sampler_diagnostics(inc_warmup=TRUE)
sdiag_main <- fit$sampler_diagnostics(inc_warmup=FALSE)

num_divergent <- sum(sdiag_main[,,"divergent__"])
accept_stat <- mean(sdiag_main[,,"accept_stat__"])
treedepth <- mean(sdiag_main[,,"treedepth__"])
num_leaps <- sum(sdiag_all[,,"n_leapfrog__"])
fit_time <- fit$time()$total

ess_speed <- as.vector(fit$summary("lp__")[1,c("ess_bulk", "ess_tail")]) / fit_time
lp_est <- as.vector(fit$summary("lp__"))

list(num_leaps=num_leaps, time=fit_time, time_per_leap=1E3 * fit_time / num_leaps,
step_size=fit$metadata()$step_size_adaptation,
num_divergent=num_divergent, accept_stat=accept_stat, treedepth=treedepth,
ess_lp_speed=ess_speed, lp_est=lp_est)
}

mcmc_rhat(rhat = rhat(bdf_fit)) + yaxis_text(hjust = 0)

str(summarize_benchmark(bdf_fit))
str(summarize_benchmark(adjoint_fit))


str(summarize_benchmark(adjoint_fit_2))
str(summarize_benchmark(adjoint_fit_3))

bdf_fit$metadata()

bdf_fit$time()


bdf_fit$summary("lp__")
Loading