chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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
Quintiq file version 2.0
#parent: #root
Method CapacityPlanningAlgorithmHandleFeasibleShiftPattern (
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
  const RunContextForCapacityPlanning runcontext,
  LibOpt_Scope scope
)
{
  Description: 'Update or create unit availabilities depending on the assigned shift pattern.'
  TextBody:
  [*
    if( runcontext.UseShiftOptimization() )
    {
      // Iterate on every unit and then on every unitperiod in scope.
      traverse( scope.GetUnitInOptimizerRun(), Elements, parentunit, parentunit.GetUseShiftOptimization() )
      {
        traverse( parentunit.GetUnitForShiftOptimization(), Elements, unit )
        {
          traverse( unit, UnitPeriod.astype(UnitPeriodTime), up, up.IsInScopeForShiftOptimization( scope ) ) 
          { 
            traverse( unit, UnitShiftPatternAllowed.ShiftPattern, sp )
            {
              // Look for the shift pattern choosen by the optimizer for this unit period.
              shiftpatternisused := this.GetOptimalValue( program.ShiftPatternIsUsedVariables().Get( sp, up ) ) > 0.5;
              
              if( shiftpatternisused ) 
              {
                //We set a temporary shift pattern during meta optimizer processing for efficiency (meta iterations). Component OptimizerPrePostProcessing transfers the value 
                //over to regular planning using unit availability
                up.SetTemporaryOptimizerShiftPattern( sp.Name() ); 
              }
            }
          }
        }
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}