public void Reset(PathFinderDescription description) { Description = description; // null 염색체 시작점 int chromosomeNullStartIndex = 0; if (chromosomes == null) { // 염색체 군 새로 할당 chromosomes = new Chromosome[description.PopulationSize]; ResizeDataArrays(); } else if (chromosomes.Length != description.PopulationSize) { // 염색체 군 크기 조정 chromosomeNullStartIndex = chromosomes.Length; var newArray = new Chromosome[description.PopulationSize]; Array.Copy(chromosomes, newArray, description.PopulationSize); chromosomes = newArray; ResizeDataArrays(); } // null 염색체에 새로 할당 for (int i = chromosomeNullStartIndex; i < description.PopulationSize; i++) { chromosomes[i] = new Chromosome(description.ChromosomeSize); } Reset(); void ResizeDataArrays() { // 각 데이터 배열 재할당 oldChromosomes = new Chromosome[description.PopulationSize]; fitnesses = new double[description.PopulationSize]; fitnessCumulatives = new double[description.PopulationSize]; } }
public PathFinderPopulation(PathFinderDescription description) { Reset(description); }