/** * No need to traverse --> graph is ready, just do some modifications: * remove ProductionOrderBoms, replace ProductionOrder by operationGraph, ... */ private DemandToProviderGraph CreateGraph3() { IDbTransactionData dbTransactionData = ZppConfiguration.CacheManager.GetDbTransactionData(); DemandToProviderGraph demandToProviderGraph = new DemandToProviderGraph(); // replace ProductionOrder by operationGraph foreach (var productionOrder in dbTransactionData.ProductionOrderGetAll()) { if (productionOrder.IsReadOnly() == false) { var productionOrderBomNode = new Node(productionOrder); if (demandToProviderGraph.Contains(productionOrderBomNode)) { OperationGraph operationGraph = new OperationGraph((ProductionOrder)productionOrder); INodes leafOfOperationGraph = operationGraph.GetLeafNodes(); demandToProviderGraph.ReplaceNodeByDirectedGraph(productionOrderBomNode, operationGraph); /*// remove all arrows from leaf, since material must be ready to the * // corresponding operation not to first operation * INodes successorsOfLeaf = * demandToProviderGraph.GetSuccessorNodes(leafOfOperationGraph.GetAny()); * foreach (var successor in successorsOfLeaf) * { * demandToProviderGraph.RemoveEdge(leafOfOperationGraph.GetAny(), successor); * }*/// --> somehow not neccessary } } } // connect every ProductionOrderBom successor to its operation foreach (var productionOrderBom in dbTransactionData.ProductionOrderBomGetAll()) { if (productionOrderBom.IsReadOnly() == false) { var productionOrderBomNode = new Node(productionOrderBom); if (demandToProviderGraph.Contains(productionOrderBomNode)) { ProductionOrderOperation productionOrderOperation = ((ProductionOrderBom)productionOrderBom).GetProductionOrderOperation(); INodes successorNodes = demandToProviderGraph.GetSuccessorNodes(productionOrderBom.GetId()); demandToProviderGraph.RemoveNode(productionOrderBomNode.GetId(), false); foreach (var successor in successorNodes) { demandToProviderGraph.AddEdge( new Edge(new Node(productionOrderOperation), successor)); } } } } return(demandToProviderGraph); }
public void TestBackwardSchedulingTransitionTimeBetweenOperationsIsCorrect( string testConfigurationFileName) { InitThisTest(testConfigurationFileName); IDbTransactionData dbTransactionData = ZppConfiguration.CacheManager.ReloadTransactionData(); IDirectedGraph <INode> operationGraph = new OperationGraph(new OrderOperationGraph()); IStackSet <INode> innerLeafs = operationGraph.GetLeafNodes().ToStackSet(); IStackSet <INode> traversedNodes = new StackSet <INode>(); foreach (var leaf in innerLeafs) { INodes predecessorNodesRecursive = operationGraph.GetPredecessorNodesRecursive(leaf); IStackSet <ProductionOrderOperation> newPredecessorNodes = new StackSet <ProductionOrderOperation>( predecessorNodesRecursive.Select(x => (ProductionOrderOperation)x.GetEntity())); ProductionOrderOperation lastOperation = (ProductionOrderOperation)leaf.GetEntity(); ValidatePredecessorOperationsTransitionTimeIsCorrect(newPredecessorNodes, lastOperation, operationGraph, traversedNodes); traversedNodes.Push(leaf); } int expectedTraversedOperationCount = new Stack <ProductionOrderOperation>( dbTransactionData.ProductionOrderOperationGetAll()).Count(); int actualTraversedOperationCount = traversedNodes.Count(); Assert.True(actualTraversedOperationCount.Equals(expectedTraversedOperationCount), $"expectedTraversedOperationCount {expectedTraversedOperationCount} " + $"doesn't equal actualTraversedOperationCount {actualTraversedOperationCount}'"); }