Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

How to do it with no AI::Genetic hacks

by fizbin (Chaplain)
on Feb 23, 2005 at 16:06 UTC ( #433732=note: print w/replies, xml ) Need Help??


in reply to Re^2: Looking for help with AI::Genetic and classroom scheduling
in thread Looking for help with AI::Genetic and classroom scheduling

As halley pointed out to me in node 433726, there is in fact a way to avoid the necessity of changing AI::Genetic at all, though it requires a small use of prototyping, which I know you abhor, to make it work.

In my version, you just have to write the make_config sub like this:

sub make_config { my (@genes) = @_; # sort classes in order by genes: # stupid #!@#!#$! sort bug my $sortsub = sub ($$) { my ($a,$b) = @_; $genes[$a] <=> $genes[$b]; }; my (@sclasses) = @CLASSES[sort $sortsub (0..$#CLASSES)]; push(@sclasses, (qw{XXX}) x ($SLOTS * $ROOMS)); my ($config) = []; for my $s (0..$SLOTS-1) { push @$config, []; for my $r (0..$ROOMS-1) { my $i=0; while (!is_acceptable($sclasses[$i],$s,$r,$config)) {$i++;} push @{$config->[-1]}, splice(@sclasses,$i,1); } } $config; }
-- @/=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://433732]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2023-12-10 17:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (40 votes). Check out past polls.

    Notices?