示例#1
0
文件: AlgPF.cs 项目: Lannyland/IPPA
        // Expand neighboring nodes
        protected override List<LHCNode> GetNeighbors(Point parent, Point me)
        {
            List<LHCNode> Neighbors = new List<LHCNode>();

            // We don't want the UAV to hover in PF because it will get stuck there
            // So don't add self if UAV can hover

            // Loop through all four directions (N, E, S, W)
            for (int j = 0; j < 4; j++)
            {
                // Expand child
                Point child = GetDirChild(j, me);

                // Check if it's valid
                if (ValidMove(parent, me, child))
                {
                    LHCNode n = new LHCNode();
                    n.Loc = child;
                    n.p = GetPartialDetection(child);
                    Neighbors.Add(n);
                }
            }
            return Neighbors;
        }
示例#2
0
文件: AlgLHC.cs 项目: Lannyland/IPPA
        // Function to pick which child node to follow.
        protected int PickChildNode(Point me, List<LHCNode> neighbors, int identicalCount, int cur_T)
        {
            int index = 0;
            List<LHCNode> NewList = new List<LHCNode>();

            // Do this for PF but not Conv
            float[] forces = PrepareTieBreaker(me, cur_T);

            // Compute convolution/pf values for these child nodes with identical p values
            for (int i = 0; i < identicalCount; i++)
            {
                LHCNode ln = new LHCNode();
                ln.Loc = neighbors[i].Loc;
                ln.p = TieBreaker(me, ln.Loc, cur_T, forces); ;
                ln.oldindex = neighbors[i].oldindex;
                NewList.Add(ln);
                // Console.Write("(" + ln.Loc.X + "," + ln.Loc.Y + ")conv=" + ln.p + " ");
            }
            // Sort so best convolution/pf value nodes at top
            NewList.Sort();
            NewList.Reverse();

            // Check if more than one neighbor with identical conv/pf value
            // If so, randomly pick one
            int identical = GetTopIdenticalCount(NewList);

            if (identical == 1)
            {
                // Found node with highest conv/pf value
                index = NewList[0].oldindex;
            }
            else
            {
                // Randomly pick a node if have same conv/pf vlaues
                int i = r.Next(0, identical);
                // Console.Write("random i=" + i + " ");
                index = NewList[i].oldindex;
            }

            return index;
        }
示例#3
0
文件: AlgLHC.cs 项目: Lannyland/IPPA
        // Expand neighboring nodes (with end point)
        protected virtual List<LHCNode> GetNeighbors(Point parent, Point me, Point end, int T_Left)
        {
            List<LHCNode> Neighbors = new List<LHCNode>();

            // Add self if UAV can hover
            if (curRequest.VehicleType == UAVType.Copter)
            {
                // Check if it's valid
                if (ValidMove(parent, me, me, end, T_Left))
                {
                    LHCNode n = new LHCNode();
                    n.Loc = me;
                    n.p = GetPartialDetection(me);
                    Neighbors.Add(n);
                }
            }

            // Loop through all four directions (N, E, S, W)
            for (int j = 0; j < 4; j++)
            {
                // Expand child
                Point child = GetDirChild(j, me);

                // Check if it's valid
                if (ValidMove(parent, me, child, end, T_Left))
                {
                    LHCNode n = new LHCNode();
                    n.Loc = child;
                    n.p = GetPartialDetection(child);
                    Neighbors.Add(n);
                }
            }
            return Neighbors;
        }
示例#4
0
文件: AlgTopN.cs 项目: Lannyland/IPPA
        // When remaining time is only one more than the shortest distance of connecting all points
        // Then we need to hover at one of the end points. Add that to the right segment.
        private void HoverAtOneEndPoint(List<List<Point>> MidSegments)
        {
            // Find all ending points
            List<LHCNode> LooseEnds = new List<LHCNode>();
            for (int i = 0; i < MidSegments.Count; i++)
            {
                if (MidSegments[i].Count > 0)
                {
                    Point me = MidSegments[i][MidSegments[i].Count - 1];
                    LHCNode node = new LHCNode();
                    node.Loc = me;
                    node.p = GetPartialDetection(me);
                    LooseEnds.Add(node);
                }
            }

            // Decide which one is the best.
            int indexOfnext = 0;
            Point p = new Point();
            if (LooseEnds.Count > 1)
            {
                FindNodeToGoTo(p, ref LooseEnds, ref indexOfnext);
            }

            // Add node to path and then collect probability (zero it out)
            Point bestPoint = LooseEnds[indexOfnext].Loc;
            for (int i = 0; i < MidSegments.Count; i++)
            {
                if (MidSegments[i].Count > 0)
                {
                    Point me = MidSegments[i][MidSegments[i].Count - 1];
                    if (me.X == bestPoint.X && me.Y == bestPoint.Y)
                    {
                        MidSegments[i].Add(bestPoint);
                        break;
                    }
                }
            }
            mCurDist[bestPoint.Y, bestPoint.X] = VacuumProbability(bestPoint);
        }
示例#5
0
文件: AlgTopN.cs 项目: Lannyland/IPPA
        // Function to pick which child node to follow.
        protected int PickChildNode(Point me, List<LHCNode> neighbors, int identicalCount)
        {
            int index = 0;
            List<LHCNode> NewList = new List<LHCNode>();

            // Compute convolution values for these child nodes with identical p values
            for (int i = 0; i < identicalCount; i++)
            {
                LHCNode ln = new LHCNode();
                ln.Loc = neighbors[i].Loc;
                ln.p = TieBreaker(me, ln.Loc); ;
                ln.oldindex = neighbors[i].oldindex;
                NewList.Add(ln);
            }
            // Sort so best convolution value nodes at top
            NewList.Sort();
            NewList.Reverse();

            // Check if more than one neighbor with identical conv value
            // If so, randomly pick one
            int identical = GetTopIdenticalCount(NewList);

            if (identical == 1)
            {
                // Found node with highest conv value
                index = NewList[0].oldindex;
            }
            else
            {
                // Randomly pick a node if have same conv vlaues
                int i = r.Next(0, identical);
                index = NewList[i].oldindex;
            }

            return index;
        }