Function to compute the fitness of a phenotype.