## WeBWorK Main Forum

### Error: Cannot generate enough valid points for comparison

by Patrick Spencer -
Number of replies: 6
We've been having a sporadic glitch on a specific homework problem. Every once in a while it gives the following error: "Cannot generate enough valid points for comparison". I've seen people ask this problem before on this forum and the solution seems to change the parameter "limits" when calling the cmp() method. For example something like this:
ANS($ans->cmp(limits=>[0,1])); We've implemented this on the problem but something it still throws the same error on some seeds (specifically seed value 1728). I've changed the limits interval to different values but to no avail. I was wondering if someone could tell us what we're doing wrong. I've attached a screenshot of the error and Ive included the problem file below (I've highlighted the limit declaration part). Also, this happens on a MultiAnswer problem so perhaps that has something to do with it. Thank you! Patrick Spencer Problem file source: DOCUMENT(); loadMacros( "MathObjects.pl", "PeriodicRerandomization.pl", "PGstandard.pl", "contextLimitedPowers.pl", "parserMultiAnswer.pl", "unionTables.pl", "AnswerFormatHelp.pl", ); TEXT(beginproblem()); PeriodicRerandomization("3");$showPartialCorrectAnswers = 1;

###########################################################################
# setup contexts and variables
###########################################################################
Context("Numeric");
LimitedPowers::OnlyPositiveIntegers();
@vars = ("x","y","z","r","s","t","m","n","p","q");
$ch1 = random(0,scalar(@vars)-1,1); do {$ch2 = random(0,scalar(@vars)-1,1)} until ($ch2 !=$ch1);
$v1 =$vars[$ch1];$v2 = $vars[$ch2];
Context()->variables->are($v1=>"Real",$v2=>"Real");

$a = random(2,13);$a2 = ($a)**2;$p = 2*random(1,7);
$q = list_random(1,2,4,6,8,10);$case = random(0,1,1);
if ($q == 1) {$case = 0;
}

if ($case == 0) {$f = ($q != 1) ? "\sqrt{\frac{$v1^{$p}$v2^{$q}}{$a2}}" : "\sqrt{\frac{$v1^{$p} $v2}{$a2}}";
$num = ($q != 1) ? Formula("$v1^{$p/2} $v2^{$q/2}")->reduce : Formula("$v1^{$p/2} sqrt($v2)")->reduce;$den = Formula("$a"); } else {$f = ($q != 1) ? "\sqrt{\frac{$v1^{$p}}{$a2 $v2^{$q}}}" : "\sqrt{\frac{$v1^{$p}}{$a2$v2}}";
$num = Formula("$v1^{$p/2}")->reduce;$den = ($q != 1) ? Formula("$a $v2^{$q/2}")->reduce : Formula("$a sqrt($v2)")->reduce;
}

$multians = MultiAnswer($num, $den)->with( singleResult => 0, allowBlankAnswers => 1, checker => sub { my ($correct, $student,$self ) = @_;
my ( $c1,$c2 ) = @{$correct}; my ($s1, $s2 ) = @{$student};
my ( $r1,$r2 ) = (0,0);
$s1 = Formula($s1) unless ($s1->type eq 'Formula' ||$s1->type eq 'String');
$s2 = Formula($s2) unless ($s2->type eq 'Formula' ||$s2->type eq 'String');
$s1 = Formula("0.1$v1^{1000}") if ($s1->type eq 'String'); #bogus answer$s2 = Formula("0.01$v2^{500}") if ($s2->type eq 'String'); #bogus answer
$r1 = 1 if ($c1 == $s1);$r2 = 1 if ($c2 ==$s2);
($r1,$r2) = (1,1) if ($c1 == -$s1 && $c2 == -$s2);
if ($c1*$s2 == $c2*$s1 && $c1 !=$s1 && $c1 != -$s1) {
$self->setMessage(1,"Your answer can be simplified further");$self->setMessage(2,"Your answer can be simplified further");
}
return [$r1,$r2];
}
);

if ($displayMode eq 'TeX') {$displayfrac =
"$f = ".multians->ans_rule(10).multians->ans_rule(10)."$";
} else {
$displayfrac = ColumnTable( "$$\displaystyle f =$$",$multians->ans_rule(20).$BR.$HR.multians->ans_rule(20), indent => 0, separation => 10, valign => "MIDDLE" ); }num->{limits} = [100,101];
$den->{limits} = [100,101]; ########################################################################### # state the problem ########################################################################### Context()->texStrings; BEGIN_TEXT Simplify the radical expression. Assume that all variables represent positive quantities.$PAR
$BCENTER$displayfrac
$ECENTER$BR
END_TEXT

###########################################################################
###########################################################################
ANS($multians->cmp()); ########################################################################### # use PeriodicRerandomization to write the answer and generate a new # version of the problem ########################################################################### if ($attempts_modp == 0 && $actualAttempts != 0) { BEGIN_TEXT$PAR
${BBOLD}Answer:${EBOLD} $$\displaystyle \frac{num}{den}$$
$PAR END_TEXT } else { BEGIN_TEXT$PAR
${BBOLD}Help:${EBOLD}
$BR END_TEXT } Context()->normalStrings; PeriodicStatus(); COMMENT('Features Periodic Rerandomization'); ENDDOCUMENT() In reply to Patrick Spencer ### Re: Error: Cannot generate enough valid points for comparison by Alex Jordan - When I load this problem with seed 1728, I do not get the version that is in the screen shot, and I don't get the error. Maybe it matters what version of webwork2 and pg you are using. Can you confirm the seed, and give the version numbers? You may want to notice that this problem is not preventing a student from just splitting the radical into the numerator and denominator. In my version, the given problem was sqrt(x^12p^8/121). If I enter sqrt(x^12p^8) in the first answer blank, and sqrt(121) in the second, the problem is marked fully correct. For radical simplification problems, consider contextLimitedRadical.pl. The notes at the top of the file explain how to use it. You wouldn't need multiAns with two answer blanks, just one for the final answer. (As it is currently written, this context will not allow x^(1/2) in place of sqrt(x), etc., which may be worth noting.) In reply to Alex Jordan ### Re: Error: Cannot generate enough valid points for comparison by Paul Pearson - Hi Patrick, I would recommend setting the domain of each variable in the context separately. For instance, Context()->variables->are($v1=>"Real", $v2=>"Real"); Context()->variables->set($v1=>{limits=>[2,5]});
Context()->variables->set(\$v2=>{limits=>[2,5]});

You'll probably also need to remove the other places where you tried to set the domain (limits).

Best regards,

Paul Pearson

### Re: Error: Cannot generate enough valid points for comparison

by Christian Seberino -
Alex

I don't know how to get the seed.  Even more mysterious...I'm not sure why different clients would use different seeds on the server.

### Re: Error: Cannot generate enough valid points for comparison

by Christian Seberino -
I found the seed even thought I just realized you weren't asking me.  For my same issue the problem seed was 669 if that helps.

### Re: Error: Cannot generate enough valid points for comparison

by Alex Jordan -
(These last few messages, including this one, are actually supposed to be in this related thread.)

For the error issue, I think that Paul has got your answer.

As I noted, this problem still won't truly be asking the students to simplify the expression though.

As for seeds, problems employ randomization, so that one student's version is different from her neighbor's version. But there needs to be a record of specifically which version is for which student, so that a student could log off, log on again, and see the same version. This is where seeds come in. A seed number (randomly generated) is stored for each student, for each problem. When the problem is compiled, all of the randomization in the problem is based from the seed. Also while you are editing a problem or viewing it in the Browser, some seed is used there as well. You have control over this seed in the problem Editor.

The seed matters for what was happening here, because the seed controls which random test points are used for comparing the formulas. Some seed was producing too many negative test values for the two variables.