Tom
Not in depth. I'll try that today.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.
On Thu, 2015-05-21 at 09:58 -0400, Daniel Lee wrote:
> I have questions, then things I think we should do before we get it
> into the code base.
>
>
> Questions:
>
> 1) Is the branch on your fork the latest version?
>
It is my latest/final version, but it is based on an older version of
stan/rstan. Since the big refactoring of the stan code, things seem to
have moved around quite a bit.
> 2) Could we move that to the main repo (github.com/stan-dev/stan)? I'd
> be happy to give you permissions to the main repo (if you don't
> already).
>
I could do that. I don't know how to deal with the dependence on an old
version of rstan however.
> 3) Have you dealt with conditional builds? I haven't thought too much
> about it, but we definitely want Stan to build even without having
> installed CVODE.
>
I have done this many times and it's easy to do. Not sure how to do it
in the stan build system however. If this is not available in the
current build system, I'm afraid you'll need to add this feature. I
usually work with autotools or cmake.
> Things we need to do:
>
> 1) tests: unit tests, tests to make sure all generated ODEs work
>
Since my implementation is a drop-in replacement for the existing
solver, I'm just using the existing unit tests. I did need to change
some of the thresholds as I'm asking for such an accurate solution from
CVODE that the tests fail because the FD gradients are not good as a
reference. This was all checked in matlab with the true analytic
solutions. Maybe it's a good idea to add this as a unit test as well,
using the true analytic solution as a reference instead of the FD
estimate.
> 2) doc: at the class level, in the documentation
>
The CVODE implementation is a drop-in replacement, so I kept the
available documentation. I can surely add more documentation wherever
needed.
> 3) evaluations: how do the different solvers (within and outside of
> CVODE) compare. Does it actually do a reasonable job with a stiff
> solver on a non-stiff problem? Should we be looking at ARKode or LSODA
> instead?
>
>
The underlying algorithms in CVODE are the same as LSODA ((BDF and
Adams-Moulton). I haven't looked at the LSODA implementation, but I
suspect that it might have some small numerical differences. An
interesting aspect of LSODA is that it has heuristics builtin to switch
automatically between the explicit and implicit methods. Comparisons are
great, but I fear the results might be too problem-specific to
generalize. I would maybe even advocate the ability for the user to
decide on the method used (as well as absolute and relative tolerances!
). Using the simulation mode in stan, the user can investigate which
method gives the best trade-off.
Unfortunately, that isn't going to work with Stan. For Windows, we need to get CVODE to install under RTools g++. The alternative is to get Stan to compile using MSVC. Last time we tried, the templating was beyond the capability of MSVC.
Unfortunately, that isn't going to work with Stan. For Windows, we need to get CVODE to install under RTools g++.
PKG_CFLAGS=-w
Aweseome. Thanks for sharing the patch to cvode. Unfortunatley, I am not able to find cmdstan/stan combinations which run together. I am getting
icc -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -I src -I /home/weberse2/libs/cmdstan/stan/src -isystem /home/weberse2/libs/cmdstan/stan/lib/stan_math_2.6.3 -isystem /home/weberse2/libs/cmdstan/stan/lib/eigen_3.2.4 -isystem /home/weberse2/libs/cmdstan/stan/lib/boost_1.58.0 -Wall -pipe -DEIGEN_NO_DEBUG -DEIGEN_USE_MKL_ALL -DNDEBUG -isystem bin/cvode-inst/include -c -O0 -o bin/stan/lang/grammars/functions_grammar_inst.o stan/src/stan/lang/grammars/functions_grammar_inst.cpp
/home/weberse2/libs/cmdstan/stan/lib/boost_1.58.0/boost/proto/detail/preprocessed/make_expr_.hpp(73): error: class
"boost::proto::transform<PrimitiveTransform, X>::result<boost::phoenix::phoenix_generator (boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::assign, boost::proto::argsns_::list2<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::phoenix::argument<3>>, 0L>, boost::spirit::_pass_type>, 2L>)> [with PrimitiveTransform=boost::proto::switch_<boost::phoenix::phoenix_generator, boost::proto::tag_of<boost::proto::_> ()>, X=void]"
has no member "type"
typedef typename proto_generator::template result<proto_generator(expr_type)>::type result_type;
^
but I think we should wait for the 2.7.0 release to be over before continuing this branch here (I even tried to merge the stan/develop into the cvode branch).
Best,
Sebastian
On Tuesday, June 16, 2015 at 11:32:44 AM UTC+2, Tom HABER wrote:
> There are two checks in integrate_ode that aren't necessary when using
> CVODE:
>
> stan::math::check_ordered("integrate_ode", "times", ts);
> stan::math::check_less("integrate_ode", "initial time", t0, ts[0]);
>
> Since CVODE can go backwards in time (but this tends to be a harder
> problem to solve) and some of the problems I come across have
> measurements associated with the initial condition.
>
> How do you feel about removing those?
>
> Kind regards,
> Tom
>
> On Sat, 2015-05-30 at 11:37 -0400, Daniel Lee wrote:
> > Hi Tom,
> >
> >
> > Do you have push permissions to the github.com/stan-dev/stan repo? If
> > not, I'll give you access and we can continue to work on the branch
> > there so we can eventually get it into Stan.
> >
> >
> > I think there's still a lot more to do before it gets in -- I'm still
> > trying to get it up and running in Windows. I thought I had the
> > installation working, but I found out that it was compiling CVODE into
> > an incompatible object.
> >
> >
> >
> > Daniel
> >
> >
> >
> > On Sat, May 30, 2015 at 11:34 AM,
I finally got the Stan cvode branch up and running with the patch from Tom. Thanks again. I can confirm that the memory leak is gone. From the initial message of how long a single gradient evaluation takes it looks as if cvode takes 2-3 times as long as the boost solver. I have increased the tolerances to 1e-6 for relative and absolute error.
I am right now benchmarking the code on a large problem, let's see what happens, but it looks to me that we still need some tuning here. I will report once over - with boost my test case takes 3days per chain...
Best,
Sebastian
On Tuesday, June 16, 2015 at 9:50:00 PM UTC+2, Bob Carpenter wrote:
> Thanks for the input. We'll probably have two calls: config-everythnig
> and use-the-defaults.
>
> We have to decide whether to make the functions in Stan solver-dependent.
> Right now, it's just "solve_ode()" to call our non-stiff solver. But are
> we going to turn that into:
>
> solve_ode_sundials_adams(...., ...optional config params for sundials adams...)
>
> ???
>
> - Bob
>
> > On Jun 16, 2015, at 5:26 AM, Tom Haber
> >
> > I would love to be able to switch between ADAMS and BDF in CVODE in
> > addition to the maximum number of iterations allowed and maybe the
> > initial step size (if you have expert knowledge about the ODE system,
> > you can avoid some computations).
> >
> > Tom
> >
> > On Tue, 2015-06-02 at 12:58 -0400, Bob Carpenter wrote:
> >> We haven't even decided on CVODE vs. other solvers in Sundials or
> >> some reimplementation/translation of LSODA in C(++).
> >>
> >> The expert function would have to set all of the options provided,
> >> or we'd have to invent a new syntax just for optional args to
> >> ODEs --- there are no optional arguments in Stan itself as is.
> >>
> >> - Bob
> >>
> >>
> >>> On Jun 2, 2015, at 9:45 AM, Bill Gillespie
> >>>
This puzzles me a bit, I hope cvode can be run in a faster way (I already went to 1e-6 absolute and relative tolerances). @Tom: Any suggestions? What parameters are important to take care of (Stan wise and cvode wise)?
Out of curiosity: Is it thinkable to get
up and running in Stan with the good old boost odeint integrator? The instructions sound very straightforward or am I overlooking something which prevents openMP for ODE solving in Stan fundamentally? Usually I get to hear "autodiff" is the killer, but isn't this now separate enough from autodiff?
Best,
Sebastian
On Friday, June 19, 2015 at 8:26:04 PM UTC+2, Bob Carpenter wrote:
> Thanks for looking into this. It'd be nice to develop a
> suite of benchmarks. I have a couple other compartment models
> for soil carbon respiration we could use.
>
> - Bob
>
> > On Jun 19, 2015, at 9:53 AM, Sebastian Weber
> >
Sebastian
I have no clue how much this will bring us in terms of speed (stuff needs to be copied around from RAM to the GPU and back), but according to the docs:
This also looks very easy to do. The only drawback is the C++11 from the VexCL library.
Best,
Sebastian