Description Usage Arguments Value Characteristics specification Constraint specification Return object Note about length Examples
Get a list with characteristics and constraints which can be used in lp
function from lpSolve
package.
1 2 | constraints_lp_format(max_n, number_items, characteristics = NULL,
constraints = NULL)
|
max_n |
Test length at which testing should stop. |
number_items |
Number of items available in the item bank. |
characteristics |
Data frame with characteristics, see |
constraints |
List of constraints, see |
List containing characteristics and constraints in lp format;
the maximum test length is always included as an additional constraint; see details
.
characteristics
should be specified as a data frame of characteristics. Each row indicates the characteristics of
one item. Each column indicates how all items score on a certain characteristic. Characteristics may be categorical or numeric.
constraints
should be specified as a list of constraints, each constraint is a list with three named values:
name
The column name of the characteristic this constraint applies to. For categorical characteristics the level should be specified as name/value
,
where name
is the column name of the characteristic and value
is the specific level of the characteristic this constraint applies to.
op
The logical operator to be used. Valid options are "<"
, "="
, ">"
and "><"
.
target
The target value, numeric. For categorical characteristics, it indicates the number of items of the relevant characteristic that should be administered ("="
), or
minimally (">"
), maximally ("<"
), or minimally and maximally ("><"
; vector with two values required) administered. For numeric characteristics,
it indicates the minimum and/or maximum sum allowed over all administered items, e.g., maximum time allowed.
The constraints and characteristics in lp format will be stored within a list. Setting the constraints and characteristics arguments to NULL results in a list with only the test length constraint. Constraints in Shadow Tests are implemented through linear programming, for which the package lpSolve is used. The returned constraints object is a list with two named elements; lp_constraints and lp_chars. The lp_constraints and lp_chars are set up to work with lpSolve, and should not be manually edited.
Note that the maximum test length is always included as an additional constraint.
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 | max_n <- 30
number_items <- 50
# set up some dummy characteristics.
content <- sample(c('algebra','physics','calculus'), number_items, TRUE)
time <- runif(number_items)
exclusive <- rep(0, number_items)
exclusive[sample(number_items, 4)] <- 1
# bind them in a data.fame
characteristics <- data.frame(content, time, exclusive)
# set up the constraints
constraints <- list(
list(name = 'content/algebra',
op = '><',
target = c(5,10)),
list(name = 'content/physics',
op = '><',
target = c(2,5)),
list(name = 'time',
op = '<',
target = 20),
list(name = 'exclusive',
op = '<',
target = 2))
# get list of characteristics and constraintrs in lp format
ShadowCAT:::constraints_lp_format(max_n = max_n,
number_items = number_items,
characteristics = characteristics,
constraints = constraints)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.