Example #1
0
        internal override void OnTerminating()
        {
            base.OnTerminating();
            Solver.BestSolution = CurrentBestSolution;

            Console.ForegroundColor = ConsoleColor.Yellow;
            SendMessage(MessageCode.LocalSearchImprovementsPerformed, ImprovementsCount);
            SendMessage(MessageCode.LocalSearchStop,
                        CurrentBestSolution.Id, CurrentBestSolution.Cost);
            Console.ForegroundColor = ConsoleColor.Gray;
            SendMessage(ToSolution.SolutionCollectionToString(_solutionsHistory));
        }
Example #2
0
        internal override void OnTerminating()
        {
            base.OnTerminating();
            var validSolutions = SolutionsHistory.Where(solution => solution.IsValid);

            if (validSolutions.Any())
            {
                Solver.BestSolution = validSolutions.MaxBy(solution => solution.Cost);
                SendMessage(ToSolution.SolutionCollectionToString(SolutionsHistory));
                return;
            }

            Solver.BestSolution     = SolutionsHistory.MaxBy(solution => solution.Cost);
            Console.ForegroundColor = ConsoleColor.Green;
            SendMessage(MessageCode.GreedyNotFoundValidSolutions, Type);
            Console.ForegroundColor = ConsoleColor.Gray;
        }