haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Quintiq file version 2.0
#parent: #root
Method SetFeedBackQuantities (
  MacroPlan mp,
  RunContextForCapacityPlanning runcontext,
  LibOpt_Scope scope
)
{
  TextBody:
  [*
    if ( runcontext.IsMetaIteration() ) 
    {
      ptcount := 0; 
      periods := scope.GetPeriodInOptimizerRun(); 
      traverse( mp, Unit.Operation, operation, operation.FeedbackPeriodTaskOperation( relsize ) > 0 or operation.HasMinimumQuantity() ) 
      {
        traverse( periods, Elements, period, PeriodTaskOperation::GetIsValidPeriodTask( operation, period ) ) // we don't want to plan feedback in frozen unit periods for example 
        {
          operationmin := 0.0; 
          if( runcontext.UseProcessMinimumQuantity()
              and operation.HasMinimumQuantity()
              and period.IsWithinLotSizeHorizon() ) 
          {
            operationmin := operation.MinimumQuantity(); 
          }
          
          feedbackqty := sum( operation, 
                              FeedbackPeriodTaskOperation, 
                              feedback,
                              feedback.GetIsValidFeedback() 
                              and feedback.UnitPeriod().Period_MP() = period,
                              feedback.FeedbackQuantity() );
                              
          pt := select(  operation, PeriodTaskOperation, ptask, true, ptask.UnitPeriod().Period_MP() = period ); 
          largestlowerbound := maxvalue(  feedbackqty, operationmin );
           
          if ( largestlowerbound > 0 ) 
          {
            if ( isnull( pt ) ) 
            {
              up := select(  operation, Unit.UnitPeriod, uperiod, uperiod.Period_MP() = period ); 
              pt := PeriodTaskOperation::CreateValidPeriodTask( operation,
                                                                up,
                                                                0.0,
                                                                false );
            }
            if ( guard( pt.Quantity() < largestlowerbound, false ) 
                 and ( not feedbackqty = 0 and pt.Quantity() = 0 )  ) // in this case 0 UNION [operationmin, infty ) is the bound on the variable ( semi continues) 
            {
              pt.SetOptimizerQuantity( largestlowerbound );   
              debuginfo(  'Pre processing Period = ', period.Start(), 'operation=', operation.Name(), 'feedback = ', feedbackqty, 'lowerbound set = ', largestlowerbound  ); 
    
              ptcount++; 
            }
          }
        }
      }
    
      Transaction::Transaction().Propagate ( attribute( PeriodTaskOperation, QuantityToProcess ) ); 
      Transaction::Transaction().Propagate ( attribute( PeriodTaskOperation, Quantity ) ); 
    
      this.PlanFeedbackPIT( scope, runcontext ); 
      
      Transaction::Transaction().Propagate( attribute( ProductInTrip, Quantity ) ); 
      
      debuginfo(  'Planned feedback for #periotaskoperation = ', ptcount ); 
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}