Your fitness function should have a good gradient over the entire search space. Some impossible schedules are more impossible than others. Take off X points for each instructor conflict, Y points for each room conflict, etc. You'll get continually closer to a valid schedule.
And that's also the "aha!" that I had when I wrote the code I pasted earlier. I was thinking too literally in terms of genetics. I would have considered "impossible" solutions as "stillborn" offspring that should never exist to roam around and mate, so I was stumped trying to figure out how to prevent such an individual from ever ending up in the gene pool.
Once I realized that I could just put them in the "undesirable" category by dinging them for unworkabilities, the GA did the right thing, and kept mixing up the "least undesirable", and within a dozen generations, I had a breeding population that was "in the black" (all hard constraints satisified, and thus now working on optimizing the soft constraints).
Well, I learned something. This is always a good thing.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||