| 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
 | | Quintiq file version 2.0 |  | #parent: #root |  | Method GetWindowCampaignSequenceOptimizer ( |  |   output Date earlieststart, |  |   output Date lateststart, |  |   Number windowsizenrperiods, |  |   DateTime latestcampaignhorizonend, |  |   OptCampaign optcampaign |  | ) |  | { |  |   TextBody: |  |   [* |  |     periods := selectsortedset(  this.GetPeriodInOptimizerRun(),  |  |                                  Elements,  |  |                                  period,  |  |                                  period.Start() <= latestcampaignhorizonend |  |                                  and not period.IsHistorical(),  |  |                                  period.StartDate() ) ;  |  |      |  |      |  |     start := maxvalue(  Number::Random( -windowsizenrperiods, periods.Size() - 1 ), 0 ); // give equal probability to first period by picking negative numbers also  |  |     end := minvalue(  start + windowsizenrperiods, periods.Size() - 1 );  |  |     earlieststart := guard(  periods.Element( start ).StartDate(), Date::MaxDate() );  |  |     lateststart := guard( periods.Element( end ).StartDate(), Date::MinDate() ); |  |   *] |  |   InterfaceProperties { Accessibility: 'Module' } |  | } | 
 |