-
-
Notifications
You must be signed in to change notification settings - Fork 123
Closed
Milestone
Description
Summary:
There is an inconsistency between the data only restrictions for the arguments to the ODE integrators between what is described in the manual and what is actually implemented in Stan.
Description:
Currently, the third and fourth arguments to all ODE integrators are enforced to be data only by the Stan type checker. However, nothing is said about that in the manual.
Reproducible Steps:
Try to compile the model
functions {
real[] sho(real t,
real[] y,
real[] theta,
real[] x,
int[] x_int) {
real dydt[2];
dydt[1] = y[2];
dydt[2] = -y[1] - theta[1] * y[2];
return dydt;
}
}
data {
int<lower=1> T;
real y0_d[2];
real ts[T];
real theta_d[1];
real x[0];
int x_int[0];
}
parameters {
real t0;
real y0_p[2];
real theta_p[1];
}
model {
real y_hat[T,2];
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_d, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_p, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_d, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_p, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_d, x, x_int, 1e-10, 1e-10, 1e8);
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_p, x, x_int, 1e-10, 1e-10, 1e8);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_d, x, x_int, 1e-10, 1e-10, 1e8);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_p, x, x_int, 1e-10, 1e-10, 1e8);
}
generated quantities {
real y_hat[T,2];
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_d, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_p, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_d, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_p, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_d, x, x_int, 1e-10, 1e-10, 1e8);
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_p, x, x_int, 1e-10, 1e-10, 1e8);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_d, x, x_int, 1e-10, 1e-10, 1e8);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_p, x, x_int, 1e-10, 1e-10, 1e8);
}
or
functions {
real[] sho(real t,
real[] y,
real[] theta,
real[] x,
int[] x_int) {
real dydt[2];
dydt[1] = y[2];
dydt[2] = -y[1] - theta[1] * y[2];
return dydt;
}
}
data {
int<lower=1> T;
real y0_d[2];
real t0;
real theta_d[1];
real x[0];
int x_int[0];
}
parameters {
real ts[T];
real y0_p[2];
real theta_p[1];
}
model {
real y_hat[T,2];
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_d, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_p, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_d, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_p, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_d, x, x_int, 1e-10, 1e-10, 1e8);
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_p, x, x_int, 1e-10, 1e-10, 1e8);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_d, x, x_int, 1e-10, 1e-10, 1e8);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_p, x, x_int, 1e-10, 1e-10, 1e8);
}
generated quantities {
real y_hat[T,2];
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_d, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_p, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_d, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_p, x, x_int);
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_d, x, x_int, 1e-10, 1e-10, 1e8);
y_hat = integrate_ode_rk45(sho, y0_d, t0, ts, theta_p, x, x_int, 1e-10, 1e-10, 1e8);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_d, x, x_int, 1e-10, 1e-10, 1e8);
y_hat = integrate_ode_rk45(sho, y0_p, t0, ts, theta_p, x, x_int, 1e-10, 1e-10, 1e8);
}
Both should be correct, according to the manual, but the Stan compiler complains that the third/fourth argument to ODE solvers should be data only. The same happens for other ODE solvers.
Current Output:
The current output. Knowing what is the current behavior is useful.
Expected Output:
I do not know which of the two is correct, but the inconsistency should be resolved.
Current Version:
v2.18.0
Metadata
Metadata
Assignees
Labels
No labels