http://qs1969.pair.com?node_id=433087


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

This is what I get for going a weekend without reading all of perlmonks - I miss out on discussions like this.

Note that another way to deal with the problem of disallowed configurations is to narrow the search space to exclude them by having the individuals in your population be things that generate an acceptable layout, rather than being a layout directly.

For example, instead of a listvector gene sequence based on slots, you could do a rangevector gene based on available courses - these genes would then represent priority values for the courses. In the scoring phase, you'd use the gene values to sort the courses and you'd then fill in the slots one after another, each time using the highest priority acceptable course.

Well that explanation was clear as mud. Let me attempt to code it up and I'll post a reply - the code is probably clearer.

Update: This approach won't work immediately, because of the perl bug described in 433559. There's a way to patch AI::Genetic to work around the perl bug, but I don't think that there's any way to work around it short of tweaking AI::Genetic. (It's a one-line patch, though)

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