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
46
47
48
49
50
Quintiq file version 2.0
#parent: #root
Method DoInitializeNonConst (
  LibOpt_Task task
)
{
  TextBody:
  [*
    start := OS::PrecisionCounter(); 
    this.CheckScalingFactors(); // Prevent badly initialized zero or negative scaling factors
    
    this.BaseForActualTime( DateTime::ActualTime() ); 
    this.DebugStoreScopeInfo( task.Scope() ); 
    this.DetailsCPLEX( '' ); 
    this.AllLevelsOptimal( true ); 
    
    scope := task.Scope(); 
    this.SetPeriodTaskOperationRelationInScope( scope ); // set relation so we can go from Operation in scope directly to its period tasks in scope
    
    runcontext := this.GetRunContextConst(); 
    
    this.CreateSubOptimizerLevels( runcontext, task ); 
    
    if ( runcontext.IsMetaIteration() and this.Optimization().astype( Optimization ).DebugMode() ) 
    {
      valuesmodel := this.MPVarValuesModel(); 
      valuesmodel.KPIStockingPointCapacity( this.MacroPlan().GetKPIStockingPointCapacity( scope.GetStockingPointInPeriodInOptimizerRunConst() ) ); 
      valuesmodel.KPIMaxInventoryLevel( this.MacroPlan().GetKPIMaximumInventoryLevel(  scope.GetPISPIPInOptimizerRunConst() ) ); 
      unitperiods := scope.GetUnitPeriodInOptimizerRunConst(); 
      valuesmodel.KPIUnitCapacity( this.MacroPlan().GetKPIUnitCapacity( unitperiods ) );  
      valuesmodel.KPILotSizeTripContinuous( this.MacroPlan().GetKPILotSizeTripContinuous( unitperiods ) ); 
    }
    
    this.SynchronizeTools( scope );
    
    // Initialize the scaling types instances (used in the auto-scaling)
    if( this.IsAutoScalingEnabled() )
    {
      this.InitScalingTypes();
    }
    
    SelectorMeta::ComputeFirstLastPISPIPInScope( scope ); // we need to ensure the relation pisp.LatestLeafPISPIPInScope has been set. We don't want to rely on the fact it has been 
                                                                 // computed in the selector already, so we recompute not to break componentized-structure.
    end := OS::PrecisionCounter(); 
    durationinit_nc := (end - start)/ OS::PrecisionCounterFrequency(); 
    debuginfo(  'Duration non const init =', durationinit_nc ); 
    task.Log( 'Duration init non const = ' + [String] durationinit_nc );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}