From 1b0f461e0db93c3f504b8be975a5b7ffddbcc584 Mon Sep 17 00:00:00 2001
From: Tianma21 <Administrator@TOTDQAE01.tianmame.cn>
Date: 星期日, 08 十月 2023 13:47:22 +0800
Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/TIANMA_JITUAN into dev

---
 LibMacroPlannerOptimizer/BL/Type_CapacityPlanningSuboptimizer/Method_CapacityPlanningAlgorithmHandleFeasibleOperationDependentDemandInputG.qbl |   39 ++++++++++++++++++++-------------------
 1 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/LibMacroPlannerOptimizer/BL/Type_CapacityPlanningSuboptimizer/Method_CapacityPlanningAlgorithmHandleFeasibleOperationDependentDemandInputG.qbl b/LibMacroPlannerOptimizer/BL/Type_CapacityPlanningSuboptimizer/Method_CapacityPlanningAlgorithmHandleFeasibleOperationDependentDemandInputG.qbl
index dcaa2a7..48ca380 100644
--- a/LibMacroPlannerOptimizer/BL/Type_CapacityPlanningSuboptimizer/Method_CapacityPlanningAlgorithmHandleFeasibleOperationDependentDemandInputG.qbl
+++ b/LibMacroPlannerOptimizer/BL/Type_CapacityPlanningSuboptimizer/Method_CapacityPlanningAlgorithmHandleFeasibleOperationDependentDemandInputG.qbl
@@ -9,7 +9,6 @@
   Description: 'Assign the optimal quantity from optimizer for dependent demand in input group.'
   TextBody:
   [*
-    // Tianma fix 20230727
     // Dependent demand of input group fulfillment
     ptperiod := periodtaskoperation.UnitPeriod().Period_MP();
     operation := periodtaskoperation.Operation();
@@ -19,22 +18,24 @@
               dd, 
               dd.HasRegularProductForOptimizer() or dd.OperationInput().GetIsProductInOptimizerRun( runcontext.IsPostProcessing() ) )
     {
-      pispipperiods := construct( Period_MPs, constcontent ); 
-      if ( getfromperiodtask ) // in case we are able to get from period tasks, below method refinds periodtask for (operation, ptperiod) i.e. periodtaskoperation and then output dep.demand periods
-      {
-        traverse( periodtaskoperation, DependentDemand.ProductInStockingPointInPeriodPlanningLeaf.Period_MP, ddperiod ) 
-        {
-          pispipperiods.Add( ddperiod ); 
-        }
-      }
-      else
-      {
-        CapacityPlanningSuboptimizer::GetOperationDependentDemandPeriods( ptperiod, operation, &pispipperiods, getfromperiodtask );
-      }
+      fulfilledqty := 0.0; 
       
-      fulfilledqty := 0.0;  
       if( operation.HasLeadTime() )     // Get the dependent demands that is located at different period from the period of period task.
       {
+        // compute dependent demand periods
+        pispipperiods := construct( Period_MPs, constcontent ); 
+        if ( getfromperiodtask ) // in case we are able to get from period tasks, below method refinds periodtask for (operation, ptperiod) i.e. periodtaskoperation and then output dep.demand periods
+        {
+          traverse( periodtaskoperation, DependentDemand.ProductInStockingPointInPeriodPlanningLeaf.Period_MP, ddperiod ) 
+          {
+            pispipperiods.Add( ddperiod ); 
+          }
+        }
+        else
+        {
+          CapacityPlanningSuboptimizer::GetOperationDependentDemandPeriods( ptperiod, operation, &pispipperiods, getfromperiodtask );
+        }
+        
         fulfilledqty := sum( pispipperiods, Elements, pispipperiod,
                              this.GetOptimalValue( program.PartialOperationDemandQtyVariables().Get( dd.OperationInput(), pispipperiod, ptperiod ) ) );
         if ( runcontext.IsMetaIteration() and operation.IsBlending() ) // no filtering for numerical sensitive blending operation in meta optimizer
@@ -44,15 +45,15 @@
         }                     
       }
       else
-      {
-        fulfilledqty := sum( pispipperiods, Elements, pispipperiod,
-                             this.GetOptimalValue( program.OperationDemandQtyVariables().Get( dd.OperationInput(), pispipperiod ) ) );
+      { 
+        // note that in case there is no lead time then the set of dependent demand periods just equals the singleton set {ptperiod}
+        fulfilledqty := this.GetOptimalValue( program.OperationDemandQtyVariables().Get( dd.OperationInput(), ptperiod ) );
         if( runcontext.IsMetaIteration() and operation.IsBlending() ) // no filtering for numerical sensitive blending operation in meta optimizer
         {
-          fulfilledqty := sum( pispipperiods, Elements, pispipperiod,
-                               this.GetOptimalValueUnfiltered( program.OperationDemandQtyVariables().Get( dd.OperationInput(), pispipperiod ) ) );
+          fulfilledqty := this.GetOptimalValueUnfiltered( program.OperationDemandQtyVariables().Get( dd.OperationInput(), ptperiod ) );
         }
       }
+      
       dd.OptimizerFulfilledQuantity( fulfilledqty );
     }
   *]

--
Gitblit v1.9.3