public void CalculateFitness() { double n = Gen1.Count; double average = 0; foreach (Agent agent in Gen1.AsEnumerable()) { average += agent.EarnedCommission; } average /= n; // promedio double variance = 0; foreach (Agent agent in Gen1.AsEnumerable()) { double tmp = agent.EarnedCommission - average; variance += Math.Pow(tmp, 2); // (value, power) } variance /= n; double standardDeviation = Math.Sqrt(variance); // si la desviacion estandar es cercana a cero los pagos son casi homogeneos. this.Fitness = standardDeviation + PenaltyFitness(); //Para poder saber si esta bien. // tener en cuenta el work time de cada agente. }
public override string ToString() { string toString = "\n\nFitness: " + Fitness + "\n"; foreach (Agent agent in Gen1.AsEnumerable()) { toString += agent; } return(toString); }