class GenotypeUniformCrossoverReproductionOperator extends AbstractUniformCrossoverReproductionOperator {

    @Override
    protected void reproduceInternal(Individual[] firstChildren, Individual[] secondChildren, int retSize) {
        for (int i = 0; i < retSize; i++){
            GenotypeRepresentation firstRepresentation = ((GenotypeRepresentation)firstChildren[i].getRepresentation());
            GenotypeRepresentation secondRepresentation = ((GenotypeRepresentation)secondChildren[i].getRepresentation());

            double parentFitness = Math.max(firstChildren[i].getFitness(), secondChildren[i].getFitness());
            firstChildren[i].setParentFitness(parentFitness);
            secondChildren[i].setParentFitness(parentFitness);
            
            // finally crossover of values
            int totalLength = firstRepresentation.getTotalLength();
            for (int j = 0; j < totalLength; j++){
                // if probability is high, then swap corresponding values
                if (this.crossoverProbability > 0.0 && this.randomGenerator.nextRandom() <= this.crossoverProbability){
                    firstRepresentation.swapGenes(secondRepresentation, j, j+1);
                }
            }
        }
    }

}