Пример #1
0
        /// <summary>
        /// good perforamce
        /// </summary>
        /// <param name="ni"></param>
        /// <param name="packet"></param>
        /// <returns></returns>
        public Sensor Greedy1(Sensor ni, Packet packet)
        {
            List <CoordinationEntry> coordinationEntries = new List <CoordinationEntry>();
            Point endPoint = (packet.Destination != null) ? packet.Destination.CenterLocation : packet.DestinationPoint;

            Sensor sj  = null;
            double sum = 0;

            foreach (Sensor nj in ni.NeighborsTable)
            {
                if (nj.ResidualEnergyPercentage > 0)
                {
                    double Norangle = Operations.AngleDotProdection(ni.CenterLocation, nj.CenterLocation, endPoint);
                    double dj       = Operations.DistanceBetweenTwoPoints(nj.CenterLocation, endPoint);
                    if (Norangle < 0.5)
                    {
                        double aggregatedValue = dj * Norangle;
                        sum += aggregatedValue;
                        coordinationEntries.Add(new CoordinationEntry()
                        {
                            Priority = aggregatedValue, Sensor = nj
                        });                                                                                           // candidaite
                    }
                }
            }
            // coordination"..... here
            sj = counter.CoordinateGetMin(coordinationEntries, packet, sum);
            return(sj);
        }
Пример #2
0
        private Sensor SelectNextHop(Sensor ni, Packet packet)
        {
            Point endPoint = (packet.Destination != null) ? packet.Destination.CenterLocation : packet.DestinationPoint;

            List <CoordinationEntry> coordinationEntries = new List <CoordinationEntry>();
            Sensor sj  = null;
            double sum = 0;

            foreach (Sensor nj in ni.NeighborsTable)
            {
                double dj = Operations.DistanceBetweenTwoPoints(nj.CenterLocation, endPoint);
                double aggregatedValue = dj;
                coordinationEntries.Add(new CoordinationEntry()
                {
                    Priority = aggregatedValue, Sensor = nj
                });                                                                                           // candidaite
                sum += aggregatedValue;
            }
            // coordination"..... here
            sj = counter.CoordinateGetMin(coordinationEntries, packet, sum);

            return(sj);;
        }