Re: GA Newbie and some Java Code



On Mon, 18 Dec 2006 20:32:44 -0000, <rufuspudge@xxxxxxxxx> wrote:

My first question is, does that imply a string of all ones should be
discovered within 20 runs in the majority of cases? My code doesn't
seem to work right as it can take upwards of 700,000 runs to generate a
string of all ones. I understand that I'm not using any elitism or
other tweaks to "evolution".

700,000 sounds way too high. I haven't run your code but, looking through it, there seems to be a bug in your getParents method. You are writing to the same array that you are reading from (you have just aliased it with another reference). You probably want the possibleParents array to be a new array rather than re-using the population array. Otherwise, your selection will be self-reinforcing and potential parents will be lost at every iteration.

Dan.

--
Daniel Dyer
http://www.uncommons.org
.