Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/vcadavez/qraLm
Browse files Browse the repository at this point in the history
  • Loading branch information
vcadavez committed Jul 8, 2024
2 parents e148413 + 3e03e1d commit 16061f0
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 34 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ URL: https://github.com/vcadavez/qraLm
BugReports: https://github.com/vcadavez/qraLm/issues
Depends: R (>= 3.5.0)
Imports: Rdpack, Hmisc, extraDistr, mc2d, matrixStats, DT, dplyr, shiny,
ggplot2, plotly, Rcpp, odeintr, doseresponsemodels
LinkingTo: Rcpp, odeintr, BH
ggplot2, plotly, Rcpp, doseresponsemodels
LinkingTo: Rcpp, BH
RdMacros: Rdpack
License: MIT + file LICENSE
LazyLoad: yes
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ importFrom(mc2d,rdirichlet)
importFrom(mc2d,rmultinomial)
importFrom(mc2d,rpert)
importFrom(mc2d,rtriang)
importFrom(odeintr,compile_sys)
importFrom(plotly,ggplotly)
importFrom(plotly,plot_ly)
importFrom(plotly,subplot)
Expand Down
52 changes: 25 additions & 27 deletions R/sfGrowthJameson.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,16 @@
#'
#' \insertRef{Moller2013}{qraLm}
#'
#' @importFrom odeintr compile_sys
#'
#' @export
#'
#' @note
#' For sake of speed, the function first evaluates a classical Baranyi and Roberts model without interactions.
#' If any of the two population reaches a value greater than \eqn{10^{(MPD - lim)}} CFU, an expanded version of the Jameson-effect model
#' by \insertCite{Gimenez2004;textual}{qraLm} is used. This model includes the parameter gamma proposed by \insertCite{Moller2013;textual}{qraLm}.
#' The expanded Jameson-effect model is integrated using the `odeintr` package. The function is vectorized for all parameters.
#' The function is vectorized for all parameters.
#'
#' @examples
#' library(qraLm)
#' library(odeintr)
#' iter <- 1000
#' set.seed(666)
#' vtime <- 200
Expand Down Expand Up @@ -99,32 +96,33 @@ sfGrowthJameson <- function(time,
# If not, build them

if (!exists("expandedjamesonC_set_params")) {
cat("Rebuilding Jameson\n")

expandedjamesonC.sys <- "
/* Q1:x[0] dQ1<-mumax1*Q1
Q2:x[1] dQ2<-mumax2*Q2
y1:x[2] dy1<-(Q1/(1+Q1))*mumax1*(1-(y1/ymax1))*(1-(gamma*y2/ymax2))*y1
y2:x[3] dy2<-(Q2/(1+Q2))*mumax2*(1-(y1/ymax1))*(1-(y2/ymax2))*y2
*/
dxdt[0] = mumax1 * x[0];
dxdt[1] = mumax2 * x[1];
dxdt[2] = (x[0]/(1+x[0])) * mumax1 * (1-(x[2]/ymax1)) * (1-(gamma*x[3]/ymax2))*x[2];
dxdt[3] = (x[1]/(1+x[1])) * mumax2 * (1-(x[2]/ymax1)) * (1-(x[3]/ymax2))*x[3];
"
# Do compile once
pars <- c(mumax1 = 0.14, mumax2 = 0.3, ymax1 = 10^8, ymax2 = 10^7, gamma = 1.0)
compile_sys(
name = "expandedjamesonC",
sys = expandedjamesonC.sys,
pars = pars,
const = FALSE, sys_dim = 4
)
stop("C++ functions for Jameson effect are missing")
# cat("Rebuilding Jameson\n")
#
# expandedjamesonC.sys <- "
# /* Q1:x[0] dQ1<-mumax1*Q1
# Q2:x[1] dQ2<-mumax2*Q2
# y1:x[2] dy1<-(Q1/(1+Q1))*mumax1*(1-(y1/ymax1))*(1-(gamma*y2/ymax2))*y1
# y2:x[3] dy2<-(Q2/(1+Q2))*mumax2*(1-(y1/ymax1))*(1-(y2/ymax2))*y2
# */
#
# dxdt[0] = mumax1 * x[0];
# dxdt[1] = mumax2 * x[1];
# dxdt[2] = (x[0]/(1+x[0])) * mumax1 * (1-(x[2]/ymax1)) * (1-(gamma*x[3]/ymax2))*x[2];
# dxdt[3] = (x[1]/(1+x[1])) * mumax2 * (1-(x[2]/ymax1)) * (1-(x[3]/ymax2))*x[3];
# "
# # Do compile once
# pars <- c(mumax1 = 0.14, mumax2 = 0.3, ymax1 = 10^8, ymax2 = 10^7, gamma = 1.0)
# compile_sys(
# name = "expandedjamesonC",
# sys = expandedjamesonC.sys,
# pars = pars,
# const = FALSE, sys_dim = 4
# )
}

# Define a function for growth with Competition integrate the
# C++ function using odeintr
# C++ function
growthCompetC <- function(time, N0Lm, N0LAB, q0Lm, q0LAB,
muLm, muLAB, MPDLm, MPDLAB, unitSize,
gamma,
Expand Down
3 changes: 1 addition & 2 deletions man/sfGrowthJameson.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified src/RcppExports.o
Binary file not shown.
5 changes: 3 additions & 2 deletions src/jameson.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Copyright Timothy H. Keitt 2015
// See license for odeintr package

// [[Rcpp::depends(odeintr)]]


#include <Rcpp.h>
// [[Rcpp::plugins(cpp11)]]

// [[Rcpp::depends(BH)]]

#include "boost/numeric/odeint.hpp"
namespace odeint = boost::numeric::odeint;

Expand All @@ -30,7 +31,7 @@ namespace odeintr

double mumax1 = 0.14, mumax2 = 0.3, ymax1 = 1e+08, ymax2 = 1e+07, gamma = 1;;

#include "utils.h"
//#include <Rcpp/utils.h>

static void
sys(const state_type x, state_type &dxdt, const double t)
Expand Down
Binary file modified src/jameson.o
Binary file not shown.
Binary file added src/qraLm.dll
Binary file not shown.

0 comments on commit 16061f0

Please sign in to comment.