Ejemplo n.º 1
0
        /// <summary>
        /// Gets the full search results of the planning search.
        /// </summary>
        /// <param name="includingSolutionPlan">Include the solution plan?</param>
        /// <returns>Search results.</returns>
        public SearchResults GetSearchResults(bool includingSolutionPlan = true)
        {
            IProblem   problem   = Problem as IProblem;
            IHeuristic heuristic = Heuristic as IHeuristic;

            SearchResults results = new SearchResults
            {
                ResultStatus          = ResultStatus,
                DomainName            = (problem != null) ? problem.GetDomainName() : "",
                ProblemName           = Problem.GetProblemName(),
                Algorithm             = GetName(),
                Heuristic             = Heuristic.GetName(),
                SearchTime            = GetSearchTime(),
                ClosedNodes           = GetClosedNodesCount(),
                OpenNodes             = GetOpenNodesCount(),
                MaxGValue             = MaxGValue,
                BestHeuristicValue    = heuristic?.GetStatistics().BestHeuristicValue ?? double.MaxValue,
                AverageHeuristicValue = heuristic?.GetStatistics().AverageHeuristicValue ?? double.MaxValue,
                SolutionPlan          = null,
                SolutionCost          = GetSolutionCost()
            };

            if (includingSolutionPlan)
            {
                results.SolutionPlan = GetSolutionPlan();
            }

            return(results);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Logs the search statistics.
        /// </summary>
        protected override void LogSearchStatistics()
        {
            if (LoggingEnabled)
            {
                string message = $"Closed nodes: {GetClosedNodesCount()}" +
                                 $"\tOpen nodes: {GetOpenNodesCount()}" +
                                 $"\tMax g-Value: {MaxGValue}";

                IHeuristic heuristic = Heuristic as IHeuristic;
                if (heuristic != null)
                {
                    message += $"\tHeuristic calls: {heuristic.GetCallsCount()}" +
                               $"\tMin heuristic: {heuristic.GetStatistics().BestHeuristicValue}" +
                               $"\tAvg heuristic: {heuristic.GetStatistics().AverageHeuristicValue:0.###}";
                }

                message += $"\tCurrent time: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}";

                LogMessage(message);
            }
        }