Beispiel #1
0
        public override void RankUpdatingHandler(RankUpdatingMessageReader request)
        {
            //Console.WriteLine("In rank updating handler");

            request.recipients.ForEach((cellId) =>
            {
                using (var cell = Global.LocalStorage.UseSSSPCell(cellId))
                {
                    //Console.WriteLine("Use cell: " + cellId);

                    cell.storedRankValue += request.rankValueP;
                    //Console.WriteLine("Stored: " + cell.storedRankValue);

                    if ((cell.storedRankValue > cell.rankValue * (1 + thresholdFactor)) && (cell.status))
                    {
                        //Console.WriteLine("Stored: " + cell.storedRankValue + " Rank: " + cell.rankValue);
                        //cell.rankValue = cell.storedRankValue;
                        newNodeSet.Add(cellId);
                    }
                    //Console.WriteLine(cell.CellID.Value + ": " + cell.newRankValue);

                    /*
                     * MessageSorter sorter = new MessageSorter(cell.neighbors);
                     * for (int i = 0; i < Global.SlaveCount; i++)
                     * {
                     *      DistanceUpdatingMessageWriter msg = new DistanceUpdatingMessageWriter(cell.CellID.Value,
                     *          cell.distance, sorter.GetCellRecipientList(i));
                     *      Global.CloudStorage.DistanceUpdatingToSlave(i, msg);
                     * }
                     */
                }
            });
        }
Beispiel #2
0
        public override void RankUpdatingHandler(RankUpdatingMessageReader request)
        {
            request.recipients.ForEach((recipient) =>
            {
                using (var cell = Global.LocalStorage.UseSSSPCell(recipient))
                {
                    int index = binarySearch(cell.inNeighbors, request.senderId);

                    if (cell.ranks[index] < request.value)
                    {
                        cell.sum         += request.value - cell.ranks[index];
                        cell.ranks[index] = request.value;

                        if (cell.CellID == 3)
                        {
                            Console.WriteLine(cell.sum);
                        }

                        send(cell);
                    }
                }
            });
        }
Beispiel #3
0
        public override void RankUpdatingHandler(RankUpdatingMessageReader request)
        {
            //v++;
            //if (v >= 30000)
            //{
              //  return;
            //}

            //Console.WriteLine("In rank updating handler");

            long senderId = request.senderId;
            double value = request.value;

            request.recipients.ForEach((cellId) =>
            {
                using (var cell = Global.LocalStorage.UseSSSPCell(cellId))
                {
                    bool toPropagate = false;
                    bool isActive = false;
                    bool recompute = false;
                    bool increasement = false;

                    int index = binarySearch(cell.inNeighbors, request.senderId);

                    if (value > cell.inNeighborsValue[index])
                    {
                        cell.inNeighborsValue[index] = value;
                        increasement = true;
                    }

                    /*
                    if (cellId == 2)
                    {
                        v++;
                        if (v % 10000 == 0) Console.WriteLine(cellId + "-Start: Sum " + cell.sum);
                        //" Received Message: (" + request.isActive + "," + request.value + ") " +
                        //" stored_inneighbor_ActiveStatus: " + cell.inNeighborsActiveStatus[index]);
                    }*/

                    if (!request.isActive)
                    {
                        if (cell.inNeighborsActiveStatus[index])
                        {
                            cell.inNeighborsActiveStatus[index] = false;
                            cell.inNeighborsReceivedStatus[index] = false;
                            //clear
                            /*
                            for (int j = 0; j < cell.inNeighborsReceivedStatus.Count; j++)
                            {
                                cell.inNeighborsReceivedStatus[j] = false;
                            }
                            cell.receivedNeighborCount = 0;
                            */
                        }
                        else
                        {
                            //Console.WriteLine("Impossible! " + " receive message (" + request.isActive + "," + request.value + ") from " + request.senderId);
                        }
                    }
                    else
                    {
                        recompute = true;

                        if (cell.inNeighborsActiveStatus[index])
                        {
                            //cell.inNeighborsValue[index] = Math.Max(cell.inNeighborsValue[index], value);
                            //active
                            cell.inNeighborsReceivedStatus[index] = true;
                        }
                        else
                        {
                            //set active
                            if (increasement)
                            {
                                //cell.inNeighborsValue[index] = value;
                                cell.inNeighborsActiveStatus[index] = true;
                                cell.inNeighborsReceivedStatus[index] = true;
                            }
                        }
                    }

                    if (recompute)
                    {
                        //cell.activeNeighborCount != 0
                        //recompute
                        double sum = 0;
                        for (int j = 0; j < cell.inNeighbors.Count; j++)
                        {
                            sum += cell.inNeighborsValue[j];
                        }

                        if (sum > cell.sum)
                        {
                            cell.sum = sum;
                            isActive = true;
                            //if (sum > 1) isActive = true;
                            //else isActive = false;
                        }
                        else
                        {
                            isActive = false;
                        }
                    }

                    //all received
                    if (isAllReceived(cell.inNeighborsActiveStatus, cell.inNeighborsReceivedStatus))
                    {
                        toPropagate = true;
                        //if (cellId == 1) Console.WriteLine(sum);
                    }

                    Console.WriteLine(cellId + " receive message (" + request.isActive + "," + request.value + ") from " + request.senderId);

                    /*
                    if (cellId == 0)
                    {
                        Console.WriteLine(cellId + "-End: Sum " + cell.sum +
                            " Received Message: (" + request.isActive + "," + request.value + ")" +
                            " isPropagate: " + toPropagate);
                    }*/

                    if (toPropagate)
                    {
                        propagate(cell, isActive);
                    }
                }
            });

            //Console.WriteLine("---zz---" + request.senderId);
        }
Beispiel #4
0
        public override void RankUpdatingHandler(RankUpdatingMessageReader request)
        {
            //Console.WriteLine("In rank updating handler");

            request.recipients.ForEach((cellId) =>
                {
                    using (var cell = Global.LocalStorage.UseSSSPCell(cellId))
                    {
                        //Console.WriteLine("Use cell: " + cellId);

                        cell.storedRankValue += request.rankValueP;
                        //Console.WriteLine("Stored: " + cell.storedRankValue);

                        if ((cell.storedRankValue > cell.rankValue * (1 + thresholdFactor)) && (cell.status))
                        {
                            //Console.WriteLine("Stored: " + cell.storedRankValue + " Rank: " + cell.rankValue);
                            //cell.rankValue = cell.storedRankValue;
                            newNodeSet.Add(cellId);
                        }
                        //Console.WriteLine(cell.CellID.Value + ": " + cell.newRankValue);

                        /*
                        MessageSorter sorter = new MessageSorter(cell.neighbors);
                        for (int i = 0; i < Global.SlaveCount; i++)
                        {
                                DistanceUpdatingMessageWriter msg = new DistanceUpdatingMessageWriter(cell.CellID.Value,
                                    cell.distance, sorter.GetCellRecipientList(i));
                                Global.CloudStorage.DistanceUpdatingToSlave(i, msg);
                        }
                        */
                    }
                });
        }
Beispiel #5
0
        public override void RankUpdatingHandler(RankUpdatingMessageReader request)
        {
            request.recipients.ForEach((recipient) =>
            {
                using (var cell = Global.LocalStorage.UseSSSPCell(recipient))
                {
                    int index = binarySearch(cell.inNeighbors, request.senderId);

                    if (cell.ranks[index] < request.value)
                    {
                        cell.sum += request.value - cell.ranks[index];
                        cell.ranks[index] = request.value;

                        if (cell.CellID == 3)
                        {
                            Console.WriteLine(cell.sum);
                        }

                        send(cell);
                    }
                }
            });
        }
Beispiel #6
0
        public override void RankUpdatingHandler(RankUpdatingMessageReader request)
        {
            //v++;
            //if (v >= 30000)
            //{
            //  return;
            //}

            //Console.WriteLine("In rank updating handler");

            long   senderId = request.senderId;
            double value    = request.value;

            request.recipients.ForEach((cellId) =>
            {
                using (var cell = Global.LocalStorage.UseSSSPCell(cellId))
                {
                    bool toPropagate  = false;
                    bool isActive     = false;
                    bool recompute    = false;
                    bool increasement = false;

                    int index = binarySearch(cell.inNeighbors, request.senderId);

                    if (value > cell.inNeighborsValue[index])
                    {
                        cell.inNeighborsValue[index] = value;
                        increasement = true;
                    }

                    /*
                     * if (cellId == 2)
                     * {
                     *  v++;
                     *  if (v % 10000 == 0) Console.WriteLine(cellId + "-Start: Sum " + cell.sum);
                     *  //" Received Message: (" + request.isActive + "," + request.value + ") " +
                     *  //" stored_inneighbor_ActiveStatus: " + cell.inNeighborsActiveStatus[index]);
                     * }*/

                    if (!request.isActive)
                    {
                        if (cell.inNeighborsActiveStatus[index])
                        {
                            cell.inNeighborsActiveStatus[index]   = false;
                            cell.inNeighborsReceivedStatus[index] = false;
                            //clear

                            /*
                             * for (int j = 0; j < cell.inNeighborsReceivedStatus.Count; j++)
                             * {
                             *  cell.inNeighborsReceivedStatus[j] = false;
                             * }
                             * cell.receivedNeighborCount = 0;
                             */
                        }
                        else
                        {
                            //Console.WriteLine("Impossible! " + " receive message (" + request.isActive + "," + request.value + ") from " + request.senderId);
                        }
                    }
                    else
                    {
                        recompute = true;

                        if (cell.inNeighborsActiveStatus[index])
                        {
                            //cell.inNeighborsValue[index] = Math.Max(cell.inNeighborsValue[index], value);
                            //active
                            cell.inNeighborsReceivedStatus[index] = true;
                        }
                        else
                        {
                            //set active
                            if (increasement)
                            {
                                //cell.inNeighborsValue[index] = value;
                                cell.inNeighborsActiveStatus[index]   = true;
                                cell.inNeighborsReceivedStatus[index] = true;
                            }
                        }
                    }

                    if (recompute)
                    {
                        //cell.activeNeighborCount != 0
                        //recompute
                        double sum = 0;
                        for (int j = 0; j < cell.inNeighbors.Count; j++)
                        {
                            sum += cell.inNeighborsValue[j];
                        }

                        if (sum > cell.sum)
                        {
                            cell.sum = sum;
                            isActive = true;
                            //if (sum > 1) isActive = true;
                            //else isActive = false;
                        }
                        else
                        {
                            isActive = false;
                        }
                    }

                    //all received
                    if (isAllReceived(cell.inNeighborsActiveStatus, cell.inNeighborsReceivedStatus))
                    {
                        toPropagate = true;
                        //if (cellId == 1) Console.WriteLine(sum);
                    }

                    Console.WriteLine(cellId + " receive message (" + request.isActive + "," + request.value + ") from " + request.senderId);

                    /*
                     * if (cellId == 0)
                     * {
                     *  Console.WriteLine(cellId + "-End: Sum " + cell.sum +
                     *      " Received Message: (" + request.isActive + "," + request.value + ")" +
                     *      " isPropagate: " + toPropagate);
                     * }*/

                    if (toPropagate)
                    {
                        propagate(cell, isActive);
                    }
                }
            });

            //Console.WriteLine("---zz---" + request.senderId);
        }