GMUEClab / ecj

ECJ Evolutionary Computation Toolkit
http://cs.gmu.edu/~eclab/projects/ecj/
123 stars 42 forks source link

ListCrossoverPipeline C_TWO_POINT always fail to produce new child #75

Open ZvikaZ opened 3 years ago

ZvikaZ commented 3 years ago

I've noticed that my individuals (using GE) are each copy of a single parent from previous generation (unless mutated). Debugging this, it seems that the problem is at ListCrossoverPipeline.java:

                        if (split[i][0] > split[i][1])  // swap so 0 is before 1
                            {
                            int temp = split[i][0];
                            split[i][0] = split[i][1];
                            split[i][1] = temp;
                            }

                        int len = split[i][0] - split[i][1];
                        if (len >= min_chunks[i] && len <= max_chunks[i])  // okay
                            {
                            split[i][0] *= chunk_size;
                            split[i][1] *= chunk_size;
                            break;
                            }
                        attempts++;
                        if (attempts > numTries) break;  // uh oh
                        }

If makes sure that split[i][0] <= split[i][1], which means that len <= 0. However, min_chunks[i] is non negative, thus if (len >= min_chunks[i] && is false, and the code never succeed (unless, split[i][0] == split[i][1]), but that probably won't do much...)