using System.Collections.Generic; namespace MetaheuristicsPCL { public abstract class TabuSearchAlgorithm : Algorithm { protected ISolution currentSolution; protected ISolution bestSoFarSolution; public override sealed void Solve(IProblem _pb, IHM _ihm) { base.Solve(_pb, _ihm); currentSolution = pb.RandomSolution(); bestSoFarSolution = currentSolution; AddToTabuList(currentSolution); while (!Done()) { List Neighbours = pb.Neighbourhood(currentSolution); if (Neighbours != null) { Neighbours = RemoveSolutionsInTabuList(Neighbours); ISolution bestSolution = pb.BestSolution(Neighbours); if (bestSolution != null) { UpdateSolution(bestSolution); } } Increment(); } SendResult(); } protected abstract void AddToTabuList(ISolution currentSolution); protected abstract List RemoveSolutionsInTabuList(List Neighbours); protected abstract bool Done(); protected abstract void UpdateSolution(ISolution _bestSolution); protected abstract void Increment(); } }