# NOT RUN {
library(dplyr)
set.seed(10001)
## generate item pool
pool <- model_3pl()$gendata(1, 300)$items
pool$content <- sample(1:3, nrow(pool), replace=TRUE)
pool$time <- round(exp(rnorm(nrow(pool), log(60), .2)))
## ex. 1: 1-2-2 MST, 2 panels, topdown
## 20 items in total, 10 items in content area 1
## maximize info. at -1 and 1 for easy and hard routes
x <- mst(pool, "1-2-2", 2, 'topdown', len=20, maxselect=1)
x <- mst_obj(x, theta=-1, indices=1:2)
x <- mst_obj(x, theta=1, indices=3:4)
x <- mst_constraint(x, "content", 10, 10, level=1)
x <- mst_assemble(x, timeout=10)
plot(x)
plot(x, byroute=TRUE)
freq(mst_get_items(x, panel=1, route=1)$content, 1:3)$freq
freq(mst_get_items(x, panel=2, route=4)$content, 1:3)$freq
## ex. 2: 1-2-3 MST, 2 panels, bottomup,
## 10 items in total and 4 items in content area 1 in each module
## maximize info. at -1, 0 and 1 for easy, medium, and hard modules
x <- mst(pool, "1-2-3", 2, 'bottomup', len=10, maxselect=1) %>%
mst_route(c(1, 2, 6), "-") %>%
mst_route(c(1, 3, 4), "-") %>%
mst_obj(theta= 0, indices=c(1, 5)) %>%
mst_obj(theta=-1, indices=c(2, 4)) %>%
mst_obj(theta= 1, indices=c(3, 6)) %>%
mst_constraint("content", 4, 4, level=1)
x <- mst_assemble(x, timeout=10)
group_by(x$items, panel, index) %>% summarise(n=sum(content==1))
# }
Run the code above in your browser using DataLab