Forum archive 2000-2006

bpollina@c... - Problem with number_list_cmp

bpollina@c... - Problem with number_list_cmp

by Arnold Pizer -
Number of replies: 0
inactiveTopicProblem with number_list_cmp topic started 9/10/2003; 10:12:21 PM
last post 9/11/2003; 11:40:52 PM
userbpollina@c... - Problem with number_list_cmp  blueArrow
9/10/2003; 10:12:21 PM (reads: 872, responses: 2)

Has anyone experienced problems using the macro number_list_cmp in extraAnswerEvaluators.pl?  I have pg problems which worked in 1.7, but not in 1.9.  Specifically, lists are evaluated as incorrect if not in a particular order, even though the order has not been set to strict.

Ben Pollina 

<| Post or View Comments |>


userMark Schmitt - Re: Problem with number_list_cmp  blueArrow
9/11/2003; 6:40:04 AM (reads: 1089, responses: 0)
I also had problems with number_list_cmp.  I was able to fix the problem, I think.

The error messages, as I recall them, had empty calls to PGsort, which was in PGtranslator.pm

There was a note in PGtranslator:  (~ line 1441)

    "This sort can cause trouble because of its special use of $a and $b. 
     Putting it in dangerMacros.pl worked frequently, but not always.

I commented out lines 1446-1450 in PGtranslator, as well as line 287 in PGtranslator, then moved the subroutine PGsort to dangerousMacros.  It has seemed to work fine for me.


-Mark

<| Post or View Comments |>


userJohn Jones - Re: Problem with number_list_cmp  blueArrow
9/11/2003; 11:40:52 PM (reads: 1116, responses: 0)
Hi,

I am open to suggestions on how to best modify this.  I will try to outline how/why sorting is involved.

In matching unordered lists of numbers, two basic algorithms suggested themselves

  • sort both lists and then match them up
  • take the first item from list 1, find a match in list two, then remove those two, and the proceed with the next item from list 1, ...
The problems with the second approach are that it would be less efficient, and if tolerances are too loose (relative to the list entries), it may mark the problem incorrectly.

For sorting, I tried to tap into perl's sorting algorithm which should be fast and efficient, but as noted, this can be tricky.  I could build an old fashioned bubble sort into the routines.  That would avoid calling perl's sort.  It is inefficient for long lists, but this routine is rarely used on lists of 4 or more.

Thoughts?

John

<| Post or View Comments |>