when workdir is specified, clean option does not delete files
- Dominant language
- Smarty
- Stars
- 6
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
The `clean` option does not delete files when `workdir` is specified. Below is an example code. If the `workdir` line is commented out, the intermediate files are deleted.
Thanks, Kyaw Sint (Joe)
```
library("R2admb")
setup_admb("C:/Program Files (x86)/ADMB")
library("ggplot2")
# from http://www.carlboettiger.info/2013/06/03/ADMB-basic-example.html
f <- function(x,h,p) x * exp(p[1] * (1 - x / p[2]) * (x - p[3]) / p[2] )
p <- c(1, 10, 5)
K <- 10 # approx, a li'l' less
Xo <- 6 # approx, a li'l' less
sigma_g <- 0.1
z_g <- function() rlnorm(1,0, sigma_g)
x_grid <- seq(0, 1.5 * K, length=50)
Tobs <- 40
set.seed(123)
x <- numeric(Tobs)
x[1] <- Xo
for(t in 1:(Tobs-1))
x[t+1] = z_g() * f(x[t], h=0, p=p)
qplot(1:Tobs, x)
model <-
paste("
PARAMETER_SECTION
vector mu(1,n) // per capita mort prob
PROCEDURE_SECTION
mu = log(x) + r * elem_prod((1 - x / k), (x - c) / k);
f = 0.5 * n * log(2 * M_PI) + n * log(s) + 0.5 * norm2(x - exp(mu)) / square(s);
")
writeLines(model, "model.tpl")
df <- data.frame(x=x)
params <- list(r = 1, k = 1, c = 1, s = 1) ## starting parameters
bounds <- list(r = c(1e-10, 1e3), k=c(1e-10, 1e3), c=c(1e-10, 1e3), s = c(1e-5,1e3)) ## bounds
dat <- c(list(n = nrow(df)), df)
m1 <- do_admb("model",
data = dat,
params = params,
bounds = bounds,
workdir = "./scratch/",
run.opts = run.control(checkparam="write",
checkdata="write", clean=TRUE), verbose = TRUE)
m1
unlink("model")
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the example using do_admb with workdir="./scratch/" and run.control(clean=TRUE), then compare it with the same call without workdir. Trace the clean and workdir handling in do_admb and run.control; done means intermediate files are deleted in both cases while the requested output remains usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100