SETALLOCATIONS directive
Runs through all ways of allocating a set of objects to subsets.
Options
Parameters
Description
The SETALLOCATIONS directive allows you to form all the ways in which a set of objects can be allocated to subsets. For example, suppose we have 4 objects numbered 1 ... 4 to allocate to two subsets of size 2. There are 6 possible ways of forming the allocations: {1, 2 : 3, 4}, {1, 3 : 2, 4}, {1, 4 : 2, 3}, {2, 3 : 1, 4}, {2, 4 : 1, 3} and {3, 4 : 1, 2}. If, however, the ordering of the subsets is unimportant, there are only three. For example {1, 2 : 3, 4} is then the same as {3, 4 : 1, 2}.
The sizes of the subsets are specified by the SETSIZE parameter, and the UNIQUE option can be set to yes to indicate that their ordering is unimportant (so only unique allocations are then formed). The NREQUIRED option indicates how many allocations you want to form (default 1). You can use the NPOSSIBLE option to find out how many allocations are possible. The NFOUND option is useful if you request more allocations than are possible - it indicates how many allocations SETALLOCATIONS has actually been able to find.
The GROUPS option saves the allocations in factors (each with a level for each subset). If NREQUIRED = 1, it saves a single factor. Aternatively, if NREQUIRED is greater than one, it saves a pointer containing NFOUND factors.
As an alternative, the ELEMENTS parameter allows you to save the allocations in variates. For example
SETALLOCATIONS 2,2; ELEMENTS=Sub1, Sub2
saves the first subset in variate Sub1 and the second in variate Sub2. Just one allocation has been formed here as the NREQUIRED option has default 1. If several allocations are formed, ELEMENTS saves them in pointers to variates. For example
SETALLOCATIONS [NREQUIRED=3] 2,2; ELEMENTS=Sub1, Sub2
saves three allocations: (Sub1[1] : Sub2[1]), (Sub1[2] : Sub2[2]), and (Sub1[3] : Sub2[3]). By default, the variates will contain the positive integers 1, 2 upwards, but you can supply a variate containing others using the UNITS option.
By default, the first allocation is a partitioning of the objects in the same ordering as in the UNITS variate (or numerical order if UNITS is not set). However, if you want to run through the allocations in order, you can save the current allocation using the GROUPS option, and then use this as the setting of the START option to get the next one. For example, the following program runs through all the allocations of seven objects into subsets of size 2, 3 and 2.
SETALLOCATIONS [NPOSSIBLE=Nposs; GROUPS=Alloc] 2,3,2
CALCULATE Ntimes = Nposs - 1
FOR [INDEX=i; NTIMES=Ntimes]
DUPLICATE Alloc; NEWSTRUCTURE=Start
SETALLOCATIONS [NREQUIRED=1; GROUPS=Alloc; START=Start]\
2,3,2
" use allocation Alloc "
ENDFOR
Options: NREQUIRED, UNIQUE, NFOUND, NPOSSIBLE, GROUPS, UNITS, START.
Parameters: SETSIZE, ELEMENTS.
Action with
RESTRICT
Not relevant.