[Pomp-commits] r1046 - in pkg/pomp: . R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jan 7 04:26:44 CET 2015
Author: kingaa
Date: 2015-01-07 04:26:44 +0100 (Wed, 07 Jan 2015)
New Revision: 1046
Modified:
pkg/pomp/DESCRIPTION
pkg/pomp/NAMESPACE
pkg/pomp/R/builder.R
pkg/pomp/R/generics.R
pkg/pomp/R/pomp-class.R
pkg/pomp/R/pomp.R
pkg/pomp/inst/NEWS
pkg/pomp/inst/NEWS.Rd
pkg/pomp/man/pomp.Rd
Log:
- new 'pompLoad' and 'pompUnload' convenience functions for working with shared-object files associated with pomps
Modified: pkg/pomp/DESCRIPTION
===================================================================
--- pkg/pomp/DESCRIPTION 2015-01-06 23:08:15 UTC (rev 1045)
+++ pkg/pomp/DESCRIPTION 2015-01-07 03:26:44 UTC (rev 1046)
@@ -1,7 +1,7 @@
Package: pomp
Type: Package
Title: Statistical Inference for Partially Observed Markov Processes
-Version: 0.57-2
+Version: 0.58-1
Date: 2015-01-06
Authors at R: c(person(given=c("Aaron","A."),family="King",
role=c("aut","cre"),email="kingaa at umich.edu"),
Modified: pkg/pomp/NAMESPACE
===================================================================
--- pkg/pomp/NAMESPACE 2015-01-06 23:08:15 UTC (rev 1045)
+++ pkg/pomp/NAMESPACE 2015-01-07 03:26:44 UTC (rev 1046)
@@ -56,6 +56,7 @@
exportMethods(
pomp,
plot,show,print,coerce,summary,logLik,window,"$",
+ pompLoad,pompUnload,
dprocess,rprocess,rmeasure,dmeasure,init.state,skeleton,
dprior,rprior,
data.array,obs,partrans,coef,"coef<-",
Modified: pkg/pomp/R/builder.R
===================================================================
--- pkg/pomp/R/builder.R 2015-01-06 23:08:15 UTC (rev 1045)
+++ pkg/pomp/R/builder.R 2015-01-07 03:26:44 UTC (rev 1046)
@@ -46,8 +46,11 @@
globals=globals,
link=link,
save=save
- ) -> name
+ ) -> bret
+ name <- bret[1]
+ solib <- bret[2]
+
pomp(
data=data,
times=times,
@@ -71,19 +74,26 @@
paramnames=paramnames,
tcovar=tcovar,
covar=covar,
- ...
+ ...,
+ .solibfile=solib
)
}
-pompLink <- function (name) {
- solib <- paste0(name,.Platform$dynlib.ext)
- dyn.load(solib)
-}
+setMethod("pompLoad",
+ signature=signature(object='pomp'),
+ definition = function (object) {
+ for (lib in object at solibfile)
+ dyn.load(lib)
+ invisible(NULL)
+ })
-pompUnlink <- function (name) {
- solib <- paste0(name,.Platform$dynlib.ext)
- dyn.unload(solib)
-}
+setMethod("pompUnload",
+ signature=signature(object='pomp'),
+ definition = function (object) {
+ for (lib in object at solibfile)
+ dyn.unload(lib)
+ invisible(NULL)
+ })
define <- list(
var="#define {%variable%}\t({%ptr%}[{%ilist%}[{%index%}]])\n",
@@ -295,15 +305,9 @@
cat("model codes written to",sQuote(modelfile),
"\nlink to shared-object library",sQuote(solib),"\n")
- if (link) {
- if (save) {
- pompLink(name)
- } else {
- pompLink(file.path(tempdir(),name))
- }
- }
+ if (link) dyn.load(solib)
- invisible(name)
+ invisible(c(name,solib))
}
cleanForC <- function (text) {
@@ -333,3 +337,4 @@
}
do.call(paste0,retval)
}
+
Modified: pkg/pomp/R/generics.R
===================================================================
--- pkg/pomp/R/generics.R 2015-01-06 23:08:15 UTC (rev 1045)
+++ pkg/pomp/R/generics.R 2015-01-07 03:26:44 UTC (rev 1046)
@@ -88,3 +88,7 @@
## continue an iteration
setGeneric("continue",function(object,...)standardGeneric("continue"))
+
+## dynamic loading and unloading
+setGeneric("pompLoad",function(object,...)standardGeneric("pompLoad"))
+setGeneric("pompUnload",function(object,...)standardGeneric("pompUnload"))
Modified: pkg/pomp/R/pomp-class.R
===================================================================
--- pkg/pomp/R/pomp-class.R 2015-01-06 23:08:15 UTC (rev 1045)
+++ pkg/pomp/R/pomp-class.R 2015-01-07 03:26:44 UTC (rev 1046)
@@ -34,6 +34,7 @@
has.trans = 'logical',
par.trans = 'pomp.fun',
par.untrans = 'pomp.fun',
+ solibfile = 'character',
userdata = 'list'
),
prototype=prototype(
@@ -58,6 +59,7 @@
has.trans=FALSE,
par.trans=pomp.fun(),
par.untrans=pomp.fun(),
+ solibfile=character(0),
userdata=list()
),
validity=function (object) {
Modified: pkg/pomp/R/pomp.R
===================================================================
--- pkg/pomp/R/pomp.R 2015-01-06 23:08:15 UTC (rev 1045)
+++ pkg/pomp/R/pomp.R 2015-01-07 03:26:44 UTC (rev 1046)
@@ -9,14 +9,18 @@
obsnames, statenames, paramnames, covarnames,
zeronames, PACKAGE,
parameter.transform, parameter.inv.transform,
- globals,
- userdata) {
+ globals, userdata, ..., .solibfile) {
## preliminary error checking
if (missing(data)) stop(sQuote("data")," is a required argument")
if (missing(times)) stop(sQuote("times")," is a required argument")
if (missing(t0)) stop(sQuote("t0")," is a required argument")
if (missing(params)) params <- numeric(0)
+ if (missing(.solibfile)) .solibfile <- character(0)
+
+ if (missing(userdata)) userdata <- list()
+ added.userdata <- list(...)
+ userdata[names(added.userdata)] <- added.userdata
## name of shared object library
if (missing(PACKAGE)) PACKAGE <- NULL
@@ -147,10 +151,14 @@
),
silent=FALSE
)
- if (inherits(PACKAGE,"try-error"))
+ if (inherits(PACKAGE,"try-error")) {
stop("error in building shared-object library from Csnippets")
+ } else {
+ .solibfile <- c(.solibfile,libname[2L])
+ libname <- libname[1L]
+ }
} else {
- libname <- ""
+ libname <- ''
}
## handle rprocess
@@ -363,6 +371,7 @@
has.trans = has.trans,
par.trans = par.trans,
par.untrans = par.untrans,
+ solibfile = .solibfile,
userdata = userdata
)
}
@@ -483,8 +492,8 @@
rmeasure=rmeasure,
dmeasure=dmeasure,
measurement.model=measurement.model,
- dprior = dprior,
- rprior = rprior,
+ dprior=dprior,
+ rprior=rprior,
skeleton=skeleton,
skeleton.type=skeleton.type,
skelmap.delta.t=skelmap.delta.t,
@@ -501,7 +510,7 @@
parameter.transform=parameter.transform,
parameter.inv.transform=parameter.inv.transform,
globals=globals,
- userdata=list(...)
+ ...
)
}
)
@@ -527,8 +536,8 @@
rmeasure=rmeasure,
dmeasure=dmeasure,
measurement.model=measurement.model,
- dprior = dprior,
- rprior = rprior,
+ dprior=dprior,
+ rprior=rprior,
skeleton=skeleton,
skeleton.type=skeleton.type,
skelmap.delta.t=skelmap.delta.t,
@@ -545,7 +554,7 @@
parameter.transform=parameter.transform,
parameter.inv.transform=parameter.inv.transform,
globals=globals,
- userdata=list(...)
+ ...
)
}
)
@@ -572,8 +581,8 @@
rmeasure=rmeasure,
dmeasure=dmeasure,
measurement.model=measurement.model,
- dprior = dprior,
- rprior = rprior,
+ dprior=dprior,
+ rprior=rprior,
skeleton=skeleton,
skeleton.type=skeleton.type,
skelmap.delta.t=skelmap.delta.t,
@@ -590,7 +599,7 @@
parameter.transform=parameter.transform,
parameter.inv.transform=parameter.inv.transform,
globals=globals,
- userdata=list(...)
+ ...
)
}
)
@@ -659,10 +668,6 @@
}
}
- userdata <- data at userdata
- added.userdata <- list(...)
- userdata[names(added.userdata)] <- added.userdata
-
if (missing(obsnames)) obsnames <- character(0)
if (missing(statenames)) statenames <- character(0)
if (missing(paramnames)) paramnames <- character(0)
@@ -677,8 +682,8 @@
dprocess=dprocess,
rmeasure=rmeasure,
dmeasure=dmeasure,
- dprior = dprior,
- rprior = rprior,
+ dprior=dprior,
+ rprior=rprior,
skeleton=skeleton,
skeleton.type=skeleton.type,
skelmap.delta.t=skelmap.delta.t,
@@ -695,7 +700,8 @@
parameter.inv.transform=par.untrans,
params=params,
globals=globals,
- userdata=userdata
+ userdata=data at userdata,
+ ...
)
}
)
Modified: pkg/pomp/inst/NEWS
===================================================================
--- pkg/pomp/inst/NEWS 2015-01-06 23:08:15 UTC (rev 1045)
+++ pkg/pomp/inst/NEWS 2015-01-07 03:26:44 UTC (rev 1046)
@@ -1,5 +1,12 @@
_N_e_w_s _f_o_r _p_a_c_k_a_g_e '_p_o_m_p'
+_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._5_8-_1:
+
+ • A ‘pomp’ object created with ‘Csnippet’s or ‘pompBuilder’
+ will now remember its associated shared-object file, which
+ can be unloaded and reloaded using the new ‘pompUnload’ and
+ ‘pompLoad’ methods.
+
_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._5_7-_1:
• ‘simulate’ has a new argument, ‘include.data’, that when used
Modified: pkg/pomp/inst/NEWS.Rd
===================================================================
--- pkg/pomp/inst/NEWS.Rd 2015-01-06 23:08:15 UTC (rev 1045)
+++ pkg/pomp/inst/NEWS.Rd 2015-01-07 03:26:44 UTC (rev 1046)
@@ -1,5 +1,10 @@
\name{NEWS}
\title{News for package `pomp'}
+\section{Changes in \pkg{pomp} version 0.58-1}{
+ \itemize{
+ \item A \code{pomp} object created with \code{Csnippet}s or \code{pompBuilder} will now remember its associated shared-object file, which can be unloaded and reloaded using the new \code{pompUnload} and \code{pompLoad} methods.
+ }
+}
\section{Changes in \pkg{pomp} version 0.57-1}{
\itemize{
\item \code{simulate} has a new argument, \code{include.data}, that when used in conjuncion with \code{as.data.frame=TRUE} will include the actual data in the resulting data frame along with the simulations.
Modified: pkg/pomp/man/pomp.Rd
===================================================================
--- pkg/pomp/man/pomp.Rd 2015-01-06 23:08:15 UTC (rev 1045)
+++ pkg/pomp/man/pomp.Rd 2015-01-07 03:26:44 UTC (rev 1046)
@@ -9,6 +9,12 @@
\alias{pomp,pomp-method}
\alias{pomp-pomp}
\alias{pomp-class}
+\alias{pompLoad}
+\alias{pompLoad-pomp}
+\alias{pompLoad,pomp-method}
+\alias{pompUnload}
+\alias{pompUnload-pomp}
+\alias{pompUnload,pomp-method}
\title{Partially-observed Markov process object.}
\description{
This function creates a \code{pomp} object,
@@ -38,6 +44,8 @@
initializer, rprior, dprior, params, covar, tcovar,
obsnames, statenames, paramnames, covarnames, zeronames,
PACKAGE, parameter.transform, parameter.inv.transform, globals)
+\S4method{pompLoad}{pomp}(object)
+\S4method{pompUnload}{pomp}(object)
}
\arguments{
\item{data, times}{
@@ -185,8 +193,11 @@
\item{globals}{
optional character;
C code that will be included in the source for (and therefore hard-coded into) the shared-object library created when the call to \code{pomp} uses \code{Csnippets}.
- If no \code{Csnippets} are used, \code{globals} has no effect.
+ If no \code{Csnippet}s are used, \code{globals} has no effect.
}
+ \item{object}{
+ a \code{pomp} object.
+ }
\item{\dots}{
Any additional arguments given to \code{pomp} will be stored in the \code{\link[=pomp-class]{pomp}} object and passed as arguments to each of the basic functions whenever they are evaluated.
}
@@ -313,6 +324,13 @@
)
}
}
+\section{Dynamically linked codes}{
+ \code{pompLoad} and \code{pompUnload} cause any compiled codes associated with \code{object} to be dynamically linked or unlinked, respectively.
+ When
+ \code{Csnippet}s are used in the construction of a \code{pomp} object, the resulting shared-object library is dynamically loaded (linked) at the time of its construction.
+ A subsequent call to \code{pompUnload} will unload the shared object library;
+ it can afterward be reloaded via a call to \code{pompLoad}.
+}
\section{Warning}{
Some error checking is done by \code{pomp}, but complete error checking is impossible.
If the user-specified functions do not conform to the above specifications (see Details), then the results may be invalid.
More information about the pomp-commits
mailing list