| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- 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<ISolution> 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();
- }
- }
|