This document explains how to create a constraint file. In test assembly, practitioners often want to select the items that satify various types of constraints.
As of TestDesign version 0.2, constraints can be read in from a .csv file. The file is expected to be in the following structure:
CONSTRAINT,TYPE,WHAT,CONDITION,LB,UB,ONOFF
1,Number,Item,,30,30,
2,Number,Item,LEVEL == 3,10,10,
3,Number,Item,LEVEL == 4,10,10,
4,Number,Item,LEVEL == 5,10,10,
5,Number,Item,STANDARD == 1,17,20,The constraint file should have 7 columns, named as CONSTRAINT, TYPE, WHAT, CONDITION, LB, UB, ONOFF on the first row of the file.
Beginning from the second row, each row should have the corresponding values for the 6 columns.
A convenient way to creating a .csv file is to use a spreadsheet application (e.g. Excel), work on the contents from there, and then saving it as a .csv file.
This column serves as indices for the constraints. A single numeric value should be put into this column, ascending by 1 per row.
This column specifies the type of constraint. The following values are expected: Number, Order, Enemy, Include, Exclude, AllorNone.
Number specifies the constraint to be applied to the number of selected items (if WHAT column is Item), or to the number of selected item sets (if WHAT column is Stimulus). For example, the following row tells the solver to select a total of 30 items.Order specifies the selection to be made in ascending order. The following row tells the solver to select the items in ascending LEVEL, based on the supplied item attributes.Enemy specifies the items (or item sets) matching the condition to be treated as enemy items. To tell the solver to select at most one of the two items:Include specifies the items matching the condition to be included in selection. For example, the following row tells the solver to include the two items SC00003 and SC00004:Exclude specifies the items matching the condition to be excluded in selection. The following row tells the solver to exclude the items satisfying PTBIS < 0.15, based on the supplied item attributes.AllorNone specifies the items matching the condition to be either all included or all excluded. To tell the solver to either select the items SC00005 and SC00006 at the same time or exclude them at the same time:This column specifies where the constraint is applied. The expected values are Item or Stimulus.
This column specifies the condition of the constraint. R expressions returning logical values (TRUE or FALSE) is expected. The variables supplied in item attributes can be used in the expression as variable names.
Some examples are:
"STANDARD %in% c(2, 4)" tells the solver to select when STANDARD is either 2 or 4."STANDARD %in% c(2, 4) & DOK >= 3" tells the solver to select when STANDARD is either 2 or 4, and also DOK is at least 3.!is.na(FACIT) tells the solver to select when FACIT is not empty.Also, Per Stimulus can be used to specify the number of items to select in each stimulus. For example, the following row tells the solver to select 4 to 6 items per stimulus:
These two columns specify the lower and upper bounds on the number of selected items. These columns should be specified when TYPE is Number, and should be left empty otherwise.
Some example rows are provided.
DOK >= 2:This column can be used to turn off a constraint from being applied. The following row specifies the order constraint to be not applied.