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