コード例 #1
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.");
                }
            }
        }
コード例 #2
0
        public void TestGetPredecessorNodesRecursive()
        {
            INode[] nodes = EntityFactory.CreateDummyNodes(6);
            IDirectedGraph <INode> directedGraph = CreateBinaryDirectedGraph(nodes);

            foreach (var node in nodes)
            {
                INodes predecessors = directedGraph.GetPredecessorNodes(node);
                if (predecessors == null)
                {
                    continue;
                }
                INodes predecessorsRecursive = directedGraph.GetPredecessorNodesRecursive(node);
                Assert.True(predecessorsRecursive.Contains(node) == false);
                foreach (var predecessor in predecessors)
                {
                    Assert.True(predecessorsRecursive.Contains(predecessor));
                }
            }
        }
コード例 #3
0
        /**
         * Top-down
         */
        public void ScheduleBackward()
        {
            // S = {0} (alle einplanbaren Operations/Demands/Providers)

            if (_clearOldTimes)
            {
                // d_0 = 0
                foreach (var uniqueNode in _orderOperationGraph.GetAllUniqueNodes())
                {
                    IScheduleNode uniqueScheduleNode = uniqueNode.GetEntity();
                    if (uniqueScheduleNode.IsReadOnly() == false &&
                        uniqueScheduleNode.GetType() != typeof(CustomerOrderPart))
                    {
                        uniqueScheduleNode.ClearStartTimeBackward();
                        uniqueScheduleNode.ClearEndTimeBackward();
                    }
                }
            }

            // while S nor empty do
            while (_S.Any())
            {
                INode         i = _S.Pop();
                IScheduleNode iAsScheduleNode = i.GetEntity();

                INodes successorNodes = _orderOperationGraph.GetSuccessorNodes(i);
                if (successorNodes != null && successorNodes.Any())
                {
                    foreach (var successor in successorNodes)
                    {
                        _S.Push(successor);

                        IScheduleNode successorScheduleNode = successor.GetEntity();
                        if (successorScheduleNode.IsReadOnly())
                        {
                            continue;
                        }


                        // Konservativ vorwärtsterminieren ist korrekt,
                        // aber rückwärts muss wenn immer möglich terminiert werden
                        // (prüfe parents und ermittle minStart und setze das)
                        INodes predecessorNodes =
                            _orderOperationGraph.GetPredecessorNodes(successor);
                        DueTime minStartTime = iAsScheduleNode.GetStartTimeBackward();
                        if (minStartTime == null)
                        {
                            throw new MrpRunException(
                                      "How can the StartTime of an already scheduled node be null ?");
                        }

                        foreach (var predecessorNode in predecessorNodes)
                        {
                            DueTime predecessorsStartTime =
                                predecessorNode.GetEntity().GetStartTimeBackward();
                            if (predecessorsStartTime != null &&
                                predecessorsStartTime.IsSmallerThan(minStartTime))
                            {
                                minStartTime = predecessorsStartTime;
                            }
                        }

                        if (successorScheduleNode.GetType() == typeof(CustomerOrderPart))
                        {
                            throw new MrpRunException(
                                      "Only a root node can be a CustomerOrderPart.");
                        }

                        if (successorScheduleNode.IsReadOnly() == false)
                        {
                            successorScheduleNode.SetEndTimeBackward(minStartTime);
                        }
                    }
                }
            }
        }