Have an idea?

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

Randomizing with constructive list

I have a multiple select question with certains attributes are visible to respondnts based on some condtions. Here is the code I have used to buuld constructive list. All these attributes   needs to be randomized except the last one. When D2=1, attribute 3 & 4 will be invisible; D2=2, attribute 5 will be invisilbe. In this situation I am unable to randmize by specifiying StartMember# and EndMember# as the list will have different attributes based on the condtion each time.

Is there a way to not randomize the last attribute in any given members in the list?

Begin Unverified Perl
 {ADD("D29List",1); }
 {ADD("D29List",2);}
 if(VALUE("D2")==1)
 {ADD("D29List",3);}
 if(VALUE("D2")==1)
 {ADD("D29List",4);}
 if(VALUE("D2")==2)
 {ADD("D29List",5);} 
 {ADD("D29List",6);}
 if(VALUE("D26_C1")<4)
 {ADD("D29List",7);}
 {ADD("D29List",8);}
 {ADD("D29List",9);}
End Unverified
asked Jul 12, 2012 by Lawrence Bronze (2,100 points)
retagged Sep 13, 2012 by Walter Williams

2 Answers

0 votes
 
Best answer
lets assume your list above is named Con1, define another constructed list named con2 and set its parent to D29List as well. use the following logic to create con2
ADD(Con1)
RANDOMIZE(1,LISTLENGTH(con1)-1)
answered Jul 12, 2012 by Bahadir Ozkurt Gold (16,930 points)
Thanks Bahadir! Smart code.
0 votes
If you wanted to do it in just one list, you could think a little backwards about adding (removing):

ADD(D29List,1,8)
Randomize
ADD("D29List",9)

Begin Unverified Perl
if(VALUE("D2")==2)
{REMOVE("D29List",3,4)}
if(VALUE("D2") == 1)
{REMOVE("D29List",5,6)}
if(VALUE("D26_C1") >= 4)
{REMOVE("D29List",7,9);}
End Unverified
answered Jul 12, 2012 by Brian McEwan Gold Sawtooth Software, Inc. (38,315 points)
Both nice solutions by Brian and Bahadir. So many people don't use the power of the constructed list functions.
...