public override Chromosome RandomNeighbourSolution(Chromosome chromosome, MutationOperator neighbourhood) { int size = chromosome.Size(); IGene[] newGenes = new IGene[size]; Array.Copy(chromosome.Genes, newGenes, size); neighbourhood.Run(newGenes); Chromosome result = new Solution(chromosome.Problem as VrptwProblem, newGenes); return(result); }
/// <summary> /// Runs a random walk of n steps along a landscape defined by a mutation operator and returns its results. /// </summary> /// <param name="steps">Number of steps.</param> /// <param name="searchOperator">Operator defining a neighbourhood.</param> /// <returns></returns> public RandomWalk RandomWalk(int steps, MutationOperator searchOperator) { RandomWalk statistics = new RandomWalk(steps); Chromosome currentSolution = ChromosomeFactory.RandomSolution(Problem.GeneCount(), Problem); GatherData(currentSolution, 0, statistics); for (int i = 1; i < steps; ++i) { searchOperator.Run(ref currentSolution); GatherData(currentSolution, i, statistics); } return(statistics); }