Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: AI::Genetic gives me strange warnings

by fizbin (Chaplain)
on Feb 23, 2005 at 04:30 UTC ( [id://433570]=note: print w/replies, xml ) Need Help??


in reply to Re: AI::Genetic gives me strange warnings
in thread AI::Genetic gives me strange warnings

Right - the second time you try that sort, $a and $b are undef each time the block is evaluated. Furthermore, it appears that sort-within-sort only breaks if the inner sort is in a different package than the outer sort, as you'll notice that when I do the sort myself (inside main) there's no problem.

Also, see my other reply that exhibits this phenomenon without using AI::Genetic.

-- @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

Replies are listed 'Best First'.
Re^3: AI::Genetic gives me strange warnings
by Tanktalus (Canon) on Feb 23, 2005 at 15:10 UTC

    As ugly as it seems, a workaround (not denying a likely perl bug here) is to use $::a and $::b in the inner sort. Which may mean patching AI::Genetic... although I don't know what that will do during non-embedded sorts.

      Actually, there's a much, much easier patch to AI::Genetic that doesn't potentially screw up other non-embedded sorts. I've already communicated this to the AI::Genetic author, but you can see what's necessary in (the updated) 433606. It relies on the fact that individuals in an AI::Genetic population remember their score values once they've computed them. (Which is necessary for even vaguely decent performance when the fitness function gets a bit hairy)

      It's a very small three-line change, and does leave open the possibility of people screwing with the internals of the AI::Genetic object if they assign to $_, but you shouldn't be assigning to $_ in any case without using local to limit the effects of your changes.

      Also note that it's not the inner sort you'd be changing if you're changing AI::Genetic but the outer sort; the inner sort is already inside package main.

      -- @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://433570]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-26 09:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found