admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
Quintiq file version 2.0
#parent: #root
Method PreProcessCampaigns
{
  Description: 'If the optimizer horizon starts in the middle of a campaign, we want to separate this campaign in two'
  TextBody:
  [*
    startpuzzle := this.GetPuzzleStart(); 
    unit := this.Unit()
    startcampaign := null( Campaign_MP )
    starttransition := null(  Transition_MP )
    
    startcampaign := select( unit, Campaign_MP, c, c.Start() < startpuzzle and c.End() >= startpuzzle )
    starttransition := select( unit, Transition_MP, t, t.Start() < startpuzzle and t.End() >= startpuzzle )
    //update the campaign to keep only the part before puzzle start
    if( not isnull( startcampaign ) and not startcampaign.End() = startpuzzle )
    {
      newduration := startcampaign.Duration() - ( startcampaign.End() - startpuzzle )
      startcampaign.Update( unit,
                            startcampaign.EarliestStart(),
                            newduration,
                            startcampaign.SequenceNumberForExcel(),
                            startcampaign.MinQuantity(),
                            startcampaign.MaxQuantity(),
                            startcampaign.MinDuration(),
                            startcampaign.MaxDuration(),
                            startcampaign.CampaignTypeName(),
                            startcampaign.CampaignID(),
                            startcampaign.Comment(),
                            startcampaign.HasInputMaxQuantity(),
                            startcampaign.HasInputMaxDuration(),
                            not startcampaign.IsManuallyConfigured()
                           )
      startcampaign.SynchronizePeriodTaskInCampaignQuantities();
      startcampaign.CampaignOptimizerPreProcessDuration( newduration ); // for use in meta optimizer because we need to be able to initialize back to this state, but also need to add to the duration
    }
    this.LastCampaignBeforeOptHorizon( relset, startcampaign )
    this.LastTransitionBeforeOptHorizon( relset, starttransition )
  *]
}