Ejemplo n.º 1
0
 protected override void InternalSolve()
 {
     ReinitializePrivates();
     InitializeMoveFactories();
     while (!TimeToEnd())
     {
         _bestFactory = null;
         _bestMove    = null;
         foreach (ITransformationFactory factory in MoveFactories)
         {
             if (TimeToEnd())
             {
                 break;
             }
             AssesMovesFromFactory(factory);
         }
         ChooseToPerform();
     }
     if (_previousBest != null && _previousBest.IsBetterThan(Solution))
     {
         Solution = _previousBest;
         _previousBest.RestoreStructures();
         _scoringFunction.AssesSolution(Solution);
     }
     if (DiagnosticMessages)
     {
         Console.WriteLine($"Number of transformations performed {NumberOfMoves}.");
     }
 }
Ejemplo n.º 2
0
 private void ReinitializePrivates()
 {
     _previousBest = null;
     _bestFactory  = null;
     _bestMove     = null;
     _numberOfLoopsWithoutImprovement = 0;
     _timeToStop = false;
 }
Ejemplo n.º 3
0
        private void AssesMovesFromFactory(ITransformationFactory factory)
        {
            var moves = factory.GenerateMoves().ToList();

            foreach (var move in moves)
            {
                if (TimeToEnd())
                {
                    break;
                }
                move.Asses();
                if (FirstIsBetter(move, _bestMove))
                {
                    _bestMove    = move;
                    _bestFactory = factory;
                }
            }
        }
Ejemplo n.º 4
0
 public TextService(ITransformationFactory transformationFactory)
 {
     _transformationFactory = transformationFactory;
 }
Ejemplo n.º 5
0
 public CatsController(ICatService catService, ITransformationFactory transformationFactory)
 {
     CatService            = catService;
     TransformationFactory = transformationFactory;
 }
 public TransformationFactoryWrapper(ITransformationFactory factory)
 {
     _factory = factory;
 }
Ejemplo n.º 7
0
 public TransformationProvider(
     ITransformationFactory factory)
 {
     _factory = factory;
 }