Esempio n. 1
0
        public override Node <S, A> FindNode(ISearchProblem <S, A> problem, InOutCollection <Node <S, A> > frontier)
        {
            _bytes = GC.GetTotalMemory(true);

            var startTime = Stopwatch.StartNew();

            startTime.Start();

            Frontier = frontier;

            var root = NodeFactory.CreateNode <S, A>(problem.InitState);

            AddToFrontier(root);

            long maxMemory = _bytes;

            while (!IsFrontierEmpty())
            {
                maxMemory = Math.Max(maxMemory, GC.GetTotalMemory(false));

                _count++;
                var node = RemoveFromFrontier();

                if (problem.GoalTest(node.State))
                {
                    startTime.Stop();
                    _times  = startTime.Elapsed;
                    _bytes -= maxMemory;
                    return(node);
                }

                foreach (var successor in NodeFactory.GetSuccessors(node, problem))
                {
                    AddToFrontier(successor);
                }
            }

            _bytes -= maxMemory;
            startTime.Stop();
            _times = startTime.Elapsed;

            return(null);
        }
Esempio n. 2
0
 public override Node <S, A> FindNode(ISearchProblem <S, A> problem, InOutCollection <Node <S, A> > frontier)
 {
     _explored.Clear();
     return(base.FindNode(problem, frontier));
 }
Esempio n. 3
0
 public abstract Node <S, A> FindNode(ISearchProblem <S, A> problem, InOutCollection <Node <S, A> > frontier);
Esempio n. 4
0
 protected QueueBasedSearchBase(SearchBase <S, A> impl, InOutCollection <Node <S, A> > list)
 {
     _frontier = list;
     _impl     = impl;
 }