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
40
41
42
43
44
45
46
47
48
49
50
51
52
Quintiq file version 2.0
#parent: #root
Method SetOptTransitionQuantity (
  LibOpt_Task task
)
{
  Description: 'move over quantities from combi world onto period task in transition'
  TextBody:
  [*
    // opt transition periodtask are linked to from-campaign by campaing sequence optimizer 
    this.Quantity( 0.0 ); 
    
    if ( not isnull( this.TransitionPeriod_MP() ) ) 
    {
      fromcampaign := this.TransitionPeriod_MP().Transition_MP().FromCampaign(); 
      transitionperiod := this.TransitionPeriod_MP(); 
      
      traverse( fromcampaign, 
                OptCampaignPeriodTaskInCombiElement, 
                optpt ) 
      {
        val1 := guard( optpt.OptCampaignCombiElement().OptCampaignElementType().astype( OptCampaignTransitionType ).TransitionType_MP() = this.TransitionType_MP(), false ) ; 
        val2 := optpt.Operation() = this.OperationInTransition().OperationInTransitionType().Operation(); 
        if ( val1 and val2 ) 
        {
          elt := optpt.OptCampaignCombiElement().astype( OptCampaignCombiElementTransition ); 
          ocusp := elt.OptCampaignUnitSubPeriod(); 
          
          use := ocusp.UnitPeriod() = transitionperiod.UnitPeriod(); 
          if ( not use and elt.OptimizerDuration() = Duration::Zero() ) 
          {
            use := elt.IsFirstElementInUnitSubPeriod() and guard( ocusp.PreviousSubPeriod().UnitPeriod() = transitionperiod.UnitPeriod(), false ) // at the combi level the first elt could still continue the previous period combi transition
                   or ( elt.IsLastElementInUnitSubPeriod() and guard( ocusp.NextSubPeriod().UnitPeriod() = transitionperiod.UnitPeriod(), false ) ) // at the combi level the last elt can start the new transition (continued in next period)
          }
        
          if ( use ) 
          {
            this.Quantity( this.Quantity() + optpt.Quantity() ); 
          }
        }
      }
    }
    else
    {
      if ( not isnull( task ) ) 
      {
        task.Log( 'null transition period' + [String] this.PeriodTaskOperation().Start() + this.PeriodTaskOperation().OperationID() +  guard( this.TransitionType_MP().Name(), 'transtype unknown' ) ); 
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Extensible' }
}