Have an idea?

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

Taking least filled quota based on selection

I'm trying to fill (roughly) evenly fill a quota with 3 cells. I know how to implement a simple least fill algorithm (e.g., fill cell 1 if cell 1 is <= cell 2 and <= cell 3), but I also want to fill this quota based on a multiple selection question where respondents can indicate whether they belong to group 1/2/3.

I'd like the logic to operate as: respondents fill the quota for which their selection matches when all quota cells are open; if they select multiple groups, they get assigned to the quota cell that is least full; if they select a group or groups whose quota cells are closed, they get assigned to the least full cell remaining. Many thanks!
asked Sep 3, 2014 by bbedore (210 points)

1 Answer

+1 vote
 
Best answer
It's bit tricky, you need to check this in constructed list. Then you need to check constructed list's first item for assigning brand.

I am going to  explain this with detail example.  Let's say we have Q1 question as multiple select question with 3 options and we had set up Quota "Brand". Now we need to add brand from Q1List based on least fill. I am going to create constructed list "AssignBrand"

Begin Unverified Perl
my $sum1=99999;
my $sum2=99999;
my $sum3=99999;




my @sum_value;
my @sum_min;


if(VALUE('Q1_1')==1 and ISQUOTACELLOPEN('Brand',1) )
{
     $sum1=QUOTACELLCOMPLETES("Brand",1);
}
if(VALUE('Q1_2')==1 and ISQUOTACELLOPEN('Brand',2) )
{
     $sum2=QUOTACELLCOMPLETES("Brand",2);
}
if(VALUE('Q1_3')==1 and ISQUOTACELLOPEN('Brand',3) )
{
     $sum3=QUOTACELLCOMPLETES("Brand",3);
}
    
    
$sum_value[0][0]=$sum1;
$sum_value[1][0]=$sum2;
$sum_value[2][0]=$sum3;

$sum_value[0][1]="1";
$sum_value[1][1]="2";
$sum_value[2][1]="3";


@sum_min=sort{$a->[0]<=>$b->[0]}@sum_value;
ADD("Q1List",$sum_min[0][1]);

End Unverified


For Quota questions, you need to check logic using constructed list first item. So logic would be  ListValue(AssignBrand,1)=1 for cell 1, ListValue(AssignBrand,1)=2 for cell 2 and ListValue(AssignBrand,1)=3 for cell 3.

Let me know for any clarification.
answered Sep 3, 2014 by Rajesh Rana Gold (23,430 points)
selected Sep 4, 2014 by bbedore
...