Have an idea?

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

Quota selection based on weight assigned

Hi All,

What client wante -  There was 5 options in list of which only one will be picked randomly but need to be based on weight as highlighted below.

•    QUESTIONS TO BE ASKED OF ONE NATURAL HAZARD ONLY
•    RANDOMISE SELECTION OF HAZARD
•    Weighting of hazard to be confirmed, initial recommendation as:
o     30% bushfire, 25% flood, 25% cyclone, 10% severe storm, 10% extreme heat


Problem - I had scripted the logic but it is not working as desired, currently it is going in linear rather than by weight and moreover if particular option got quota full still goes ahead and assign that.


Did scripting similar to https://sawtoothsoftware.com/forum/8648/choosing-quota-based-on-which-quota-has-more-interviews-left
asked May 30 by Nischay

2 Answers

0 votes
What version are you using?  In version 9.7.0 they have added a feature to the quota question where you can set it to assign based on lease fill either by counts or by percentages.  It sounds like least fill by percentages is what you are looking for.  That way it keeps the numbers even based on the percentage for the cell limits you set.  I'm currently using it on a project and it works quite well.
answered May 30 by Jay Rutherford Gold (31,960 points)
Hi Jay,

I am using 9.5.3 version, we haven't updated to new version as in past we had faced issues after update so currently using same version which we are been using for a while.

Can you advise how to work with current version or provide input what best can be work out.

Project is live and have pass through 50% of complete.

Can you
0 votes
You need a quota question with five cells.  Their values / codes should be the numbers 1 through 5, and their cell limits should be whatever limits you require.  Set the quota question to check for membership randomly.  Now set each quota cell's qualification logic to this:

Begin Unverified Perl
# Parameters
my $quotaName = 'QuotaQ';
my $thisCell = 1;
my @cellQualifications = (
    GETVALUE('SelectQ_1'),
    GETVALUE('SelectQ_2'),
    GETVALUE('SelectQ_3'),
    GETVALUE('SelectQ_4'),
    GETVALUE('SelectQ_5')
);

# Run
my $qual = 1;

if ($cellQualifications[$thisCell - 1]) {
    my $thisFill = QUOTACELLCOMPLETES($quotaName, $thisCell) / QUOTACELLLIMIT($quotaName, $thisCell);
    for (my $i = 1; $i <= scalar @cellQualifications; $i++) {
        if ($i != $thisCell && $cellQualifications[$i - 1]) {
            my $ithFill = QUOTACELLCOMPLETES($quotaName, $i) / QUOTACELLLIMIT($quotaName, $i);
            if ($ithFill < $thisFill) {
                $qual = 0;
                last;
            }
        }
    }
}
else {
    $qual = 0;
}

return $qual;
End Unverified


Line 3 must be updated with the name of the quota question.  Line 4 must be updated with the current cell value (1 for the first cell, 2 for the second, etc.).  Lines 6 - 10 must be updated with the normal qualification logic for each cell; I have assumed a checkbox-type select question.
answered May 30 by Zachary Platinum Sawtooth Software, Inc. (123,825 points)
Hi Zachary thank you so much for jumping here.  Just one small query before i implement this and test my study. My 5 option don't have any condition it is random selection so should I create dummy vairable with all 5 selection and then update following variable in line 6-10 to respective multi response? "SelectQ_1, SelectQ_2 ..."
All respondents qualify for answering any hazard?  Then here's the same code without qualification:

Begin Unverified Perl
# Parameters
my $quotaName = 'QuotaQ';
my $thisCell = 1;
my $numberOfCells = 5;

# Run
my $qual = 1;

my $thisFill = QUOTACELLCOMPLETES($quotaName, $thisCell) / QUOTACELLLIMIT($quotaName, $thisCell);
for (my $i = 1; $i <= $numberOfCells; $i++) {
    if ($i != $thisCell) {
        my $ithFill = QUOTACELLCOMPLETES($quotaName, $i) / QUOTACELLLIMIT($quotaName, $i);
        if ($ithFill < $thisFill) {
            $qual = 0;
            last;
        }
    }
}

return $qual;
End Unverified


Note the new parameter that represents the total number of quota cells.
thank you so much, will get back after testing if any query. Once again thank you for saving my life
Hi Zachary,

I tested 16 records and it works properly. Will have more testing on this before I put back on LIVE.

Thanks you so much.
...