note
fizbin
Yeah, it appears to be a perl bug, as I've now gotten something that demonstrates this problem without using AI::Genetic:<p>
<code>
#!/usr/bin/perl
use strict;
use warnings;
package yo;
use Data::Dumper;
sub my_f {
my $genes = shift;
my @order = (0,1,2,3);
my @sorted = sort {
local $SIG{__WARN__} = sub {print Dumper($a,$b); print @_; sleep 1;};
$genes->[$a] <=> $genes->[$b]
} @order;
my $score = $sorted[1] + 2*$sorted[2] + 3*$sorted[3];
print "DEBUG: score was $score\n";
return $score;
}
package main;
$|=1;
my @populace = map { [ map {rand 100;} (1..4) ] } (1..100);
my @spopu = sort {yo::my_f($a) <=> yo::my_f($b)} @populace;
</code>
Well, hell. This sucks - I wonder if this is a documented perl bug anywhere?
<div class="pmsig"><div class="pmsig-246930">
<code>--
@/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/;
map{y/X_/\n /;print}map{pop@$_}@/for@/</code>
</div></div>
433559
433559