## Not run:
# # test defined in mirtCAT help file, first example
# CATdesign <- mirtCAT(df, mod, criteria = 'MI', design_elements = TRUE)
#
# # returns number 1 in this case, since that's the starting item
# findNextItem(CATdesign)
#
# # determine next item if item 1 and item 10 were answered correctly, and Theta = 0.5
# CATdesign <- updateDesign(CATdesign, items = c(1, 10), responses = c(1, 1), Theta = 0.5)
# findNextItem(CATdesign)
# findNextItem(CATdesign, all_index = TRUE) # all items rank in terms of most optimal
#
# # alternatively, update the Theta using the internal ReferenceClass method
# Person$help('Update.thetas') # internal help file for class 'Person'
# CATdesign$person$Update.thetas(CATdesign$design, CATdesign$test)
# findNextItem(CATdesign)
#
#
# #-------------------------------------------------------------
# ## Integer programming example (e.g., shadow testing)
#
# # find maximum information subject to constraints
# # sum(xi) <= 5 ### 5 or fewer items
# # x1 + x2 <= 1 ### items 1 and 2 can't be together
# # x4 == 0 ### item 4 not included
# # x5 + x6 == 1 ### item 5 or 6 must be included, but not both
#
# # constraint function
# constr_fun <- function(person, test, design){
#
# # left hand side constrains
# # - 1 row per constraint, and ncol must equal number of items
# mo <- extract.mirtCAT(test, 'mo')
# nitems <- extract.mirt(mo, 'nitems')
# lhs <- matrix(0, 4, nitems)
# lhs[1,] <- 1
# lhs[2,c(1,2)] <- 1
# lhs[3, 4] <- 1
# lhs[4, c(5,6)] <- 1
#
# # relationship direction
# dirs <- c("<=", "<=", '==', '==')
#
# #right hand side
# rhs <- c(5, 1, 0, 1)
#
# #all together
# constraints <- data.frame(lhs, dirs, rhs)
# constraints
# }
#
# #### CATdesign <- mirtCAT(..., design_elements = TRUE,
# ### design = list(constr_fun=constr_fun))
#
# #' # MI criteria value associated with each respective item
# objective <- computeCriteria(CATdesign, criteria = 'MI')
#
# # most optimal item, given constraints
# findNextItem(CATdesign, objective=objective)
#
# # all the items which solve the problem
# findNextItemp(CATdesign, objective=objective, all_index = TRUE)
#
# ## within a customNextItem() definition the above code would look like
# # customNextItem <- function(person, design, test){
# # objective <- computeCriteria(person=person, design=design, test=test,
# # criteria = 'MI')
# # item <- findNextItem(person=person, design=design, test=test,
# # objective=objective)
# # item
# # }
#
# ## End(Not run)
Run the code above in your browser using DataLab