# examples for the JSS paper
multistageoptimal.pb(N.upper=rep(401,2), N.lower=c(1,1), num.grid=21, Budget=1000,
CostC=0.5, CostTv=c(1,1), V="VC2", L1=2, Rep=c(1,1), N.fs=1, alg=GenzBretz())
# glm
dim=6
gain.table= array(0,c(dim,7))
result.nlm= array(0,c(dim,9))
result.grid= array(0,c(dim,9))
rownames(gain.table)= c(1:dim)
colnames(gain.table)= c("NumSelected","Budget","maxN1","maxN2",
"Location1","steplength","Calcu.Gain")
gain.table[1,]=c(1,200, 101, 101,1,21 ,0)
gain.table[2,]=c(1,1000,401, 401,2,21,0)
gain.table[3,]=c(1,5000,2001,2001,2,41,0)
gain.table[4,]=c(4,200, 101, 101,1,21, 0)
gain.table[5,]=c(4,1000,601, 601,1,21, 0)
gain.table[6,]=c(4,5000,2001,2001,2,41,0)
#######
# IMPORTANT
#######
# in order to reduce the time of checking in CRAN only the first breeding scheme will be checked
# if you want to run all 6 schemes you have to change the following code dim6=1 into dim6=6
dim6=1
#######
# change the code above
#######
for (i in 1:dim6 )
{
maxn=gain.table[i,"maxN1"]
length=gain.table[i,"steplength"]
Budget=gain.table[i,"Budget"]
Location1= gain.table[i,"Location1"]
NumSelected=gain.table[i,"NumSelected"]
temp<-multistageoptimal.pb(N.upper=rep(maxn,2), N.lower=c(1,1), num.grid=length,
Budget=Budget, CostC=0.5, CostTv=c(1,1), V="VC2", L1=Location1, Rep=c(1,1),
N.fs=NumSelected, alg=GenzBretz(),detail=TRUE)
result.grid[i,]=temp[[1]][1,]
}
colnames(result.grid)<-c("NumSelected","Budget","Location1","Location2",
"N1","N2","Rep1","Rep2","gain")
rownames(result.grid)<-rep("grid",6)
result.grid
# round-nlm
dim=6
gain.table= array(0,c(dim,7))
result.nlm= array(0,c(dim,9))
result.grid= array(0,c(dim,9))
rownames(gain.table)= c(1:dim)
colnames(gain.table)= c("NumSelected","Budget","maxN1","maxN2",
"Location1","steplength","Calcu.Gain")
gain.table[1,]=c(1,200, 101, 101,1,21 ,0)
gain.table[2,]=c(1,1000,401, 401,2,21,0)
gain.table[3,]=c(1,5000,2001,2001,2,41,0)
gain.table[4,]=c(4,200, 101, 101,1,21, 0)
gain.table[5,]=c(4,1000,601, 601,1,21, 0)
gain.table[6,]=c(4,5000,2001,2001,2,41,0)
# name changed in certain version
gainmatrix=gain.table
for (i in 1:dim6 )
{
maxn=gainmatrix[i,"maxN1"]
length=gainmatrix[i,"steplength"]
Budget=gainmatrix[i,"Budget"]
Location1= gainmatrix[i,"Location1"]
NumSelected=gainmatrix[i,"NumSelected"]
temp<-multistageoptimal.pb(N.upper=rep(maxn,2), N.lower=c(1,1),
num.grid=length, Budget=Budget, CostC=0.5, CostTv=c(1,1), V="VC2",
L1=Location1, Rep=c(1,1), N.fs=NumSelected, alg=GenzBretz(),detail=FALSE)
result.nlm[i,]=temp[[1]][2,]
}
colnames(result.nlm)<-c("NumSelected","Budget","Location1","Location2",
"N1","N2","Rep1","Rep2","gain")
rownames(result.nlm)<-rep("round-nlm",6)
result.nlmRun the code above in your browser using DataLab