陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Quintiq file version 2.0
#parent: #root
Method InitConstraintsForOperationDependentDemandInputGroup (
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
  const RunContextForCapacityPlanning runcontext,
  const LibOpt_Scope scope
) const
{
  Description: 'Initialize constraints for dependent demands which is part of an input group'
  TextBody:
  [*
    constddqtyname := typeof( MPOperationInputGroupDependentDemandQtyConstraint ); 
    constuppername := typeof( MPOperationInputGroupUpperBoundConstraint );
    constlowername := typeof( MPOperationInputGroupLowerBoundConstraint );
    constrelativename := typeof( MPRelativeDurationConstraint );
    
    scalefactor_periodtask_constddqty := this.ScaleConstraintTerm( typeof( MPPTQtyVariable ), constddqtyname );
    scalefactor_periodtask_constupper := this.ScaleConstraintTerm( typeof( MPPTQtyVariable ), constuppername );
    scalefactor_operationinputgroupover_constupper := this.ScaleConstraintTerm( typeof( MPOperationInputGroupOverVariable ), constuppername );
    scalefactor_periodtask_constlower := this.ScaleConstraintTerm( typeof( MPPTQtyVariable ), constlowername );
    scalefactor_operationinputgroupunder_constlower := this.ScaleConstraintTerm( typeof( MPOperationInputGroupUnderVariable ), constlowername );
    scalefactor_partialoperationdemandqty_constddqty := this.ScaleConstraintTerm( typeof( MPPartialOperationDemandQtyVariable ), constddqtyname );
    scalefactor_partialoperationdemandqty_constupper := this.ScaleConstraintTerm( typeof( MPPartialOperationDemandQtyVariable ), constuppername );
    scalefactor_partialoperationdemandqty_constlower := this.ScaleConstraintTerm( typeof( MPPartialOperationDemandQtyVariable ), constlowername );
    scalefactor_partialoperationdemandqty_constrelative := this.ScaleConstraintTerm( typeof( MPPartialOperationDemandQtyVariable ), constrelativename );
    scalefactor_operationdemandqty_constddqty := this.ScaleConstraintTerm( typeof( MPOperationDemandQtyVariable ), constddqtyname );
    scalefactor_operationdemandqty_constupper := this.ScaleConstraintTerm( typeof( MPOperationDemandQtyVariable ), constuppername );
    scalefactor_operationdemandqty_constlower := this.ScaleConstraintTerm( typeof( MPOperationDemandQtyVariable ), constlowername );
    
    usingproportionalleadtimelogic := this.MacroPlan().GlobalParameters_MP().OperationLeadTimeLogic() = Translations::MP_GlobalParameter_LeadTimeLogic_Proportional()
    
    if ( this.GetPeriodsFromPeriodTaskOperation() ) 
    {
      traverse( scope.GetOperationInputGroupInOptimizerRunConst(), Elements, group, 
                  not exists( group, OperationInput, input,
                              not input.GetIsProductInOptimizerRun( runcontext.IsPostProcessing() ) ) ) //Filter group if one or more input products are excluded
        {
          operation := group.Operation(); 
          traverse( operation, PeriodTaskOperationInScope, pto ) 
          {
            period := pto.UnitPeriod().Period_MP(); 
            this.InitConstraintsForOperationDependentDemandInputGroup_Add( program, 
                                                                   runcontext, 
                                                                   scope, 
                                                                   group, 
                                                                   period, 
                                                                   pto, 
                                                                   scalefactor_periodtask_constddqty,
                                                                   scalefactor_periodtask_constupper,
                                                                   scalefactor_operationinputgroupover_constupper,
                                                                   scalefactor_periodtask_constlower,
                                                                   scalefactor_operationinputgroupunder_constlower,
                                                                   scalefactor_partialoperationdemandqty_constddqty,
                                                                   scalefactor_partialoperationdemandqty_constupper,
                                                                   scalefactor_partialoperationdemandqty_constlower,
                                                                   scalefactor_partialoperationdemandqty_constrelative,
                                                                   scalefactor_operationdemandqty_constddqty,
                                                                   scalefactor_operationdemandqty_constupper,
                                                                   scalefactor_operationdemandqty_constlower,
                                                                   usingproportionalleadtimelogic ); 
          } 
        }
    }
    else
    {
      traverse( scope.GetOperationInputGroupInOptimizerRunConst(), Elements, group, 
                not exists( group, OperationInput, input,
                            not input.GetIsProductInOptimizerRun( runcontext.IsPostProcessing() ) ) ) //Filter group if one or more input products are excluded
      {
        operation := group.Operation();
        periods := this.GetPeriodsForOperation( scope, operation );
      
        traverse( periods, Elements, period )
        {
          this.InitConstraintsForOperationDependentDemandInputGroup_Add( program, 
                                                                         runcontext, 
                                                                         scope, 
                                                                         group, 
                                                                         period, 
                                                                         null(  PeriodTaskOperation ), 
                                                                         scalefactor_periodtask_constddqty,
                                                                         scalefactor_periodtask_constupper,
                                                                         scalefactor_operationinputgroupover_constupper,
                                                                         scalefactor_periodtask_constlower,
                                                                         scalefactor_operationinputgroupunder_constlower,
                                                                         scalefactor_partialoperationdemandqty_constddqty,
                                                                         scalefactor_partialoperationdemandqty_constupper,
                                                                         scalefactor_partialoperationdemandqty_constlower,
                                                                         scalefactor_partialoperationdemandqty_constrelative,
                                                                         scalefactor_operationdemandqty_constddqty,
                                                                         scalefactor_operationdemandqty_constupper,
                                                                         scalefactor_operationdemandqty_constlower,
                                                                         usingproportionalleadtimelogic ); 
                                                                         
        } //end traverse period 
      } // end traverse group
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}