Permalink
Browse files

Comparison and profiling updates

* Workaround - use par file instead of std file to report higher admb precision
* Consistency tmb vs admb of orange_big
* Add args to admb runs
* profile - make text report
  • Loading branch information...
1 parent 500790f commit dc135625ee94d093e591464ca4acccd6c0950473 @kaskr committed Jan 29, 2014
Showing with 33 additions and 11 deletions.
  1. +1 −1 admb_examples/Makefile
  2. +20 −6 admb_examples/run.R
  3. +5 −2 compare/report.R
  4. +3 −2 tmb_examples/orange_big.cpp
  5. +4 −0 tmb_examples/profiler.R
View
@@ -1,4 +1,4 @@
-examples=nmix mvrw spatial sdv_multi
+examples=nmix mvrw spatial sdv_multi orange_big
outputfiles = $(examples:=.output.RData)
all: $(outputfiles)
%.output.RData :
View
@@ -1,11 +1,25 @@
example <- Sys.getenv("example")
example <- sub("\\..*","",example)
print(example)
+file <- paste(example,"README.md",sep="/")
+if(file.exists(file)) readme <- readLines(file) else readme <- ""
+run <- paste(grep(paste0("^\\./",example),readme,value=TRUE),"")
+run <- sub("-est","",run)
+args <- sub("^[^ ]* ","",run)
build <- "cd folder;admb -r folder.tpl"
-run1 <- "cd folder;./folder -est"
-run2 <- "cd folder;./folder"
+run1 <- "cd folder;./folder -args -est"
+run2 <- "cd folder;./folder -args"
system(gsub("folder",example,build))
-tim1 <- system.time(system(gsub("folder",example,run1)))
-tim2 <- system.time(system(gsub("folder",example,run2)))
-rep <- read.table(paste0(example,"/",example,".std"),header=TRUE)
-save(tim1,tim2,rep,file=paste0(example,".output.RData"))
+tim1 <- system.time(system(cmd1 <- sub("-args",args,gsub("folder",example,run1))))
+tim2 <- system.time(system(cmd2 <- sub("-args",args,gsub("folder",example,run2))))
+rep <- try(read.table(paste0(example,"/",example,".std"),header=TRUE))
+
+## Hack: insert par file estimate in std
+par <- try(readLines(paste0(example,"/",example,".par")))
+par <- grep("^[^#]",par,value=TRUE)
+par <- sub("^ ","",par)
+par <- do.call("paste",as.list(par))
+par <- as.numeric(strsplit(par," ")[[1]])
+rep$value[] <- par
+
+save(tim1,tim2,cmd1,cmd2,rep,file=paste0(example,".output.RData"))
View
@@ -1,5 +1,5 @@
require(TMB)
-f1 <- dir("../tmb_examples",".expected.RData")
+f1 <- dir("../tmb_examples",".output.RData")
f2 <- dir("../admb_examples",".output.RData")
examples <- intersect(sub("\\..*","",f1),sub("\\..*","",f2))
compare <- function(example){
@@ -10,7 +10,10 @@ compare <- function(example){
setwd("../tmb_examples")
load(paste0(example,".output.RData"))
sum <- summary(.results$`TMB::sdreport`)
- rep <- rep[1:nrow(sum),] ## In case admb example has sdreport - we don't compare that yet
+ M <- min(nrow(sum),nrow(rep))
+ if(M<1)stop("No output")
+ rep <- rep[1:M,] ## In case admb example has sdreport - we don't compare that yet
+ sum <- sum[1:M,]
ok <- all(as.character(rep$name)==rownames(sum))
if(!ok){
cat("Example:",example,"\n")
@@ -33,10 +33,11 @@ Type objective_function<Type>::operator() ()
{
// Random effects contribution
Type u1 = u[i+k*M];
- g -= -.5*u1*u1;
+ g -= -(log_sigma_u);
+ g -= -.5*pow(u1/sigma_u,2);
vector<Type> a(3);
- a[0] = 192.0 + beta[0] + sigma_u*u1;
+ a[0] = 192.0 + beta[0] + u1;
a[1] = 726.0 + beta[1];
a[2] = 356.0 + beta[2];
View
@@ -8,3 +8,7 @@ example <- Sys.getenv("example")
Rexe <- paste(Sys.getenv("R_HOME"),"bin/exec/R",sep="/")
cmd <- paste("amplxe-cl -collect hotspots -result-dir ",example,".profile"," -- ",Rexe," --vanilla < ",example,".R",sep="")
system(cmd)
+cmd <- paste("amplxe-cl -report hotspots -result-dir ",example,".profile"," > ",example,".profile.txt",sep="")
+system(cmd)
+df <- read.table(paste0(example,".profile.txt"),header=TRUE,sep="\t")
+as.matrix(xtabs(CPU.Time~Module,data=df))

0 comments on commit dc13562

Please sign in to comment.