public double Evaluate(IChromosome chromosome) { ExpressionChromosome ch = chromosome as ExpressionChromosome; if (ch == null) { throw new ArgumentException("Chromosome type is not ExpressionChromosome"); } double fitness = 0; foreach (InputFunction func in data) { double result = ch.Evaluate(func.Parameters); fitness += Math.Abs(result - func.Result); } if (double.IsNaN(fitness)) { return(-1000); } return(fitness * -1); }