陈清红
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
Quintiq file version 2.0
#parent: #root
Method InitConstraintsForOperationDependentDemandInputSet_Add (
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
  const RunContextForCapacityPlanning runcontext,
  const LibOpt_Scope scope,
  const OperationInputSet set,
  const Period_MP period,
  const PeriodTaskOperation pto,
  Real scalefactor_periodtaskqty_maxconst,
  Real scalefactor_operationinputsetover_maxconst,
  Real scalefactor_periodtaskqty_minconst,
  Real scalefactor_operationinputsetunder_minconst,
  Real scalefactor_partialoperationdemandqty_maxconst,
  Real scalefactor_partialoperationdemandqty_minconst,
  Real scalefactor_operationdemandqty_maxconst,
  Real scalefactor_operationdemandqty_minconst,
  Real scalefactor_rhs_maxconst,
  Real scalefactor_rhs_minconst,
  Real maxfactor,
  Real minfactor
) const
{
  Description: 'Initialize constraints for dependent demands which is part of an input group and belongs to an input set.'
  TextBody:
  [*
    operation := set.Operation();
    
    // maxconst Constraint UoM: Input Set
    maxconst := program.OperationInputSetUpperBoundConstraints().New( set, period );
    maxconst.Sense( "<=" );
    maxconst.RHSValue( 0.0 * scalefactor_rhs_maxconst );
    // Term: - maxfactor       * PTQty variable
    // UoM: [Input Set/ Unit]  *    [Unit]
    maxconst.NewTerm( -maxfactor * scalefactor_periodtaskqty_maxconst, program.PTQtyVariables().Get( operation, period ) );
    // Term UoM: Input Set
    maxconst.NewTerm( -1.0 * scalefactor_operationinputsetover_maxconst,
                      program.OperationInputSetOverVariables().Get( set, period ) );
    
    //minconst Constraint UoM: Input Set
    minconst := program.OperationInputSetLowerBoundConstraints().New( set, period );
    minconst.Sense( ">=" );
    minconst.RHSValue( 0.0 * scalefactor_rhs_minconst );
    // Term: - minfactor       * PTQty variable
    // UoM: [Input Set/ Unit]  *    [Unit]
    minconst.NewTerm( -minfactor * scalefactor_periodtaskqty_minconst, program.PTQtyVariables().Get( operation, period ) );
    // Term UoM: Input Set
    minconst.NewTerm( scalefactor_operationinputsetunder_minconst, program.OperationInputSetUnderVariables().Get( set, period ) );
    
    // Only select the input where the product is included.
    traverse( set, OperationInput, oi, oi.HasRegularProductforOptimizer() or oi.GetIsProductInOptimizerRun( runcontext.IsPostProcessing() ) )
    {
      uomconversion := oi.OperationInputSetConversionFactor();
    
      if( operation.HasLeadTime() )
      {
        
        pispipperiods := construct( Period_MPs, constcontent );
        if ( this.GetPeriodsFromPeriodTaskOperation() ) 
        {
          traverse( pto, DependentDemand.ProductInStockingPointInPeriodPlanningLeaf.Period_MP, ddperiod ) 
          {
            pispipperiods.Add( ddperiod ); 
          }
          pispipperiods := pispipperiods.Unique(); 
        }
        else
        {
          CapacityPlanningSuboptimizer::GetOperationDependentDemandPeriods( period, operation, &pispipperiods, this.GetPeriodsFromPeriodTaskOperation() );
        }
    
        traverse( pispipperiods, Elements, pispipperiod )
        {
          // Term:   uomconversion        * PartialOperationDemandQty variable
          // UoM: [Input PISP to Input Set] *        [Input PISP]
          varpodqty := program.PartialOperationDemandQtyVariables().Get( oi, pispipperiod, period ); 
          maxconst.NewTerm( uomconversion * scalefactor_partialoperationdemandqty_maxconst, varpodqty );
          minconst.NewTerm( uomconversion * scalefactor_partialoperationdemandqty_minconst, varpodqty );
        }
      }
      else
      {
        // Term:   uomconversion        * OperationDemandQty variable
        // UoM: [Input PISP to Input Set] *        [Input PISP]
        maxconst.NewTerm( uomconversion * scalefactor_operationdemandqty_maxconst, program.OperationDemandQtyVariables().Get( oi, period ) );
        minconst.NewTerm( uomconversion * scalefactor_operationdemandqty_minconst, program.OperationDemandQtyVariables().Get( oi, period ) );
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}