コード例 #1
0
        /// <summary>
        /// Returns the specified nodes sorted stochastically according to
        /// their Euclidian distance value with a penalty for node changes.
        /// </summary>
        /// <param name="nodes">
        /// The nodes to be sorted.
        /// </param>
        /// <returns>
        /// The nodes stochastically sorted.
        /// </returns>
        protected override NodeWrapper<INetworkNode>[] OrderChildren(NodeWrapper<INetworkNode>[] nodes)
        {
            // nodes = base.OrderChildren(nodes);
            var target = (Location)(this.CurrentIndex == 0 ? this.Destination : this.Origin);

            foreach (var wrapper in nodes)
            {
                wrapper.EuclidianDistance = GeometryHelper.GetStraightLineDistance((Location)wrapper.Node, target);

                // wrapper.EuclidianDistance = 1;
                if (((PtvDataProvider)this.provider).RoutesIntersect(wrapper.Node, this.Current[0].Node))
                {
                    // wrapper.EuclidianDistance *= 0.5; //best
                    wrapper.EuclidianDistance *= 0.5;
                }
            }

            // Array.Sort(nodes, new NodeComparer());
            // Array.Reverse(nodes);
            nodes.StochasticSort(this.Entropy);

            return nodes.Reverse().ToArray();
        }
コード例 #2
0
        /// <summary>
        /// Returns the specified nodes sorted stochastically according to
        /// their Euclidian distance value only.
        /// </summary>
        /// <param name="nodes">
        /// The nodes to be sorted.
        /// </param>
        /// <returns>
        /// The nodes stochastically sorted.
        /// </returns>
        protected override NodeWrapper<INetworkNode>[] OrderChildren(NodeWrapper<INetworkNode>[] nodes)
        {
            var target = (Location)(this.CurrentIndex == 0 ? this.Destination : this.Origin);
            foreach (var wrapper in nodes)
            {
                /*
                if (Bidirectional)
                {
                    INetworkNode otherCurrent = this.current[CurrentIndex == 0 ? 1 : 0].Node;
                    /*
                    wrapper.EuclidianDistance = this.Bidirectional && otherCurrent != null
                                                         ? GeometryHelper.GetStraightLineDistance(
                                                             (Location)wrapper.Node, (Location)otherCurrent)
                                                         : GeometryHelper.GetStraightLineDistance(
                                                             (Location)wrapper.Node, (Location)this.Destination);
                     *

                }
                else
                {
                    wrapper.EuclidianDistance = GeometryHelper.GetStraightLineDistance((Location)wrapper.Node, (Location)this.Destination);
                }

                //if (wrapper.Node.TransportType == "Train")
                //{
                //    wrapper.EuclidianDistance /= 2.0;
               // }
                 *
                 **/
                wrapper.EuclidianDistance = GeometryHelper.GetStraightLineDistance((Location)wrapper.Node, target);
            }

            // Array.Sort(nodes, new NodeComparer());
            nodes.StochasticSort(this.Entropy);

            return nodes.Reverse().ToArray();

            // return nodes.OrderBy(n => n.EuclidianDistance).Reverse().ToArray();
        }