metrumresearchgroup / Torsten

library of C++ functions that support applications of Stan in Pharmacometrics
BSD 3-Clause "New" or "Revised" License
53 stars 11 forks source link

pmx_integrate_ode_ functions not available [BUG] #53

Open sebastianueckert opened 5 months ago

sebastianueckert commented 5 months ago

Description

The family of function pmx_integrate_ode_ is described in the documentation but does not appear to be found by STAN during the compilation process.

Example

Compiling Stan program...
Semantic error in '/tmp/Rtmpch722Q/model-14e2926ff4481.stan', line 93, column 38 to column 124:
   -------------------------------------------------
    91:      ii[:j24], evid[:j24], cmt[:j24], addl[:j24], ss[:j24], K, biovar, tlag);
    92:    int n_cmt_pd = 3;
    93:    matrix [n_cmt_pd, n_t - j24] x_pd = pmx_integrate_ode_rk45(f_ode, x_init[:, j24], 24.0, time[j24 + 1:], prm_i, {0.0}, {0});   
                                               ^
    94:    return  {y_hat_p, y_hat_l, y_hat_pd};
    95:   }
   -------------------------------------------------

A returning function was expected but an undeclared identifier 'pmx_integrate_ode_rk45' was supplied.

Expected Output

Model should compile without errors

Current Version:

v0.90.0

yizhang-yiz commented 5 months ago

Thanks for reporting. Looks like a problem in the language part with stanc. I can probably look into it next week.

yizhang-yiz commented 5 months ago

I've updated the ODE solver signatures to get close to what Stan offers, e.g.

pmx_ode_bdf(rhs_function,  y0, t0, ts, params,...) // without ODE solver control params
pmx_ode_bdf_ctrl(rhs_function,  y0, t0, ts, rtol, atol, maxstep, params,...)  // with ODE solver controls: relative tolerance, absolute tolerance, maximum steps.

Replacing "bdf" with "ckrk", "rk45", and "adams" for the other solvers.

I still need to add more tests before merge but you may use https://github.com/metrumresearchgroup/Torsten/tree/pmx_ode branch for now. You may also find examples at https://github.com/metrumresearchgroup/Torsten/tree/pmx_ode/example-models/airy_equation https://github.com/metrumresearchgroup/Torsten/tree/pmx_ode/example-models/chemical_reactions