class FitnessProportionateSelectionOperator extends AbstractProportionateSelectionOperator {

    protected List<Individual> selectWinners(Individual[] inputIndividuals, double[] accumulatedProbabilities){
        int resultSize = this.outputArity * this.individualsPerPopulation;
        List<Individual> resultingIndividuals = new ArrayList<Individual>(resultSize);
        for (int i = 0; i < resultSize; i++){
            double probability = this.randomGenerator.nextRandom();
            // select first individual which accumulated probability is bigger or equal to current random number
            for (int j = 0; j < inputIndividuals.length; j++){
                if (accumulatedProbabilities[j] >= probability){
                    resultingIndividuals.add(inputIndividuals[j]);
                    break;
                }
            }
        }
        return resultingIndividuals;
    }

}