Yeah, it appears to be a perl bug, as I've now gotten something that demonstrates this problem without using AI::Genetic:
#!/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;
Well, hell. This sucks - I wonder if this is a documented perl bug anywhere?
--
@/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/;
map{y/X_/\n /;print}map{pop@$_}@/for@/
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|