#' Stuttgart 05 April 2017
#' @author Nha Vo-Thanh
#' reading data from text files
#'
rm(list = ls())
setwd(
"D:/user/vthanh/Google Drive/Project Stuttgart/R_programing/UpdateFormular/Block3AugDesigns/"
)
#Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre1.8.0_121')
#install.packages("rJava")
library("rJava")
library(xlsx)
library(devtools)
library(roxygen2)
library(MASS)
devtools::load_all()
#-------------------------------------#
source("D:/user/vthanh/Google Drive/Project Stuttgart/R_programing/A_Eff_RowColumnDesign.r")
source("D:/user/vthanh/Google Drive/Project Stuttgart/R_programing/A_Eff_BlockDesign.r")
nTreatments <- 39
nChecks <- 3
nRows <- 6
nCols <- 9
repli <- -1
flag <- 0
vrepChecks <- c(6,6,6)
ptm <- proc.time()
pDesign <- genBlkDesign(nTreatments, nRows, nCols, nChecks, vrepChecks, flag=0)
cputime <- proc.time() - ptm
print(cputime)
#cat("\014")
copyDesign <- pDesign
t00 <- AOpt(pDesign, nTreatments, nRows, nCols, repli=-1, 0)
t0 <- t00
# Swapping two treatments
# The first treatment
niter <- 10000
Temp <- 1.0
T_min <- 0.00001
alpha <- 0.9
iPDesign <- pDesign
told <- t00
while (Temp>=T_min){
i <- 1
while (i <= niter){
# The first treatment
rcols <- sample(1:nCols, 2, replace = F)
irow1 <- sample(1:nRows, 1, replace = F)
iTrt1 <- iPDesign[irow1,rcols[1]]
# The second treatment
irow2 <- sample(1:nRows, 1, replace = F)
iTrt2 <- iPDesign[irow2,rcols[2]]
nDesign <- iPDesign
nDesign[irow1,rcols[1]] <- iTrt2
nDesign[irow2,rcols[2]] <- iTrt1
tnew <- AOpt(nDesign, nTreatments, nRows, nCols, repli=-1, 0)
ap <- exp((-told+tnew)/Temp)
#ap = acceptance_probability(old_cost, new_cost, T)
if ((ap > 0.01)&&(tnew>0)) {
iPDesign <- nDesign
told <- tnew
}
i <- i + 1
}
Temp <- Temp*alpha
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.