ata: Automated Test Assembly (ATA)

Description Usage Arguments Details Examples

View source: R/module3_ata.R

Description

ata creates an ata object

ata_obj_relative adds relative (maximize/minimize) objectives to LP

ata_obj_absolute adds absolute objectives to LP

ata_constraint adds a constraint to LP

ata_item_maxselect sets the maximum selection for items

ata_item_enemy adds enemy item relationship to LP

ata_item_fixedvalue sets a fixed value range for items

ata_solve solves the LP

ata_solve_lpsolve solves the LP using LpSolve

Usage

 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
ata(pool, nforms = 1, len = NULL, maxselect = NULL)

## S3 method for class 'ata'
print(x, ...)

## S3 method for class 'ata'
plot(x, ...)

ata_obj_relative(x, coef, mode = c("max", "min"), negative = FALSE,
  flatten = NULL, forms = NULL, collapse = FALSE)

ata_obj_absolute(x, coef, target, forms = NULL, collapse = FALSE)

ata_constraint(x, coef, min = NA, max = NA, level = NULL, forms = NULL,
  collapse = FALSE)

ata_item_maxselect(x, maxselect, items = NULL)

ata_item_enemy(x, items)

ata_item_fixedvalue(x, items, min = NA, max = NA, forms = NULL,
  collapse = FALSE)

ata_solve(x, as.list = TRUE, timeout = 10, mip_gap = 0.1,
  verbose = "neutral", warning = FALSE, ...)

ata_solve_lpsolve(x, ...)

Arguments

pool

item pool

nforms

the number of forms

len

the test length

maxselect

the maximum selection of each item

x

the ata object

...

further arguments

coef

the coefficients of the objective function or the constraint

mode

the optimization mode: 'max' for maximization and 'min' for minimization

negative

TRUE when the expected value of the objective function is negative

flatten

the flatten parameter to make the objective function flat

forms

the indices of forms where objectives are added. NULL for all forms

collapse

TRUE to collapse all forms into one objective function

target

the target of the objective function

min

the lower bound of the constraint

max

the upper bound of the constraint

level

the level value for categorical variable

items

a vector of item indices

as.list

TRUE to return results in a list; otherwise, data frame

timeout

the time limit in seconds

mip_gap

the mip gap parameter

verbose

the message parameter

warning

TRUE to output warning message when LP is not solved

Details

The ata object stores LP definitions in obj, mat, dir, rhs, types, bounds, max. When calling ata_solve, it converts these definitions to the real LP object. If solved successfully, two results are added to the object: result (a matrix of binary selection results) and items (a list or data frame of selected items).

To maximize the LP, it is to maximize y while subject to sum(x) - y >= 0 and <= F (flatten parameter). To minimize the LP, it is to minimize y while subject to sum(x) - y <= 0 and >= F. By default, y is non-negative. When negative=TRUE, y is set to be negative.
When coef is a pool-size or form-size numeric vector, coefficients are used directly. When coef is a variable name, variable values are used as coefficients. When coef is a numeric vector unequal to pool size, information at those points are used as coefficients.

ata_obj_absolute is to minimize y while subject to sum(x) + y >= T and sum(x) - y <= T.

For ata_constraint, set coef to a variable name and level a level of that variable to add a categorical constraint. Set coef to a variable name and leave level to default value (NULL or NA) to add a quantitative constraint. Set coef to a constant or a vector to add a constraint directly.

In ata_solve, additional control parameters will be passed into solvers. When passing control parameters to the GLPK solver, use the correct parameter name (see ?glpkAPI::glpkConstants).

Examples

 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
## Not run: 
library(dplyr)
## generate a 100-item pool
pool <- model_3pl()$gendata(1, 100)$items
pool$content <- sample(1:3, 100, replace=TRUE)
pool$time <- round(rlnorm(100, log(60), .2))

## ex. 1: 6 forms, 10 items, maximize b parameter
x <- ata(pool, 6, len=10, maxselect=1)
x <- ata_obj_relative(x, "b", "max")
x <- ata_solve(x)
sapply(x$items, function(x) {
  c(mean=mean(x$b), sd=sd(x$b), min=min(x$b), max=max(x$b))
}) %>% t() %>% round(., 2)

## ex. 2: 4 forms, 10 items, minimize b parameter
x <- ata(pool, 3, len=10, maxselect=1)
x <- ata_obj_relative(x, "b", "min", negative=TRUE)
x <- ata_solve(x, as.list=FALSE, timeout=5)
group_by(x$items, form) %>% 
  summarise(mean=mean(b), sd=sd(b), min=min(b), max=max(b)) %>%
  round(., 2)
  
## ex. 3: 2 forms, 10 items, mean(b) = 0, sd(b) = 1.0, content = (3, 3, 4)
x <- ata(pool, 2, len=10, maxselect=1) %>%
     ata_obj_absolute(pool$b, 0 * 10) %>%
     ata_obj_absolute((pool$b - 0)^2, 1 * 10) %>%
     ata_constraint("content", min=3, max=3, level=1) %>%
     ata_constraint("content", min=3, max=3, level=2) %>%
     ata_constraint("content", min=4, max=4, level=3)
x <- ata_solve(x, verbose="normal", timeout=5)
sapply(x$items, function(x) {
  c(mean=mean(x$b), sd=sd(x$b))
}) %>% t() %>% round(., 2)

# ex. 4: 2 forms, 10 items, flat TIF over [-1, 1]
x <- ata(pool, 2, len=10, maxselect=1) %>%
     ata_obj_relative(seq(-1, 1, .5), "max", flatten=0.05)
x <- ata_solve(x)
plot(x)

## End(Not run)

Example output

Attaching package: 'dplyr'

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

     mean   sd   min  max
[1,] 0.57 0.74 -0.08 1.57
[2,] 0.58 0.76 -0.28 1.49
[3,] 0.57 0.48 -0.18 1.38
[4,] 0.58 0.44 -0.19 1.14
[5,] 0.57 0.37  0.16 1.12
[6,] 0.56 0.31  0.08 1.10
# A tibble: 3 x 5
   form  mean    sd   min   max
  <dbl> <dbl> <dbl> <dbl> <dbl>
1     1 -1.12  0.42 -1.81 -0.65
2     2 -1.10  0.36 -1.86 -0.66
3     3 -1.11  0.33 -1.77 -0.70

Model name:  '' - run #1    
Objective:   Minimize(R0)
 
SUBMITTED
Model size:      116 constraints,     201 variables,         1392 non-zeros.
Sets:                                   0 GUB,                  0 SOS.
 
                     [           +0 < Z < Inf           ]
 
Using DUAL simplex for phase 1 and PRIMAL simplex for phase 2.
The primal and dual simplex pricing strategy set to 'Devex'.
 

Relaxed solution                   0 after         62 iter is B&B base.
 
Feasible solution                  1 after        225 iter,        15 nodes (gap 100.0%)
Improved solution               0.63 after        255 iter,        23 nodes (gap 63.0%)
Improved solution               0.28 after        360 iter,        48 nodes (gap 28.0%)
Improved solution                  0 after        799 iter,        99 nodes (gap 0.0%)
 
Optimal solution                   0 after        799 iter,        99 nodes (gap 0.0%).

Excellent numeric accuracy ||*|| = 1.77636e-15

 MEMO: lp_solve version 5.5.2.0 for 64 bit OS, with 64 bit LPSREAL variables.
      In the total iteration count 799, 366 (45.8%) were bound flips.
      There were 47 refactorizations, 0 triggered by time and 4 by density.
       ... on average 9.2 major pivots per refactorization.
      The largest [LUSOL v2.2.1.0] fact(B) had 240 NZ entries, 1.0x largest basis.
      The maximum B&B level was 34, 0.1x MIP order, 34 at the optimal solution.
      The constraint matrix inf-norm is 3.46, with a dynamic range of 346.
      Time to load data was 0.008 seconds, presolve used 0.001 seconds,
       ... 0.011 seconds in simplex solver, in total 0.020 seconds.
     mean   sd
[1,] 0.01 1.05
[2,] 0.02 1.06

xxIRT documentation built on Aug. 30, 2017, 5:06 p.m.

Related to ata in xxIRT...