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
Quintiq file version 2.0
#parent: #root
Method FixUserPeriodTask (
  const constcontent PeriodTaskOperations userperiodtasks,
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program
) const
{
  TextBody:
  [*
    // Freeze the user planning period tasks
    traverse( userperiodtasks, Elements, pt, pt.HasUserQuantity() )   // User quantity must be adhered by the optimizer. Optimizer cannot change the quantity planned on the period task.
    {
      var := program.PTQtyVariables().Find( pt.Operation(), pt.UnitPeriod().Period_MP() ); // find because in meta it may be out of scope for an iteration
      if ( not isnull( var ) ) 
      {
        var.VariableType( 'Continuous' );   // A semi-continuous variable type will still ignore the lowerbound of the variable, thus potentially setting PTQty to 0.
        this.FixVariableStyleGuide( var, pt.Quantity() );
      }
    }
    
    traverse( userperiodtasks, Elements, pt, pt.HasDependentDemandUserQuantity() ) 
    {
      period := pt.UnitPeriod().Period_MP(); 
      traverse( pt, DependentDemand, dd, dd.HasUserQuantity() )
      {
        pispipperiod := dd.ProductInStockingPointInPeriodPlanningLeaf().Period_MP(); 
        input := dd.ProcessInput().astype( OperationInput ); 
        if ( pt.Operation().HasLeadTime() ) 
        {
          var := program.PartialOperationDemandQtyVariables().Get( input, pispipperiod, period );     
          this.FixVariableStyleGuide( var, dd.UserQuantity() ); 
        }
        else
        {
          var := program.OperationDemandQtyVariables().Get( input, period );     
          this.FixVariableStyleGuide( var, dd.UserQuantity() ); 
        }
      } 
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}