Exemple #1
0
        /// <summary>
        /// sum costs over all nodes
        /// </summary>
        /// <param name="throughputTotalCost">a cost</param>
        /// <param name="latencyTotalCost">a cost</param>
        /// <param name="registersTotalCost">a cost</param>
        internal void SumCosts(
            out long throughputTotalCost,
            out long latencyTotalCost,
            out long registersTotalCost)
        {
            var sort = DelayGraphAlgorithms.TopologicalSort(Graph).ToList();

            throughputTotalCost = DelayGraphAlgorithms.FindMaxThroughputCostCore(sort, Graph, RegisteredTerminals);
            latencyTotalCost    = DelayGraphAlgorithms.FindMaxLatencyCore(sort, Graph, RegisteredTerminals);
            registersTotalCost  = 0;
            foreach (var vertex in Graph.Vertices.Where(Registered))
            {
                registersTotalCost += vertex.RegisterCostIfRegistered;
            }
        }
Exemple #2
0
        /// <summary>
        /// fix sibling to be registered if any is registered
        /// </summary>
        /// <returns>a count of number of nodes that changed</returns>
        private int FixSolutionForSiblingVertices()
        {
            int count = 0;
            HashSet <DelayGraphVertex> grouped;
            var listOfSiblings = DelayGraphAlgorithms.FindVertexGroups(Graph, out grouped);

            foreach (var siblings in listOfSiblings)
            {
                if (siblings.Any(Registered) && siblings.Count() > 1)
                {
                    // at least one in sibling is registered
                    var verticesWhichAreNotRegistered = siblings.Where(v => !Registered(v));
                    count += verticesWhichAreNotRegistered.Count();
                    foreach (var v in verticesWhichAreNotRegistered)
                    {
                        RegisteredTerminals.Add(v);
                    }
                }
            }
            return(count);
        }