@Override
    public void calculateFitness(List<Individual> population) throws Exception{
        for(int i = 0; i < population.size(); i++){
            try{
                population.get(i).fitness();
            }catch (Exception e){
                int fitnessFactor = 0;
                MaxOnePheno pheno = (MaxOnePheno) population.get(i).phenotype();
                int[] phenoArray = pheno.pheno;
                //Blow up targetString and compare each bit
                if(targetArray != null && targetArray.length != phenoArray.length){
                    throw new Exception("Phenotype and bit string not of equal length!");
                }

                for(int j = 0; j < phenoArray.length; j++){
                    if(targetArray != null && phenoArray[j] == targetArray[j]){
                        fitnessFactor++;
                    }else if(phenoArray[j] == '1') fitnessFactor++;
                }population.get(i).setFitness((double) fitnessFactor/ (double) phenoArray.length);
            }
        }
    }