Exemple #1
0
        /// <summary>
        /// Get the candidates of the i.
        /// get the candidate for the jucntion i.
        /// An Inter-path is a sequence of road intersections that connect the source to the destination, satisfying two key requirements, shorter routing distances, and higher connectivity. To meet these two requirements, we developed a heuristic function with two probability distributions, the connectivity distribution (denoted by ξ ̃_(i,j)) and the shortest distance distribution (denoted by〖 Φ ̃〗_(i,j)).
        /// </summary>
        /// <param name="_i"></param>
        /// <returns></returns>
        public CandidateJunction CandidateJunction(Junction _i, Junction _des)
        {
            List <CandidateJunction>    candidateJunctions = new List <Routing.CandidateJunction>();
            ShortestDistanceSelector    computer           = new ShortestDistanceSelector();
            SegmentConnectivitySelector connect            = new SegmentConnectivitySelector();

            // values:
            foreach (Junction _j in _i.Adjacentjunctions)
            {
                RoadSegment roadSegment = GetRoadSegment(_i, _j);
                if (roadSegment != null)
                {
                    CandidateJunction can = new Routing.CandidateJunction();
                    can.CurrentJunction     = _i;
                    can.NextJunction        = _j;
                    can.NextJunction        = _j; // CAN id.
                    can.DestinationJunction = _des;
                    can.NextRoadSegment     = roadSegment;

                    // values:
                    //1- shortes distance:
                    can.Perpendiculardistance = computer.Perpendiculardistance(_j.CenterLocation, _i.CenterLocation, _des.CenterLocation);

                    if (_des.JID == _j.JID)
                    {
                        can.AngleDotProdection = 1;
                    }
                    else
                    {
                        computer.AngleDotProdection(_i.CenterLocation, _j.CenterLocation, _des.CenterLocation);
                    }

                    can.Length = computer.Length(_i.CenterLocation, _j.CenterLocation);
                    //-2 connectivity.
                    can.Connectivity = connect.SegmentConnectivity(roadSegment.SegmentLength, roadSegment.VehiclesCount, roadSegment.VehicleInterArrivalMean, Settings.Default.CommunicationRange, roadSegment.LanesCount);


                    candidateJunctions.Add(can);
                }
            }

            // get the max priority.
            if (candidateJunctions.Count > 0)
            {
                CandidateJunction max = candidateJunctions[0];
                for (int j = 1; j < candidateJunctions.Count; j++)
                {
                    if (candidateJunctions[j].HeuristicFunction > max.HeuristicFunction)
                    {
                        max = candidateJunctions[j];
                    }
                }

                return(max);
            }

            return(null);
        }
Exemple #2
0
        /// <summary>
        /// Get the candidates of the i.
        /// get the candidate for the jucntion i.
        /// An Inter-path is a sequence of road intersections that connect the source to the destination, satisfying two key requirements, shorter routing distances, and higher connectivity. To meet these two requirements, we developed a heuristic function with two probability distributions, the connectivity distribution (denoted by ξ ̃_(i,j)) and the shortest distance distribution (denoted by〖 Φ ̃〗_(i,j)).
        /// </summary>
        /// <param name="_i"></param>
        /// <returns></returns>
        public CandidateJunction CandidateJunction(Junction _i, Junction _des)
        {
            string protocol = Settings.Default.RoutingProtocolString;
            List <CandidateJunction>    candidateJunctions = new List <Routing.CandidateJunction>();
            ShortestDistanceSelector    computer           = new ShortestDistanceSelector();
            SegmentConnectivitySelector connect            = new SegmentConnectivitySelector();

            // values:
            foreach (Junction _j in _i.Adjacentjunctions)
            {
                RoadSegment roadSegment = GetRoadSegment(_i, _j);
                if (roadSegment != null)
                {
                    switch (protocol)
                    {
                    case "VEFR":
                    {
                        CandidateJunction can = new CandidateJunction();
                        can.CurrentJunction             = _i;
                        can.NextJunction                = _j;
                        can.NextJunction                = _j; // CAN id.
                        can.DestinationJunction         = _des;
                        can.NextRoadSegment             = roadSegment;
                        can.RSSInput                    = new RSSInput(); // new one.
                        can.RSSInput.DensityCrisp       = Settings.Default.WeightConnectivity * Crisps.Density(roadSegment.SegmentLength, roadSegment.VehiclesCount, Settings.Default.CommunicationRange, roadSegment.LanesCount);
                        can.RSSInput.ValidDistanceCrisp = Settings.Default.WeightShortestDistance * Crisps.ValidDistance(_i.CenterLocation, _j.CenterLocation, _des.CenterLocation);
                        can.Priority                    = RSSRuleBase.Aggregate(can.RSSInput);
                        candidateJunctions.Add(can);
                        if (Settings.Default.SaveJunctionsCrisp)
                        {
                            ///
                        }
                        if (_des.JID == _j.JID)
                        {
                            return(can);
                        }
                    }
                    break;

                    case "HERO":
                    {
                        CandidateJunction can = new Routing.CandidateJunction();
                        can.CurrentJunction     = _i;
                        can.NextJunction        = _j;
                        can.NextJunction        = _j;  // CAN id.
                        can.DestinationJunction = _des;
                        can.NextRoadSegment     = roadSegment;

                        // values:
                        //1- shortes distance:
                        can.Perpendiculardistance = computer.Perpendiculardistance(_j.CenterLocation, _i.CenterLocation, _des.CenterLocation);

                        if (_des.JID == _j.JID)
                        {
                            can.AngleDotProdection = 1;
                        }
                        else
                        {
                            computer.AngleDotProdection(_i.CenterLocation, _j.CenterLocation, _des.CenterLocation);
                        }

                        can.Length = computer.Length(_i.CenterLocation, _j.CenterLocation);
                        //-2 connectivity.
                        can.Connectivity = connect.SegmentConnectivity(roadSegment.SegmentLength, roadSegment.VehiclesCount, roadSegment.VehicleInterArrivalMean, Settings.Default.CommunicationRange, roadSegment.LanesCount);


                        candidateJunctions.Add(can);
                    }
                    break;
                    }
                }
            }
            switch (protocol)
            {
            case "VEFR":
            {
                if (candidateJunctions.Count > 0)
                {
                    CandidateJunction max = candidateJunctions[0];
                    for (int j = 1; j < candidateJunctions.Count; j++)
                    {
                        if (candidateJunctions[j].Priority > max.Priority)
                        {
                            max = candidateJunctions[j];
                        }
                    }
                    return(max);
                }
            }
            break;

            case "HERO":
            {
                // get the max priority.
                if (candidateJunctions.Count > 0)
                {
                    CandidateJunction max = candidateJunctions[0];
                    for (int j = 1; j < candidateJunctions.Count; j++)
                    {
                        if (candidateJunctions[j].HeuristicFunction > max.HeuristicFunction)
                        {
                            max = candidateJunctions[j];
                        }
                    }

                    return(max);
                }
            }
            break;
            }
            return(null);
        }