Пример #1
0
 public AnytimeDStar(Heuristic <SS, DS> H, Transformer <SS, DS> Transformer,
                     StateVisualizer <SS, DS> sv)
 {
     this.Transformer = Transformer;
     this.H           = H;
     this.sv          = sv;
 }
Пример #2
0
 public RasterPointList(int capacity, Axis axis, StateVisualizer visualizer)
 {
     cap   = capacity;
     scale = axis.Scale;
     list  = new RollingPointPairList(500);
     owner = visualizer;
 }
Пример #3
0
 public LSSLRTAStar(Heuristic <SS, DS> Heuristic,
                    StateVisualizer <SS, DS> sv, Transformer <SS, DS> Transformer)
 {
     this.Heuristic   = Heuristic;
     this.Transformer = Transformer;
     this.sv          = sv;
 }
Пример #4
0
 public TBAStar2(Heuristic <SS, DS> H, Transformer <SS, DS> Transformer,
                 float r, int c, StateVisualizer <SS, DS> sv)
 {
     this.r = r;
     this.c = c;
     Alg    = new LPAStar <SS, DS>(H, Transformer, sv, ReconstructPathStartingPoint.UTop);
 }
Пример #5
0
 public LPAStar(Heuristic <SS, DS> H, Transformer <SS, DS> Transformer,
                StateVisualizer <SS, DS> sv, ReconstructPathStartingPoint rpsp)
 {
     this.Transformer = Transformer;
     this.H           = H;
     this.sv          = sv;
     this.rpsp        = rpsp;
 }
Пример #6
0
 /// <summary>
 /// Finishes the required parsing
 /// </summary>
 public override void FinishParse( )
 {
     // This must be done here otherwise opengl double start error...
       if ( vis == null ) {
     vis = new OpenGLStateVisualizer( );
       }
       if ( !Directory.Exists( this.file ) ) {
     SetFilename( this.file );
       }
 }
Пример #7
0
 public LRTAStar(Heuristic <SS, DS> Heuristic,
                 bool Static, StateVisualizer <SS, DS> sv,
                 Metric Weight, bool RTAStar)
 {
     this.Heuristic = Heuristic;
     this.Static    = Static;
     this.sv        = sv;
     this.Weight    = Weight;
     this.RTAStar   = RTAStar;
 }
        protected virtual void OnEnable()
        {
            instance           = (StateVisualizer)target;
            interactiveElement = serializedObject.FindProperty("interactiveElement");
            animator           = serializedObject.FindProperty("animator");

            stateContainers = serializedObject.FindProperty("stateContainers");

            RemoveButtonLabel = new GUIContent(InspectorUIUtility.Minus, "Remove");
            AddButtonLabel    = new GUIContent(InspectorUIUtility.Plus, "Add");
        }
Пример #9
0
        public RealTimeAnytimeDStar(Heuristic <SS, DS> H, Transformer <SS, DS> Transformer,
                                    StateVisualizer <SS, DS> sv, ChooseMethodStep sm, double Ratio)
        {
            this.Transformer = Transformer;
            this.H           = H;
            this.aS          = new RealTimeAnytimeDStar <SS, DS> .AnytimeDStarState( );

            this.aS.sv = sv;
            this.sm    = sm;
            this.Ratio = Ratio;
        }
Пример #10
0
 public RealTimeTBAStar(Heuristic <SS, DS> H, Transformer <SS, DS> Transformer,
                        float r, int c, StateVisualizer <SS, DS> sv,
                        ReconstructPathStartingPoint rpsp, ShortcutDetection sd)
 {
     this.r           = r;
     this.c           = c;
     this.sv          = sv;
     Alg              = new LPAStar <SS, DS>(H, Transformer, sv, rpsp);
     this.H           = H;
     this.Transformer = Transformer;
     this.sd          = sd;
 }
Пример #11
0
            public StateTransitionArrows(StateVisualizer owner)
            {
                Guard.NotNull(owner, nameof(owner));
                this.owner = owner;

                TransitionTable = CreateTransitionArrowTable();

                foreach (ArrowShape shape in TransitionTable.Values)
                {
                    owner.shapes.Add(shape);
                }
            }
Пример #12
0
 /// <summary>
 /// Finishes the required parsing
 /// </summary>
 public override void FinishParse( )
 {
     // This must be done here otherwise opengl double start error...
     if (vis == null)
     {
         vis = new OpenGLStateVisualizer( );
     }
     if (!Directory.Exists(this.file))
     {
         SetFilename(this.file);
     }
 }
Пример #13
0
 public GenericAlgorithmFactory <SS, DS> SetRealTimeData(Heuristic <SS, DS> h,
                                                         StateVisualizer <SS, DS> vis, Transformer <SS, DS> sut, Metric Weight,
                                                         double Ratio)
 {
     this.h               = h;
     this.vis             = vis;
     this.sut             = sut;
     this.Weight          = Weight;
     this.RealTimeDataSet = true;
     this.Ratio           = Ratio;
     return(this);
 }
Пример #14
0
 public RealTimeDStarLite(Heuristic <SS, DS> H,
                          Transformer <SS, DS> Transformer,
                          StateVisualizer <SS, DS> sv, ChooseMethodLandMarkGoal lgm,
                          ChooseMethodFilterSucc fsm, ChooseMethodStep sm, Metric Weight, double Ratio)
 {
     this.Transformer = Transformer;
     this.H           = H;
     this.sv          = sv;
     this.lgm         = lgm;
     this.fsm         = fsm;
     this.sm          = sm;
     this.Weight      = Weight;
     this.Ratio       = Ratio;
 }
Пример #15
0
        private static void AStar(ref ExtendedDictionary <DS, Metric> G,
                                  ExtendedDictionary <DS, Metric> H, DS Sstart, DS Sgoal,
                                  ExtendedDictionary <DS, DS> tree, ref PriorityQueue <Metric, DS> OPEN,
                                  ref HashSet <DS> CLOSED, int lookahead, Operator <SS, DS>[] Ops, SS ss,
                                  Func <DS, DS, Metric> h0, ref uint Expansions, StateVisualizer <SS, DS> sv)
        {
            G = new ExtendedDictionary <DS, Metric>(k => Metric.Infinity);
            G.Set(Sstart, Metric.Zero);
            OPEN   = new PriorityQueue <Metric, DS>( );
            CLOSED = new HashSet <DS>( );
            OPEN.Enqueue(H.Lookup(Sstart), Sstart);

            int expansions = 0;

            while (!OPEN.IsEmpty( ) && G.Lookup(Sgoal) > OPEN.TopKey( ) &&
                   expansions < lookahead)
            {
#if OpenGl
                if (sv != null)
                {
                    HashSet <DS> hs = new HashSet <DS>( );
                    OPEN.AddToHashSet(hs);
                    sv.VisualizeAlg(ss, ss.InitialDynamicState, new OpenGLStateVisualizer.OpenGlVisulizationData( )
                    {
                        List      = hs as HashSet <GenericGridWorldDynamicState>,
                        HAdjusted = H,
                    });
                }
#endif
                expansions++;
                DS s = OPEN.Dequeue( );
                CLOSED.Add(s);
                Expansions++;
                foreach (DS sp in s.Expand(Ops, ss, false))
                {
                    Metric cost = G.Lookup(s) + c(s, sp, h0);
                    if (G.Lookup(sp) > cost)
                    {
                        G.Set(sp, cost);
                        tree.Set(sp, s);
                        if (OPEN.Contains(sp))
                        {
                            OPEN.Remove(sp);
                        }
                        OPEN.Enqueue(G.Lookup(sp) + H.Lookup(sp), sp);
                    }
                }
            }
        }
Пример #16
0
        /// <summary>
        /// A constructor to setup all the applicable fields.
        /// </summary>
        /// <param name="IO"></param>
        /// <param name="WorldLoader"></param>
        /// <param name="Algorithm"></param>
        /// <param name="Weight"></param>
        public AlgorithmRunner( System.IO.TextReader IO,
            GridWorldLoader<GenericGridWorldStaticState,
            GenericGridWorldDynamicState> WorldLoader, String Algorithm,
            Metric Weight, bool Batch, StateVisualizer<GenericGridWorldStaticState,
            GenericGridWorldDynamicState> vis, int Seed)
        {
            gen = new Random( Seed );
              this.vis = vis;
              this.Goal = new DestinationsReachedGoal( );
              this.Algorithm = new GenericAlgorithmFactory<GenericGridWorldStaticState,
            GenericGridWorldDynamicState>( ).SetRealTimeData(
            new SingleUnitOctileDistanceHeuristic( ), vis,
            new SingleUnitTransformer( ), Weight, 0.1 ).GetAlgorithm(
            Algorithm, null, 0 );

              GenericGridWorldDynamicState InitialDynamicState;
              WorldLoader.Load( IO, out StaticState, out InitialDynamicState );
              IO.Close( );
              this.Actions = GridWorldOperator.Ops;
        }
Пример #17
0
        /// <summary>
        /// A constructor to setup all the applicable fields.
        /// </summary>
        /// <param name="IO"></param>
        /// <param name="WorldLoader"></param>
        /// <param name="Algorithm"></param>
        /// <param name="Weight"></param>
        public AlgorithmRunner(System.IO.TextReader IO,
                               GridWorldLoader <GenericGridWorldStaticState,
                                                GenericGridWorldDynamicState> WorldLoader, String Algorithm,
                               Metric Weight, bool Batch, StateVisualizer <GenericGridWorldStaticState,
                                                                           GenericGridWorldDynamicState> vis, int Seed)
        {
            gen            = new Random(Seed);
            this.vis       = vis;
            this.Goal      = new DestinationsReachedGoal( );
            this.Algorithm = new GenericAlgorithmFactory <GenericGridWorldStaticState,
                                                          GenericGridWorldDynamicState>( ).SetRealTimeData(
                new SingleUnitOctileDistanceHeuristic( ), vis,
                new SingleUnitTransformer( ), Weight, 0.1).GetAlgorithm(
                Algorithm, null, 0);

            GenericGridWorldDynamicState InitialDynamicState;

            WorldLoader.Load(IO, out StaticState, out InitialDynamicState);
            IO.Close( );
            this.Actions = GridWorldOperator.Ops;
        }
Пример #18
0
        public static Path <SS, DS> AStarLookAheadNotSliced(DS Start, SS ss,
                                                            int ComputationLimit, StateVisualizer <SS, DS> sv,
                                                            ref uint Expansions, ref uint Generations, bool Static,
                                                            Operator <SS, DS>[] Actions, Dictionary <string, Metric> HAdjusted,
                                                            Heuristic <SS, DS> Heuristic, Goal <SS, DS> Goal, Metric Weight, bool RTAStar)
        {
            if (ComputationLimit <= 0)
            {
                throw new ArgumentException("Computation Limit Invalid");
            }

            DS Cur = null;

            Start.ResetPath( );
            int IterationExpansions             = 0;
            PriorityQueue <Metric, DS> OpenList = new PriorityQueue <Metric, DS>( );
            HashSet <DS> ClosedList             = new HashSet <DS>( );

            OpenList.Enqueue(h(Start, HAdjusted, Heuristic, Goal, Actions, ss), Start);
            while (true)
            {
                if (OpenList.IsEmpty( ))
                {
                    Cur = null;
                    break;
                }
#if OpenGl
                if (sv != null)
                {
                    sv.VisualizeAlg(ss, ss.InitialDynamicState, new OpenGLStateVisualizer.OpenGlVisulizationData( )
                    {
                        OL        = OpenList as PriorityQueue <Metric, GenericGridWorldDynamicState>,
                        HAdjusted = HAdjusted,
                    });
                }
#endif
                Cur = OpenList.Dequeue( );
                ClosedList.Add(Cur);
                if (Goal.IsSatisfiedBy(ss, Cur))
                {
                    break;
                }
                else
                {
                    if (++IterationExpansions > ComputationLimit)
                    {
                        break;
                    }
                    Expansions++;
                    foreach (DS e in Cur.Expand(Actions, ss, Static))
                    {
                        if (!ClosedList.Contains(e) && !OpenList.Contains(e))
                        {
                            OpenList.Enqueue(Weight * h(e, HAdjusted, Heuristic, Goal, Actions, ss)
                                             + gComputer.G(ss, e, Goal), e);
                        }
                        Generations++;
                    }
                }
            }
            Metric            Best       = null;
            Operator <SS, DS> BestOp     = null;
            Metric            SecondBest = null;
            if (Cur != null)
            {
                Best = Weight * h(Cur, HAdjusted, Heuristic, Goal, Actions, ss)
                       + gComputer.G(ss, Cur, Goal);
                BestOp = Cur.Path( ).Actions.First.Value;

                if (!OpenList.IsEmpty( ))
                {
                    Cur        = OpenList.Dequeue( );
                    SecondBest = Weight * h(Cur, HAdjusted, Heuristic, Goal, Actions, ss)
                                 + gComputer.G(ss, Cur, Goal);
                }
            }

            if (RTAStar && SecondBest != null)
            {
                if (h(Start, HAdjusted, Heuristic, Goal, Actions, ss) < SecondBest)
                {
                    h(Start, SecondBest, HAdjusted);
                }
            }
            else if ((RTAStar && SecondBest == null) || Best == null)
            {
                h(Start, new Metric(double.PositiveInfinity), HAdjusted);
            }
            else if (Best != null)
            {
                if (h(Start, HAdjusted, Heuristic, Goal, Actions, ss) < Best)
                {
                    h(Start, Best, HAdjusted);
                }
            }
            if (BestOp == null)
            {
                return(null);
            }
            else
            {
                return(Operator <SS, DS> .MakePath(BestOp));
            }
        }
Пример #19
0
        public static Path <SS, DS> BreadthFirstLookAhead(DS Start, SS ss,
                                                          int ComputationLimit, StateVisualizer <SS, DS> sv,
                                                          ref uint Expansions, ref uint Generations, bool Static,
                                                          Operator <SS, DS>[] Actions, Dictionary <string, Metric> HAdjusted,
                                                          Heuristic <SS, DS> Heuristic, Goal <SS, DS> Goal, Metric Weight, bool RTAStar, Random Gen)
        {
            Start.ResetPath( );

            if (ComputationLimit <= 0)
            {
                throw new ArgumentException("Computation Limit Invalid");
            }
            DS[] Neighbors = Start.Expand(Actions, ss, Static).ToArray( );
            Expansions++;
            Metric            Best       = null;
            Operator <SS, DS> BestOp     = null;
            Metric            SecondBest = null;

            foreach (DS Neighbor in Neighbors)
            {
                Metric            GNeigh  = Neighbor.Path( ).Cost;
                Operator <SS, DS> OpNeigh = Neighbor.Path( ).Actions.First.Value;
                Metric            HNeigh  = null;
                if (HAdjusted == null || !HAdjusted.TryGetValue(Neighbor.ToString( ), out HNeigh))
                {
                    Neighbor.ResetPath( );
                    Metric       Alpha      = new Metric(double.PositiveInfinity);
                    Stack <DS>   ToVisit    = new Stack <DS>( );
                    Stack <int>  Depths     = new Stack <int>( );
                    HashSet <DS> ClosedList = new HashSet <DS>( );
                    ToVisit.Push(Neighbor);
                    Depths.Push(0);
                    ClosedList.Add(Start);
                    while (ToVisit.Count > 0)
                    {
#if OpenGl
                        if (sv != null)
                        {
                            sv.VisualizeAlg(ss, ss.InitialDynamicState, new OpenGLStateVisualizer.OpenGlVisulizationData( )
                            {
                                List      = new HashSet <DS>(ToVisit) as HashSet <GenericGridWorldDynamicState>,
                                HAdjusted = HAdjusted,
                            });
                        }
#endif
                        DS  Top   = ToVisit.Pop( );
                        int Depth = Depths.Pop( );
                        ClosedList.Add(Top);
                        Metric TVal = gComputer.G(ss, Top, Goal) + Weight *
                                      h(Top, HAdjusted, Heuristic, Goal, Actions, ss);
                        if (TVal >= Alpha)
                        {
                            continue;
                        }
                        if (HNeigh == null || HNeigh > TVal)
                        {
                            HNeigh = TVal;
                        }
                        if (ComputationLimit == Depth)
                        {
                            Alpha = Metric.Min(Alpha, TVal);
                        }
                        else
                        {
                            Expansions++;
                            foreach (DS n in Top.Expand(Actions, ss, Static))
                            {
                                Generations++;
                                if (!ClosedList.Contains(n) && !ToVisit.Contains(n))
                                {
                                    ToVisit.Push(n);
                                    Depths.Push(Depth + 1);
                                }
                            }
                        }
                    }
                }
                if (HNeigh != null)
                {
                    Metric FNeigh = GNeigh + HNeigh;
                    if (Best == null || Best > FNeigh)
                    {
                        BestOp = OpNeigh;
                        Best   = FNeigh;
                    }
                    else if (SecondBest == null || SecondBest > FNeigh)
                    {
                        SecondBest = FNeigh;
                    }
                }
            }
            if (RTAStar && SecondBest != null)
            {
                if (h(Start, HAdjusted, Heuristic, Goal, Actions, ss) < SecondBest)
                {
                    h(Start, SecondBest, HAdjusted);
                }
            }
            else if ((RTAStar && SecondBest == null) || Best == null)
            {
                h(Start, new Metric(double.PositiveInfinity), HAdjusted);
            }
            else if (Best != null)
            {
                if (h(Start, HAdjusted, Heuristic, Goal, Actions, ss) < Best)
                {
                    h(Start, Best, HAdjusted);
                }
            }
            if (BestOp == null)
            {
                return(null);
            }
            else
            {
                return(Operator <SS, DS> .MakePath(BestOp));
            }
        }
Пример #20
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="GComputer">The G function computer object</param>
 /// <param name="DepthBound">The dpeth</param>
 /// <param name="UseClosedList">Whether a closed list or duplicate
 /// detection should be used for cycle detection.</param>
 public UniformedCostSearch(bool UseClosedList, StateVisualizer <SS, DS> sv)
     : base(null, true, sv)
 {
     throw new System.Exception("Not Implemented UCS");
 }
Пример #21
0
        public static Path <SS, DS> AStarLookAhead(DS Start, SS ss,
                                                   int ComputationLimit, StateVisualizer <SS, DS> sv,
                                                   ref uint Expansions, ref uint Generations, bool Static,
                                                   Operator <SS, DS>[] Actions, Dictionary <string, Metric> HAdjusted,
                                                   Heuristic <SS, DS> Heuristic, Goal <SS, DS> Goal, Metric Weight, bool RTAStar)
        {
            if (ComputationLimit <= 0)
            {
                throw new ArgumentException("Computation Limit Invalid");
            }

            DS[] Neighbors           = Start.Expand(Actions, ss, Static).ToArray( );
            int  IterationExpansions = 1;

            Expansions++;

            Dictionary <DS, Metric>             GNeighs = new Dictionary <DS, Metric>( );
            Dictionary <DS, Metric>             HNeighs = new Dictionary <DS, Metric>( );
            Dictionary <DS, Operator <SS, DS> > OpNeighs
                = new Dictionary <DS, Operator <SS, DS> >( );

            LinkedList <DS> LookAheadNeighbors = new LinkedList <DS>( );

            foreach (DS Neighbor in Neighbors)
            {
                GNeighs.Add(Neighbor, Neighbor.Path( ).Cost);
                OpNeighs.Add(Neighbor, Neighbor.Path( ).Actions.First.Value);
                Neighbor.ResetPath( );
                Metric HNeigh = null;
                if (HAdjusted != null && HAdjusted.TryGetValue(Neighbor.ToString( ), out HNeigh))
                {
                    HNeighs.Add(Neighbor, HNeigh);
                }
                else
                {
                    LookAheadNeighbors.AddFirst(Neighbor);
                }
            }

            Dictionary <DS, PriorityQueue <Metric, DS> > OpenLists =
                new Dictionary <DS, PriorityQueue <Metric, DS> >( );

#if OpenGl
            HashSet <DS> OpenStates = new HashSet <DS>( );
#endif
            HashSet <DS> ClosedList = new HashSet <DS>( );
            ClosedList.Add(Start);
            foreach (DS Neighbor in LookAheadNeighbors)
            {
                var ol = new PriorityQueue <Metric, DS>( );
                ol.Enqueue(h(Neighbor, HAdjusted, Heuristic, Goal, Actions, ss), Neighbor);
                OpenLists.Add(Neighbor, ol);
#if OpenGl
                OpenStates.Add(Neighbor);
#endif
            }

            while (true)
            {
                LinkedList <DS> OpenNeighbors = new LinkedList <DS>(LookAheadNeighbors);
                foreach (DS Neighbor in LookAheadNeighbors)
                {
                    PriorityQueue <Metric, DS> OpenList;
                    OpenLists.TryGetValue(Neighbor, out OpenList);
#if OpenGl
                    if (sv != null)
                    {
                        sv.VisualizeAlg(ss, ss.InitialDynamicState, new OpenGLStateVisualizer.OpenGlVisulizationData( )
                        {
                            List      = OpenStates as HashSet <GenericGridWorldDynamicState>,
                            HAdjusted = HAdjusted,
                        });
                    }
#endif
                    if (OpenList.IsEmpty( ))
                    {
                        HNeighs.Add(Neighbor, new Metric(double.PositiveInfinity));
                        OpenNeighbors.Remove(Neighbor);
                        continue;
                    }
                    DS Cur = OpenList.Dequeue( );
#if OpenGl
                    OpenStates.Remove(Cur);
#endif

                    ClosedList.Add(Cur);
                    if (Goal.IsSatisfiedBy(ss, Cur))
                    {
                        HNeighs.Add(Neighbor, Cur.Path( ).Cost);
                        OpenNeighbors.Remove(Neighbor);
                        continue;
                    }
                    else
                    {
                        if (++IterationExpansions > ComputationLimit)
                        {
                            HNeighs.Add(Neighbor, Cur.Path( ).Cost
                                        + Weight * h(Cur, HAdjusted, Heuristic, Goal, Actions, ss));
                            OpenNeighbors.Remove(Neighbor);
                            break;
                        }
                        Expansions++;
                        foreach (DS e in Cur.Expand(Actions, ss, Static))
                        {
                            if (!ClosedList.Contains(e) && !OpenList.Contains(e))
                            {
                                OpenList.Enqueue(Weight * h(e, HAdjusted, Heuristic, Goal, Actions, ss)
                                                 + gComputer.G(ss, e, Goal), e);
#if OpenGl
                                OpenStates.Add(e);
#endif
                            }
                            Generations++;
                        }
                    }
                }
                LookAheadNeighbors = OpenNeighbors;
                if (IterationExpansions > ComputationLimit || LookAheadNeighbors.Count == 0)
                {
                    break;
                }
            }
            foreach (DS Neighbor in LookAheadNeighbors)
            {
                PriorityQueue <Metric, DS> OpenList;
                OpenLists.TryGetValue(Neighbor, out OpenList);
                if (OpenList.IsEmpty( ))
                {
                    HNeighs.Add(Neighbor, new Metric(double.PositiveInfinity));
                }
                else
                {
                    DS Cur = OpenList.Dequeue( );
                    HNeighs.Add(Neighbor, Cur.Path( ).Cost
                                + Weight * h(Cur, HAdjusted, Heuristic, Goal, Actions, ss));
                }
            }

            Metric            Best       = null;
            Operator <SS, DS> BestOp     = null;
            Metric            SecondBest = null;

            foreach (DS Neighbor in Neighbors)
            {
                Metric            HNeigh  = null;
                Metric            GNeigh  = null;
                Operator <SS, DS> OpNeigh = null;
                HNeighs.TryGetValue(Neighbor, out HNeigh);
                GNeighs.TryGetValue(Neighbor, out GNeigh);
                OpNeighs.TryGetValue(Neighbor, out OpNeigh);
                if (HNeigh != null)
                {
                    Metric FNeigh = GNeigh + HNeigh;
                    if (Best == null || Best > FNeigh)
                    {
                        BestOp = OpNeigh;
                        Best   = FNeigh;
                    }
                    else if (SecondBest == null || SecondBest > FNeigh)
                    {
                        SecondBest = FNeigh;
                    }
                }
            }
            if (RTAStar && SecondBest != null)
            {
                if (h(Start, HAdjusted, Heuristic, Goal, Actions, ss) < SecondBest)
                {
                    h(Start, SecondBest, HAdjusted);
                }
            }
            else if ((RTAStar && SecondBest == null) || Best == null)
            {
                h(Start, new Metric(double.PositiveInfinity), HAdjusted);
            }
            else if (Best != null)
            {
                if (h(Start, HAdjusted, Heuristic, Goal, Actions, ss) < Best)
                {
                    h(Start, Best, HAdjusted);
                }
            }
            if (BestOp == null)
            {
                return(null);
            }
            else
            {
                return(Operator <SS, DS> .MakePath(BestOp));
            }
        }
Пример #22
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="GComputer">The G function computer object</param>
 /// <param name="Heuristic">The Heuristic function object</param>
 /// <param name="DepthBound">The dpeth</param>
 /// <param name="UseClosedList">Whether a closed list or duplicate
 /// detection should be used for cycle detection.</param>
 public WeightedAStar(Heuristic <SS, DS> Heuristic,
                      bool UseClosedList, Metric Weight, StateVisualizer <SS, DS> sv)
     : base(Heuristic, UseClosedList, sv)
 {
     throw new System.Exception("Not Implemented Weight");
 }
Пример #23
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="BestExpresion">The best expression for sorting elements
 /// in the open list.</param>
 /// <param name="Limit">The limit bound. Default to 0 if no bound
 /// wanted.</param>
 /// <param name="UseClosedList">Whether or not a closed list vs upward
 /// travesal loop detection will be used to detect cycles.</param>
 public BestFirstSearch(Heuristic <SS, DS> Heuristic, bool UseClosedList, StateVisualizer <SS, DS> sv)
 {
     this.UseClosedList = UseClosedList;
     this.sv            = sv;
     this.Heuristic     = Heuristic;
 }
Пример #24
0
        public static Path <SS, DS> LSSLRTAStarLookahead(int ComputationLimit, SS ss,
                                                         DS Sstart, DS Sgoal, Operator <SS, DS>[] Ops, Func <DS, DS, Metric> h0,
                                                         ref Path <SS, DS> Incumbant, ref uint Expansions, StateVisualizer <SS, DS> sv,
                                                         ExtendedDictionary <DS, DS> tree, ExtendedDictionary <DS, Metric> H)
        {
            if (!PathGood(Incumbant, ss))
            {
                ExtendedDictionary <DS, Metric> G    = null;
                PriorityQueue <Metric, DS>      OPEN = null;
                HashSet <DS> CLOSED = null;
                AStar(ref G, H, Sstart, Sgoal, tree, ref OPEN, ref CLOSED, ComputationLimit, Ops, ss, h0, ref Expansions, sv);
                if (OPEN.IsEmpty( ))
                {
                    return(null);
                }
                DS SPgoal = OPEN.Top( );
                Dijkstra(ref G, H, Sstart, Sgoal, ref tree, ref OPEN, ref CLOSED, Ops, ss, h0);

                Incumbant = ExtractPath(Sstart, SPgoal, tree, Ops, ss);
            }
            if (Incumbant == null || Incumbant.ActionCount == 0)
            {
                return(null);
            }
            else
            {
                var IHead = Incumbant.PopHead( );
                if (IHead.Actions.First.Value.IsValidOn(ss.InitialDynamicState, ss, false))
                {
                    return(IHead);
                }
                else
                {
                    Incumbant = null;
                    return(null);
                }
            }
        }
Пример #25
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="GComputer">The G function computer object</param>
 /// <param name="Heuristic">The Heuristic function object</param>
 /// <param name="DepthBound">The dpeth</param>
 /// <param name="UseClosedList">Whether a closed list or duplicate
 /// detection should be used for cycle detection.</param>
 public AStar(Heuristic <SS, DS> Heuristic,
              bool UseClosedList, StateVisualizer <SS, DS> sv)
     : base(Heuristic, UseClosedList, sv)
 {
 }
Пример #26
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="DepthBound">The dpeth</param>
 /// <param name="UseClosedList">Whether a closed list or duplicate
 /// detection should be used for cycle detection.</param>
 public DepthFirstSearch(Metric DepthBound, bool UseClosedList, StateVisualizer <SS, DS> sv)
     : base(null, UseClosedList, sv)
 {
     throw new System.Exception("Not Implemented DFS");
 }