yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
Method SetIsActiveStatusCombis (
  Number windowsize,
  LibOpt_Scope scope
)
{
  TextBody:
  [*
    start := OS::PrecisionCounter(); 
    nractive := 0; 
    earlieststartglobal := Date::MinDate(); 
    lateststartglobal := Date::MaxDate()
    latestcampaignhorizonend := max( this, OptCampaignUnit.Unit, unit, true, unit.CampaignTypeRequirementHorizon() ); 
    
    scope.GetWindowCampaignSequenceOptimizer( earlieststartglobal, lateststartglobal, windowsize, latestcampaignhorizonend, this ); // we prefer the same window for all campaign units, but pick new window if that is not possible
    debuginfo( 'global window =', earlieststartglobal, ' - ', lateststartglobal ); 
    
    traverse( this, OptCampaignUnit, ocunit ) 
    {
      earlieststart := earlieststartglobal; 
      lateststart := lateststartglobal; 
      this.GetWindowCampaignSequenceOptimizer( earlieststart, lateststart, windowsize, ocunit, scope ); 
      debuginfo(  'unit=', ocunit.UnitID(), 'window = ', earlieststart, ' - ', lateststart ); 
      nractive := nractive + ocunit.SetIsActiveStatusCombis( earlieststart, lateststart ); 
    }
    
    // check for those periods that are not covered yet  - throw in simple <=3 element combis or those based on initial existing plan
    traverse( this, OptCampaignUnit, ocunit ) 
    {
      subperiods := selectset( ocunit, OptCampaignUnitSubPeriod, ocusp, true ); 
      subperiodscovered := construct( OptCampaignUnitSubPeriods ); 
      traverse( ocunit, OptCampaignUnitSubPeriod.OptCampaignCombiSelected.OptCampaignCombiElement.OptCampaignUnitSubPeriod, ocuspcovered ) 
      {
        subperiodscovered.Add( ocuspcovered ); 
      }
      uncovered := subperiods.Difference( subperiodscovered );
      traverse( uncovered, Elements.OptCampaignCombi, combi, combi.NumberOfElements() <= 3 or combi.IsBasedOnExistingPlan() ) 
      {
        combi.IsActive( true ); 
      }
    }
    
    end := OS::PrecisionCounter(); 
    timeneededsec := ( end - start ) / OS::PrecisionCounterFrequency(); 
    debuginfo( 'Processing combi active status. Nr active = ', nractive, ' Time used = ', timeneededsec,  ' seconds' );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}