CVODE to Joy

36 views
Skip to first unread message

Michael Betancourt

unread,
Nov 27, 2015, 7:38:59 AM11/27/15
to stan development mailing list
In https://github.com/stan-dev/math/tree/feature/issue-175-add-cvode please
find a working implementation of CVODE with a custom banded Jacobian.

The relevant function to call is
https://github.com/stan-dev/math/blob/feature/issue-175-add-cvode/stan/math/prim/arr/functor/integrate_ode_cvode.hpp
which should be trivial to expose to the language.

The implementation is also thoroughly tested
https://github.com/stan-dev/math/blob/feature/issue-175-add-cvode/test/unit/math/prim/arr/functor/coupled_ode_system_cvode_test.cpp
https://github.com/stan-dev/math/blob/feature/issue-175-add-cvode/test/unit/math/prim/arr/functor/integrate_ode_cvode_test.cpp
https://github.com/stan-dev/math/blob/feature/issue-175-add-cvode/test/unit/math/rev/arr/functor/coupled_ode_system_cvode_test.cpp
https://github.com/stan-dev/math/blob/feature/issue-175-add-cvode/test/unit/math/rev/arr/functor/integrate_ode_cvode_test.cpp
https://github.com/stan-dev/math/blob/feature/issue-175-add-cvode/test/unit/math/rev/arr/functor/integrate_ode_cvode_grad_test.cpp

The only complication that prevents this from being merged is that it requires
the CVODE shared library to have been built and installed in /usr/local/lib
(see lines 29 and 30 of the makefile, https://github.com/stan-dev/math/blob/feature/issue-175-add-cvode/makefile).
The installation issue is going to be a pain to resolve and I’m not sure if there’s any clean way to propagate
this implementation into the interfaces without users being able to checkout this branch and build the interfaces
themselves.

Ben Goodrich

unread,
Nov 27, 2015, 10:29:03 AM11/27/15
to stan development mailing list
On Friday, November 27, 2015 at 7:38:59 AM UTC-5, Michael Betancourt wrote:
The only complication that prevents this from being merged is that it requires
the CVODE shared library to have been built and installed in /usr/local/lib
(see lines 29 and 30 of the makefile, https://github.com/stan-dev/math/blob/feature/issue-175-add-cvode/makefile).
The installation issue is going to be a pain to resolve and I’m not sure if there’s any clean way to propagate
this implementation into the interfaces without users being able to checkout this branch and build the interfaces
themselves.

Can you say more about why it has to go into /usr/local/lib ? The current R package that provides an interface to it

https://cran.r-project.org/src/contrib/Rsundials_1.6.tar.gz

doesn't seem to have any special requirements and includes the cveode stuff in its /src and /src/include directories.

> install.packages("Rsundials")
trying URL
'https://cran.r-project.org/src/contrib/Rsundials_1.6.tar.gz'
Content type 'application/x-gzip' length 510137 bytes (498 KB)
==================================================
downloaded
498 KB

* installing *source* package Rsundials ...
** package Rsundials successfully unpacked and MD5 sums checked
** libs
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c cvodea.c -o cvodea.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c cvodea_io.c -o cvodea_io.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c cvodes.c -o cvodes.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c cvodes_band.c -o cvodes_band.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c cvodes_bandpre.c -o cvodes_bandpre.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c cvodes_bbdpre.c -o cvodes_bbdpre.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c cvodes_dense.c -o cvodes_dense.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c cvodes_diag.c -o cvodes_diag.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c cvodes_io.c -o cvodes_io.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c cvodes_spbcgs.c -o cvodes_spbcgs.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c cvodes_spgmr.c -o cvodes_spgmr.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c cvodes_spils.c -o cvodes_spils.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c cvodes_sptfqmr.c -o cvodes_sptfqmr.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c fnvector_serial.c -o fnvector_serial.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c ida.c -o ida.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c ida_band.c -o ida_band.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c ida_bbdpre.c -o ida_bbdpre.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c ida_dense.c -o ida_dense.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c ida_ic.c -o ida_ic.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c ida_io.c -o ida_io.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c ida_spbcgs.c -o ida_spbcgs.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c ida_spgmr.c -o ida_spgmr.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c ida_spils.c -o ida_spils.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c ida_sptfqmr.c -o ida_sptfqmr.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c nvector_serial.c -o nvector_serial.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c sundials_band.c -o sundials_band.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c sundials_cvodes.c -o sundials_cvodes.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c sundials_dense.c -o sundials_dense.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c sundials_ida.c -o sundials_ida.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c sundials_iterative.c -o sundials_iterative.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c sundials_math.c -o sundials_math.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c sundials_nvector.c -o sundials_nvector.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c sundials_smalldense.c -o sundials_smalldense.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c sundials_spbcgs.c -o sundials_spbcgs.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c sundials_spgmr.c -o sundials_spgmr.o
gcc
-5 -I/opt/r-devel/include -DNDEBUG  -I/usr/local/include   -w -fpic  -g -O2  -c sundials_sptfqmr.c -o sundials_sptfqmr.o
gcc
-5 -shared -L/usr/local/lib -o Rsundials.so cvodea.o cvodea_io.o cvodes.o cvodes_band.o cvodes_bandpre.o cvodes_bbdpre.o cvodes_dense.o cvodes_diag.o cvodes_io.o cvodes_spbcgs.o cvodes_spgmr.o cvodes_spils.o cvodes_sptfqmr.o fnvector_serial.o ida.o ida_band.o ida_bbdpre.o ida_dense.o ida_ic.o ida_io.o ida_spbcgs.o ida_spgmr.o ida_spils.o ida_sptfqmr.o nvector_serial.o sundials_band.o sundials_cvodes.o sundials_dense.o sundials_ida.o sundials_iterative.o sundials_math.o sundials_nvector.o sundials_smalldense.o sundials_spbcgs.o sundials_spgmr.o sundials_sptfqmr.o
installing to
/opt/r-devel/library/Rsundials/libs
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (Rsundials)

Ben

Michael Betancourt

unread,
Nov 27, 2015, 10:36:52 AM11/27/15
to stan...@googlegroups.com

Can you say more about why it has to go into /usr/local/lib ?

That’s just where the makefile is hardcoded to look for it — it’s not
an absolute requirement.

Ben Goodrich

unread,
Nov 27, 2015, 11:05:30 AM11/27/15
to stan development mailing list

 In which case, can we put it under lib/ ?

Michael Betancourt

unread,
Nov 27, 2015, 11:32:02 AM11/27/15
to stan...@googlegroups.com
Not going to work on recent versions of OS X and no idea about Windows.
Ultimately we’re going to need some kind of CVODE installation step which
is going to take some thinking.

--
You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bob Carpenter

unread,
Nov 27, 2015, 5:37:32 PM11/27/15
to stan...@googlegroups.com
Is the problem with OS X that you can't write into
those locations?

Why can't we build it ourselves in a location of our
choosing?

- Bob

Michael Betancourt

unread,
Nov 27, 2015, 6:10:46 PM11/27/15
to stan...@googlegroups.com
In the most recent versions of OS X none of the base
directories are user-writable except for /usr/local.

I don’t think there’s any reason not to have something
flexible and customizable, it’ll just require some careful
planning to work across interfaces and architectures.

I was just happy to get CVODE working!

Bob Carpenter

unread,
Nov 30, 2015, 3:16:19 PM11/30/15
to stan...@googlegroups.com
You definitely did the heavy lifting on this one.

Hopefully Daniel can figure out the builds and we'll be good
to go. Will it be possible to just do the install locally
and call it directly rather than through a PATH so it won't
interfere with any other potential installs?

- Bob
Reply all
Reply to author
Forward
0 new messages