Beispiel #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);
        }
Beispiel #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;
            }
        }
Beispiel #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);
        }
Beispiel #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);
Beispiel #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);
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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;
        }