haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Quintiq file version 2.0
#parent: #root
Method SmartPlanGapFill (
  Boolean isusingselectedunits,
  Units units,
  LibOpt_Scope scope,
  RunContextForCapacityPlanning runcontext
)
{
  Description: 'gap filling routing to make optimizer horizon contiguous per pispip'
  TextBody:
  [*
    if ( runcontext.IsMetaIteration() ) 
    {
      error( 'Not expecting to use this case anymore' ); 
    }
    else
    {
      hasgap := true;
      pisps := selectset( scope.GetPISPIPInOptimizerRun(), Elements.ProductInStockingPoint_MP, pisp, true );  // 20230720 Tianma Fix
      
      for( i:= 1; i<= 100 and hasgap; i++ )
      {   
        nomoregap := true;
      
        traverse( pisps, Elements, pisp )
        {
          firstpispip := minselect( pisp, ProductInStockingPointInPeriodPlanning, pispip, scope.Contains( pispip.PISPIPInOptimizerRun() ), pispip.Start() );
          lastpispip := maxselect( pisp, ProductInStockingPointInPeriodPlanning, pispip, scope.Contains( pispip.PISPIPInOptimizerRun() ), pispip.End() );
          
          traverse( pisp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), pispip,
                    not scope.Contains( pispip.PISPIPInOptimizerRun() ) 
                    and pispip.Start() >= firstpispip.Start()
                    and pispip.End() <= lastpispip.End() )
          {
            this.SetOptimizerInputSmartPlan( pispip, isusingselectedunits, units, 0 /*depth*/, scope, runcontext );
            nomoregap := false;
          }
        }
        hasgap := not nomoregap;
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}