Creating constraints in TestDesign package

Sangdon Lim


Introduction

This document explains how to create constraints data for loadConstraints(). In test assembly, practitioners often want to select items satisfying various types of constraints. As of TestDesign version 1.1.0, constraints can be read in from data.frame objects or .csv spreadsheet files. Data 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

Constraints data must have seven columns, named as CONSTRAINT, TYPE, WHAT, CONDITION, LB, UB, ONOFF on the first row. Beginning from the second row, each row must have corresponding values for each column. A convenient way to creating constraints is to use a spreadsheet application (e.g. Excel) and work on the content from there.



CONSTRAINT

This column serves as indices. One number must be put into each row, beginning from 1 and incrementing by 1. loadConstraints() recreates these if necessary.



TYPE

This column specifies the type of constraint. Following values are expected: Number, Order, Enemy, Include, Exclude, AllorNone.


CONSTRAINT TYPE WHAT CONDITION LB UB ONOFF
1 Number Item 30 30



CONSTRAINT TYPE WHAT CONDITION LB UB ONOFF
2 Sum Item WORDS 500 600



CONSTRAINT TYPE WHAT CONDITION LB UB ONOFF
32 Order Item LEVEL



CONSTRAINT TYPE WHAT CONDITION LB UB ONOFF
33 Enemy Item ID %in% c(“SC00001”, “SC00002”)



CONSTRAINT TYPE WHAT CONDITION LB UB ONOFF
34 Include Item ID %in% c(“SC00003”, “SC00004”)



CONSTRAINT TYPE WHAT CONDITION LB UB ONOFF
35 Exclude Item PTBIS < 0.15



CONSTRAINT TYPE WHAT CONDITION LB UB ONOFF
36 AllOrNone Item ID %in% c(“SC00005”, “SC00006”)



WHAT

This column specifies the unit of assembly the constraint uses. Expected values are Item or Stimulus.



CONDITION

This column specifies the condition of the constraint. An R expression 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:

For TYPE == SUM, using a variable name imposes the constraint on the sum of the variable. The following row tells the solver to keep the sum of WORDS between 500–600.

CONSTRAINT TYPE WHAT CONDITION LB UB ONOFF
2 Sum Item WORDS 500 600

For TYPE == SUM, constraints on conditional sums can be imposed by using a variable name, placing a comma, and then giving an R expression returning logical values. The following row tells the solver to keep the sum of WORDS within DOK == 1 items between 50–80.

CONSTRAINT TYPE WHAT CONDITION LB UB ONOFF
3 Sum Item WORDS, DOK == 1 50 80

In set-based assembly, 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:

CONSTRAINT TYPE WHAT CONDITION LB UB ONOFF
3 Number Item Per Stimulus 4 6



LB and UB

These two columns specify lower and upper bounds on the number of selected items. These must be specified when TYPE is Number, and otherwise must be left empty.

Some example rows are provided.

CONSTRAINT TYPE WHAT CONDITION LB UB ONOFF
1 Number Item 12 12



CONSTRAINT TYPE WHAT CONDITION LB UB ONOFF
17 Number Item DOK >= 2 15 30



ONOFF

Set this to OFF to turn off the constraint from being applied. ON or leaving it blank applies the constraint. The following example specifies the order constraint to be not applied.

CONSTRAINT TYPE WHAT CONDITION LB UB ONOFF
18 Order Passage CONTENT OFF