陈清红
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
Quintiq file version 2.0
#parent: #root
MethodOverride AddTermsForCapacityUsage (
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
  MPConstraint minconst,
  MPConstraint maxconst,
  const LibOpt_Scope scope,
  const CapacityPlanningSuboptimizer subopt,
  const UnitPeriod unitperiodforconstraint,
  Real scalefactor_periodtaskqty_minconst,
  Real scalefactor_periodtaskqty_maxconst,
  Real scalefactor_tripnewsupply_minconst,
  Real scalefactor_tripnewsupply_maxconst,
  output Real bound
) const
{
  TextBody:
  [*
    traverse( this, PeriodTask_MP.astype( PeriodTaskLaneLeg ), ptll,
              scope.Contains( ptll.Trip().TripInOptimizerRun() ) )     // Only if the trip is part of this optimizer run
    {
      traverse( ptll, Trip.ProductInTrip, productintrip,
                scope.Contains( productintrip.ProductInTripInOptimizerRun() ) ) // Only if the productintrip is part of this optimizer run
      {
        uomconversion := productintrip.UnitConversionFactor();
        factor := ptll.Process_MP().GetCapacityUsagePerQuantity( unitperiodforconstraint );
      
        var := program.TripNewSupplyVariables().Get( productintrip );
    
        // Term:    uomconversion   *      factor          * TripNewSupply variable
        // UoM: [Output PISP to Unit] * [Time / Unit] *      [Output PISP]    
        maxconst.NewTerm( uomconversion * factor * scalefactor_tripnewsupply_maxconst, var );
        minconst.NewTerm( uomconversion * factor * scalefactor_tripnewsupply_minconst, var );
    
        bound := bound + factor * var.LowerBound();
      }
    }
    
    traverse( this, ChildOfUnitDimension, childunitperiod )
    {
      childunitperiod.AddTermsForCapacityUsage( program,
                                                minconst,
                                                maxconst,
                                                scope,
                                                subopt,
                                                unitperiodforconstraint,
                                                scalefactor_periodtaskqty_minconst,
                                                scalefactor_periodtaskqty_maxconst,
                                                scalefactor_tripnewsupply_minconst,
                                                scalefactor_tripnewsupply_maxconst,
                                                bound );
    }
  *]
}