public DueTime GetEarliestPossibleStartTimeOf( ProductionOrderOperation productionOrderOperation) { DueTime maximumOfEarliestStartTimes = null; Providers providers = ZppConfiguration.CacheManager.GetAggregator() .GetAllChildStockExchangeProvidersOf(productionOrderOperation); foreach (var stockExchangeProvider in providers) { DueTime earliestStartTime = productionOrderOperation.GetStartTimeBackward(); if (earliestStartTime.IsGreaterThanOrEqualTo(stockExchangeProvider .GetStartTimeBackward())) { earliestStartTime = stockExchangeProvider.GetStartTimeBackward(); } else { throw new MrpRunException( "A provider of a demand cannot have a later dueTime."); } Demands stockExchangeDemands = ZppConfiguration.CacheManager.GetAggregator() .GetAllChildDemandsOf(stockExchangeProvider); if (stockExchangeDemands.Any() == false) // StockExchangeProvider has no childs (stockExchangeDemands), // take that from stockExchangeProvider { DueTime childDueTime = stockExchangeProvider.GetStartTimeBackward(); if (childDueTime.IsGreaterThan(earliestStartTime)) { earliestStartTime = childDueTime; } } else // StockExchangeProvider has childs (stockExchangeDemands) { foreach (var stockExchangeDemand in stockExchangeDemands) { DueTime stockExchangeDemandDueTime = stockExchangeDemand.GetStartTimeBackward(); if (stockExchangeDemandDueTime.IsGreaterThan(earliestStartTime)) { earliestStartTime = stockExchangeDemandDueTime; } } } if (maximumOfEarliestStartTimes == null || earliestStartTime.IsGreaterThan(maximumOfEarliestStartTimes)) { maximumOfEarliestStartTimes = earliestStartTime; } } return(maximumOfEarliestStartTimes); }
public DueTime GetEarliestPossibleStartTimeOf(ProductionOrderBom productionOrderBom) { DueTime earliestStartTime = productionOrderBom.GetStartTimeBackward(); Providers providers = ZppConfiguration.CacheManager.GetAggregator() .GetAllChildProvidersOf(productionOrderBom); if (providers.Count() > 1) { throw new MrpRunException("A productionOrderBom can only have one provider !"); } Provider stockExchangeProvider = providers.GetAny(); if (earliestStartTime.IsGreaterThanOrEqualTo( stockExchangeProvider.GetStartTimeBackward())) { earliestStartTime = stockExchangeProvider.GetStartTimeBackward(); } else { throw new MrpRunException("A provider of a demand cannot have a later dueTime."); } Demands stockExchangeDemands = ZppConfiguration.CacheManager.GetAggregator() .GetAllChildDemandsOf(stockExchangeProvider); if (stockExchangeDemands.Any() == false) // StockExchangeProvider has no childs (stockExchangeDemands), // take that from stockExchangeProvider { DueTime childDueTime = stockExchangeProvider.GetStartTimeBackward(); if (childDueTime.IsGreaterThan(earliestStartTime)) { earliestStartTime = childDueTime; } } else // StockExchangeProvider has childs (stockExchangeDemands) { foreach (var stockExchangeDemand in stockExchangeDemands) { DueTime stockExchangeDemandDueTime = stockExchangeDemand.GetStartTimeBackward(); if (stockExchangeDemandDueTime.IsGreaterThan(earliestStartTime)) { earliestStartTime = stockExchangeDemandDueTime; } } } return(earliestStartTime); }
public void ScheduleForward() { Stack <INode> S = new Stack <INode>(); // d_0 = 0 foreach (var node in _orderOperationGraph.GetLeafNodes()) { IScheduleNode scheduleNode = node.GetEntity(); if (scheduleNode.IsReadOnly() == false && scheduleNode.GetStartTimeBackward().IsSmallerThan(_simulationInterval.GetStart())) { // implicitly the due/endTime will also be set accordingly scheduleNode.SetStartTimeBackward(_simulationInterval.GetStart()); S.Push(node); } else // no forward scheduling is needed { } } // while S nor empty do while (S.Any()) { INode i = S.Pop(); IScheduleNode iAsScheduleNode = (IScheduleNode)i.GetEntity(); INodes predecessors = _orderOperationGraph.GetPredecessorNodes(i); if (predecessors != null && predecessors.Any()) { foreach (var predecessor in predecessors) { IScheduleNode predecessorScheduleNode = predecessor.GetEntity(); // if predecessor starts before endTime of current d/p --> change that if (predecessorScheduleNode.IsReadOnly() == false && predecessorScheduleNode .GetStartTimeBackward().IsSmallerThan(iAsScheduleNode.GetEndTimeBackward())) { // COPs are not allowed to change if (predecessorScheduleNode.GetType() != typeof(CustomerOrderPart)) { // don't take getDueTime() since in case of a demand, // this will be the startTime, which is to early // This must be the maximum endTime of all childs !!! DueTime maxEndTime = iAsScheduleNode.GetEndTimeBackward(); foreach (var successor in _orderOperationGraph.GetSuccessorNodes( predecessor)) { DueTime successorsEndTime = successor.GetEntity().GetEndTimeBackward(); if (successorsEndTime.IsGreaterThan(maxEndTime)) { maxEndTime = successorsEndTime; } } predecessorScheduleNode.SetStartTimeBackward(maxEndTime); } } S.Push(predecessor); } } } }