Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

More than one group

Hi all,

Thank you for this explanation. It works very well for one group. But I have more than one group.
For example,
and I want randomize these blocks, but the most important thing that they will be randomly positioned amongst Items 1-11,14.
1-4 not always be positioned at 1-4.
How can I do this with sysrand?
Thanks for helping.
asked Feb 9, 2015 by anonymous

1 Answer

0 votes
The technique I provided you with in October 2014 was ideal for the random insertion of one group. If I was to use that technique for multiple groups, I would run into trouble with the possibility of inserting a group within a group. Obviously you don't want that happening.

So let's go with this solution ...

Assume we have 14 items. I have defined the groups as follows ...

Group 1 - items 1-4
Group 2 - items 5-7
Group 3 - items 8-11,14
Group 4 - items 12-13

ItemsList is a parent list that defines Item1-Item14 ...

1 Item1
2 Item2
3 Item3
4 Item4
5 Item5
6 Item6
7 Item7
8 Item8
9 Item9
10 Item10
11 Item11
12 Item12
13 Item13
14 Item14

Create a parent list called OrderList ...

 1 1
 2 2
 3 3
 4 4

Now create a constructed list called OrderConList (this helps randomise the 4 groups) ...

Create 4 constructed lists (see below) and name them Group1ConList to Group4ConList. Name them exactly as I have as the programming will fail otherwise.





These 4 constructed lists get 4 groups of items separately and randomise each.

This final constructed list (call it GroupsConList) collates the 4 randomised groups. Remember we are randomising items within each group and then the OrderConList randomises the display order of each group (which you will see in GroupsConList).
Begin Unverified Perl

End Unverified 

Give it a go. Good luck.
answered Feb 10, 2015 by Paul Moon Platinum (59,425 points)
I have tested it out. Works a treat.

And remember, Perl is case sensitive so tread carefully with the way you write your functions within your Perl script.
Thank you very much. It works well!