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