protected MoChromosome GeneticOPDE(int pos, int i) {//Differential Evolution int k, l; MoChromosome chromosome1; MoChromosome chromosome2; if (Pop[pos].Count < 4) { do { k = random.Next(0, popsize - 1); }while (k == i); do { l = random.Next(0, popsize - 1); }while (l == k || l == i); chromosome1 = mainpop[k]; chromosome2 = mainpop[l]; } else { do { k = random.Next(0, Pop[pos].Count); }while (k == i); do { l = random.Next(0, Pop[pos].Count); }while (l == k || l == i); chromosome1 = Pop[pos][k]; chromosome2 = Pop[pos][l]; } // generic operation crossover and mutation. MoChromosome offSpring = this.createChromosome(); MoChromosome current = Pop[pos][i]; offSpring.DE(current, chromosome1, chromosome2, random); offSpring.mutate(1d / offSpring.parDimension, random); return(offSpring); }
protected MoChromosome DECrossover(int i, Boolean flag = false) {//Differential Evolution int k, l; if (flag == true && random.NextDouble() < 0.5) { do { k = neighbourTable[i][random.Next(this.neighbourSize)]; }while (k == i); do { l = neighbourTable[i][random.Next(this.neighbourSize)]; }while (l == k || l == i); } else { do { k = random.Next(0, popsize - 1); }while (k == i); do { l = random.Next(0, popsize - 1); }while (l == k || l == i); } MoChromosome chromosome1 = mainpop[k]; MoChromosome chromosome2 = mainpop[l]; // generic operation crossover and mutation. MoChromosome offSpring = this.createChromosome(); MoChromosome current = mainpop[i]; offSpring.DE(current, chromosome1, chromosome2, random); offSpring.mutate(1d / offSpring.parDimension, random); return(offSpring); }