On 07/30/2012 03:52 PM, monarch_dodra wrote:
... Your looks OK, and I doubt you are mutating. I only see floating point gotchas: If a chromosome travels nothing, then his fitness is 1/0 = NaN.
1/0 evaluates to Inf
NaN then compares false with everything, making it un-transitive, and potentially breaking your cmp. COuld you try the algo with "return 1/(1+travelled)". That, or because of the non-deterministic nature of floating point calculation,
Floating-point computation is deterministic.
I'd create an array containing all the fitnesses, and sort using that. This should avoid any "re-evaluation error".