/** * Run simulation for the SISe3 model * * This function is called from R with '.Call' * @param model The SISe3 model * @param threads Number of threads * @param seed Random number seed. * @return S4 class SISe3 with the simulated trajectory in U */ SEXP SISe3_run(SEXP model, SEXP threads, SEXP seed) { int err = 0; SEXP result, class_name; PropensityFun t_fun[] = {&SISe3_S_1_to_I_1, &SISe3_I_1_to_S_1, &SISe3_S_2_to_I_2, &SISe3_I_2_to_S_2, &SISe3_S_3_to_I_3, &SISe3_I_3_to_S_3}; if (R_NilValue == model || S4SXP != TYPEOF(model)) Rf_error("Invalid SISe3 model"); class_name = getAttrib(model, R_ClassSymbol); if (strcmp(CHAR(STRING_ELT(class_name, 0)), "SISe3") != 0) Rf_error("Invalid SISe3 model: %s", CHAR(STRING_ELT(class_name, 0))); result = PROTECT(duplicate(model)); err = siminf_run(result, threads, seed, t_fun, &SISe3_post_time_step); UNPROTECT(1); if (err) siminf_error(err); return result; }
/** * Run simulation with the SISe model * * @param model The SISe model. * @param threads Number of threads. * @param seed Random number seed. * @return The simulated trajectory. */ SEXP SISe_run(SEXP model, SEXP threads, SEXP seed) { TRFun tr_fun[] = {&SISe_S_to_I, &SISe_I_to_S}; return siminf_run(model, threads, seed, tr_fun, &SISe_post_time_step); }