source("tadpole_sim_funs.R")
nsim <- 300

library(plyr)
library(rbenchmark)
library(optimx)

Rout <- rdply(nsim,simfun("R"))
ADMBout <- rdply(nsim,simfun("ADMB"))
BUGSout <- rdply(nsim,simfun("BUGS"))
      
tadpole_sims <- rbind(data.frame(method="ADMB",ADMBout),
                      data.frame(method="R",Rout),
                      data.frame(method="BUGS",BUGSout))

optbench <- benchmark(mle2(Kill~dbinom(c*((TBL/d)*exp(1-TBL/d))^g,size=10),
                 start=list(c=0.45,d=13,g=1),
                 data=ReedfrogSizepred,
                 method="L-BFGS-B",
                 lower=c(c=0.003,d=10,g=0),
                 upper=c(c=0.8,d=20,g=20),
                 control=list(parscale=c(c=0.5,d=10,g=1))),
            mle2(Kill~dbinom(c*((TBL/d)*exp(1-TBL/d))^g,size=10),
                 start=list(c=0.45,d=13,g=1),data=ReedfrogSizepred,
                 optimizer="nlminb",
                 lower=c(c=0.003,d=10,g=0),
                 upper=c(c=0.8,d=20,g=20)),
            mle2(Kill~dbinom(c*((TBL/d)*exp(1-TBL/d))^g,size=10),
                 start=list(c=0.45,d=13,g=1),data=ReedfrogSizepred,
                 optimizer="optimx",method="bobyqa",
                 lower=c(c=0.003,d=10,g=0),
                 upper=c(c=0.8,d=20,g=20)),
               mle2(Kill~dbinom(c*((TBL/d)*exp(1-TBL/d))^g,size=10),
                 start=list(c=0.45,d=13,g=1),data=ReedfrogSizepred,
                 optimizer="optimx",method="Rvmmin",
                 lower=c(c=0.003,d=10,g=0),
                 upper=c(c=0.8,d=20,g=20)),
            replications=50)
save("tadpole_sims",file="tadpole_sims.RData")
      
