Example #1
0
        private void ScheduleBackwardSecond(IDirectedGraph <INode> orderOperationGraph)
        {
            INodes childRootNodes = new Nodes();

            foreach (var rootNode in orderOperationGraph.GetRootNodes())
            {
                if (rootNode.GetEntity().GetType() != typeof(CustomerOrderPart))
                {
                    continue;
                }

                Providers childProviders = ZppConfiguration.CacheManager.GetAggregator()
                                           .GetAllChildProvidersOf((Demand)rootNode.GetEntity());
                if (childProviders == null || childProviders.Count() > 1)
                {
                    throw new MrpRunException(
                              "After Mrp1 a CustomerOrderPart MUST have exact one child.");
                }

                childRootNodes.AddAll(childProviders.ToNodes());
            }

            IBackwardsScheduler backwardsScheduler =
                new BackwardScheduler(childRootNodes.ToStack(), orderOperationGraph, false);

            backwardsScheduler.ScheduleBackward();
        }
        public void ReplaceNodeByDirectedGraph(Id nodeId, IDirectedGraph <INode> graphToInsert)
        {
            INodes predecessors = GetPredecessorNodes(nodeId);
            INodes successors   = GetSuccessorNodes(nodeId);

            RemoveNode(nodeId, false);
            // predecessors --> roots
            if (predecessors != null)
            {
                foreach (var predecessor in predecessors)
                {
                    foreach (var rootNode in graphToInsert.GetRootNodes())
                    {
                        AddEdge(new Edge(predecessor, rootNode));
                    }
                }
            }

            // leafs --> successors
            if (successors != null)
            {
                foreach (var leaf in graphToInsert.GetLeafNodes())
                {
                    foreach (var successor in successors)
                    {
                        AddEdge(new Edge(leaf, successor));
                    }
                }
            }

            // add all edges from graphToInsert
            AddEdges(graphToInsert.GetEdges());
        }
Example #3
0
        public void TestGetRoots()
        {
            INode[] nodes = EntityFactory.CreateDummyNodes(7);
            IDirectedGraph <INode> directedGraph = CreateBinaryDirectedGraph(nodes);
            INodes roots = directedGraph.GetRootNodes();

            Assert.True(roots != null, "There should be roots in the graph.");

            Assert.True(roots.Contains(nodes[0]), $"Leafs do not contain node {nodes[0]}.");
            Assert.True(roots.Count() == 1, "Roots must contain exact one node.");
        }
Example #4
0
        private void ScheduleBackwardFirst(IDirectedGraph <INode> orderOperationGraph)
        {
            INodes rootNodes = new Nodes();

            foreach (var rootNode in orderOperationGraph.GetRootNodes())
            {
                if (rootNode.GetEntity().GetType() == typeof(CustomerOrderPart))
                {
                    rootNodes.Add(rootNode);
                }
            }

            IBackwardsScheduler backwardsScheduler =
                new BackwardScheduler(rootNodes.ToStack(), orderOperationGraph, true);

            backwardsScheduler.ScheduleBackward();
        }
Example #5
0
        public void TestGetPredecessorNodes()
        {
            INode[] nodes = EntityFactory.CreateDummyNodes(7);
            IDirectedGraph <INode> directedGraph = CreateBinaryDirectedGraph(nodes);
            INodes roots = directedGraph.GetRootNodes();

            foreach (var node in nodes)
            {
                INodes predecessors = directedGraph.GetPredecessorNodes(node);
                bool   isRoot       = roots.Contains(node);
                if (isRoot)
                {
                    Assert.True(predecessors == null, "A root cannot have predecessors.");
                }
                else
                {
                    Assert.True(predecessors != null, "A non-root MUST have predecessors.");
                }
            }
        }