| 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' } | 
| } |