Esempio n. 1
0
        /// <summary>
        /// Returns the cheapest incoming plan edge and its cost,
        /// excluding nodes contained within the given top super node (if given)
        /// </summary>
        public override PlanEdge GetCheapestIncoming(PlanPseudoNode excludeTopNode, out float minCost)
        {
            minCost = float.MaxValue;
            PlanEdge minEdge = null;

            PlanPseudoNode current = Child;

            do
            {
                float    curCost;
                PlanEdge curEdge = current.GetCheapestIncoming(excludeTopNode, out curCost);
                if (curEdge != null)
                {
                    PlanPseudoNode target = curEdge.Target;
                    while (target.SuperNode != this)
                    {
                        target = target.SuperNode;
                    }

                    if (PreferNewEdge(minEdge, minCost, curEdge, curCost))
                    {
                        minCost = curCost;
                        minEdge = curEdge;
                    }
                }
                current = current.IncomingMSAEdge.Source;
                while (current.SuperNode != this)
                {
                    current = current.SuperNode;
                }
            }while(current != Child);
            return(minEdge);
        }
Esempio n. 2
0
        public PlanSuperNode(PlanPseudoNode cycleNode)
        {
            Child = cycleNode;

            // Find cheapest edge within cycle
            PlanPseudoNode current = Child;

            minCycleEdgeCost = float.MaxValue;
            do
            {
                current.SuperNode = this;
                if (current.IncomingMSAEdge.mstCost < minCycleEdgeCost)
                {
                    minCycleEdgeCost = current.IncomingMSAEdge.mstCost;
                }
                current = current.IncomingMSAEdge.Source;
                while (current.SuperNode != null && current.SuperNode != this)
                {
                    current = current.SuperNode;
                }
            }while(current != Child);

            // Adjust costs of incoming edges
            foreach (PlanEdge edge in Incoming)
            {
                PlanPseudoNode curTarget = edge.Target;
                while (curTarget.SuperNode != this)
                {
                    curTarget = curTarget.SuperNode;
                }
                edge.mstCost -= curTarget.IncomingMSAEdge.mstCost - minCycleEdgeCost;
            }

            // Find cheapest incoming edge and set Child appropriately
            float cost;

            IncomingMSAEdge = GetCheapestIncoming(this, out cost);
            Child           = IncomingMSAEdge.Target;
            while (Child.SuperNode != this)
            {
                Child = Child.SuperNode;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Returns the cheapest incoming plan edge and its cost,
        /// excluding nodes contained within the given top super node (if given)
        /// </summary>
        public override PlanEdge GetCheapestIncoming(PlanPseudoNode excludeTopNode, out float minCost)
        {
            minCost = float.MaxValue;
            PlanEdge minEdge = null;

            foreach (PlanEdge edge in IncomingEdges)
            {
                if (excludeTopNode != null && edge.Source.TopNode == excludeTopNode)
                {
                    continue;
                }
                if (PreferNewEdge(minEdge, minCost, edge, edge.mstCost))
                {
                    minCost = edge.mstCost;
                    minEdge = edge;
                }
            }
            return(minEdge);
        }
Esempio n. 4
0
 /// <summary>
 /// Returns the cheapest incoming plan edge and its cost,
 /// excluding nodes contained within the given top super node (if given)
 /// </summary>
 public abstract PlanEdge GetCheapestIncoming(PlanPseudoNode excludeTopNode, out float cost);
Esempio n. 5
0
 /// <summary>
 /// Returns the cheapest incoming plan edge and its cost,
 /// excluding nodes contained within the given top super node (if given)
 /// </summary>
 public abstract PlanEdge GetCheapestIncoming(PlanPseudoNode excludeTopNode, out float cost);
Esempio n. 6
0
        /// <summary>
        /// Returns the cheapest incoming plan edge and its cost,
        /// excluding nodes contained within the given top super node (if given)
        /// </summary>
        public override PlanEdge GetCheapestIncoming(PlanPseudoNode excludeTopNode, out float minCost)
        {
            minCost = float.MaxValue;
            PlanEdge minEdge = null;

            PlanPseudoNode current = Child;
            do
            {
                float curCost;
                PlanEdge curEdge = current.GetCheapestIncoming(excludeTopNode, out curCost);
                if (curEdge != null)
                {
                    PlanPseudoNode target = curEdge.Target;
                    while (target.SuperNode != this)
                        target = target.SuperNode;

                    if (PreferNewEdge(minEdge, minCost, curEdge, curCost))
                    {
                        minCost = curCost;
                        minEdge = curEdge;
                    }
                }
                current = current.IncomingMSAEdge.Source;
                while (current.SuperNode != this)
                    current = current.SuperNode;
            }
            while (current != Child);
            return minEdge;
        }
Esempio n. 7
0
        public PlanSuperNode(PlanPseudoNode cycleNode)
        {
            Child = cycleNode;

            // Find cheapest edge within cycle
            PlanPseudoNode current = Child;
            minCycleEdgeCost = float.MaxValue;
            do
            {
                current.SuperNode = this;
                if (current.IncomingMSAEdge.mstCost < minCycleEdgeCost)
                    minCycleEdgeCost = current.IncomingMSAEdge.mstCost;
                current = current.IncomingMSAEdge.Source;
                while (current.SuperNode != null && current.SuperNode != this)
                    current = current.SuperNode;
            }
            while (current != Child);

            // Adjust costs of incoming edges
            foreach (PlanEdge edge in Incoming)
            {
                PlanPseudoNode curTarget = edge.Target;
                while (curTarget.SuperNode != this)
                    curTarget = curTarget.SuperNode;
                edge.mstCost -= curTarget.IncomingMSAEdge.mstCost - minCycleEdgeCost;
            }

            // Find cheapest incoming edge and set Child appropriately
            float cost;
            IncomingMSAEdge = GetCheapestIncoming(this, out cost);
            Child = IncomingMSAEdge.Target;
            while (Child.SuperNode != this)
                Child = Child.SuperNode;
        }
Esempio n. 8
0
        /// <summary>
        /// Returns the cheapest incoming plan edge and its cost,
        /// excluding nodes contained within the given top super node (if given)
        /// </summary>
        public override PlanEdge GetCheapestIncoming(PlanPseudoNode excludeTopNode, out float minCost)
        {
            minCost = float.MaxValue;
            PlanEdge minEdge = null;

            foreach (PlanEdge edge in IncomingEdges)
            {
                if (excludeTopNode != null && edge.Source.TopNode == excludeTopNode) continue;
                if (PreferNewEdge(minEdge, minCost, edge, edge.mstCost))
                {
                    minCost = edge.mstCost;
                    minEdge = edge;
                }
            }
            return minEdge;
        }