-
Notifications
You must be signed in to change notification settings - Fork 2
/
extsim-case-a.R
60 lines (54 loc) · 2.92 KB
/
extsim-case-a.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# --------------------------------------------------------------------------- #
# CBM systems paper - extended simulation study for revision -
# Case A: failure times as expected
# --------------------------------------------------------------------------- #
# packages, code files, example system
source("extsim-setup.R")
# simulate 100 25-cycle machines
set.seed(2211)
repetitions <- 100
opcycles <- 25
Asimdata <- list()
for (i in 1:repetitions){
Asimdata[[i]] <- brWeibullData(opcycles, br1beta, br1mttf)
}
# result lists
AsimCBMcpu <- list() # our model
AsimCBMepu <- list() # do not update params during cycle, but at end of cycle
AsimCBMnpu <- list() # never update params
AsimABMepu <- list() # age-based policy with parameter update
AsimABMnpu <- list() # age-based policy without parameter update
AsimCM <- list() # corrective policy
# run simulations (six separate loops possible - use plyr::llply or lapply instead?)
for (i in 1:repetitions){
#cat("Repetition", i, ": CBM-cpu\n")
AsimCBMcpu[[i]] <- simNcycle(sys = br, ctypes = brctypes, compfts = Asimdata[[i]], n0y0 = br1n0y0,
beta = br1beta, tnowstep = 0.1, hor = 4, thresh = 0.1, seqlen = 401,
onecycle = FALSE)
#cat("Repetition", i, ": CBM-epu\n")
AsimCBMepu[[i]] <- simNcycle(sys = br, ctypes = brctypes, compfts = Asimdata[[i]], n0y0 = br1n0y0,
beta = br1beta, tnowstep = 0.1, hor = 4, thresh = 0.1, seqlen = 401,
prior = TRUE, onecycle = FALSE)
#cat("Repetition", i, ": CBM-npu\n")
AsimCBMnpu[[i]] <- simNcycle(sys = br, ctypes = brctypes, compfts = Asimdata[[i]], n0y0 = br1n0y0,
beta = br1beta, tnowstep = 0.1, hor = 4, thresh = 0.1, seqlen = 401,
prior = TRUE, cycleupdate = FALSE, onecycle = FALSE)
#cat("Repetition", i, ": ABM-epu\n")
AsimABMepu[[i]] <- simNcycleAgebased(sys = br, ctypes = brctypes, compfts = Asimdata[[i]], n0y0 = br1n0y0,
beta = br1beta, tnowstep = 0.1, hor = 4, seqlen = 401)
#cat("Repetition", i, ": ABM-npu\n")
AsimABMnpu[[i]] <- simNcycleAgebased(sys = br, ctypes = brctypes, compfts = Asimdata[[i]], n0y0 = br1n0y0,
beta = br1beta, tnowstep = 0.1, hor = 4, seqlen = 401, cycleupdate = FALSE)
#cat("Repetition", i, ": CM\n")
AsimCM[[i]] <- simNcycleCorrective(sys = br, ctypes = brctypes, compfts = Asimdata[[i]], tnowstep = 0.1)
}
# save result lists
str1 <- "Asim"
str2 <- c("CBMcpu", "CBMepu", "CBMnpu", "ABMepu", "ABMnpu", "CM")
save(list = paste(str1, str2), file = "extsim-a-objects.RData", compression = TRUE)
# test
AsimCBMcpu[[1]] <- simNcycle(sys = br, ctypes = brctypes, compfts = Asimdata[[1]], n0y0 = br1n0y0,
beta = br1beta, tnowstep = 0.1, hor = 4, thresh = 0.1, seqlen = 401,
onecycle = FALSE)
AsimCBMcpu[[1]]$costrate
#