chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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
Quintiq file version 2.0
#parent: #root
Method FixDecisionVariables_Debug (
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
  RunContextForCapacityPlanning runcontext,
  LibOpt_Scope scope
)
{
  TextBody:
  [*
    subopt := this; 
    nrfixed := 0; 
    traverse( scope.GetOperationInOptimizerRunConst(), Elements, operation ) 
    {
      periods := subopt.GetPeriodsForOperation( scope, operation );
      traverse( periods, Elements, period ) 
      {
        var := program.PTQtyVariables().Get( operation, period );
        pt := select( operation, PeriodTaskOperation, po, true, po.UnitPeriod().Period_MP() = period ); 
        valuetofix := guard( pt.Quantity(), 0.0 ); 
        subopt.FixVariableStyleGuide( var, valuetofix );
        nrfixed++; 
      }
    }
    
    /* >>
    userperiodtasks := selectset(  runcontext, UserPeriodTask, pto, true, true ); 
    this.FixUserPeriodTask( userperiodtasks, program ); // don't alter the user period task operations
    */
    
    // fixing trips 
    nrfixed := 0; 
    traverse( scope.GetProductInTripInOptimizerRun(), Elements, productintrip )
    {
      var := program.TripNewSupplyVariables().Get( productintrip ); 
      subopt.FixVariableStyleGuide( var, productintrip.Quantity() );
      nrfixed++; 
    }
    
    /*
      // Freeze variables for SalesDemands
    nrfixed := 0; 
    nrunfixed := 0;   
    traverse( scope.GetLeafSalesDemandInPeriodInRun(), Elements, lsdip, scope.Contains( lsdip.ProductInStockingPoint_MP().PISPInOptimizerRun() ) )
    {
        var := program.SalesDemandQtyVariables().Get( lsdip );      // Fulfilled quantity
        if ( mustfixduetocurrentlevel ) 
        {
          subopt.FixVariableStyleGuide( var, lsdip.FulfilledQuantity() );
          nrfixed++; 
        }
        else
        {
          var.LowerBound( lsdip.SalesDemandQtyVarInitLowerBound() ); 
          var.UpperBound( lsdip.SalesDemandQtyVarInitUpperBound() ); 
          nrunfixed++; 
        }
    } 
    
    traverse( scope.GetAggregatedSalesDemandInPeriodInRun(), Elements, asdip )
    {
      traverse ( asdip, DisaggregatedSalesDemandInPeriod, dasdip,
                 scope.Contains( dasdip.AsPlanningBaseSalesDemandInPeriod().PISPIPInOptimizerRun() ) )
      {
         var := program.DisaggregatedSalesDemandQtyVariables().Get( dasdip );
         if ( mustfixduetocurrentlevel ) 
         {
            subopt.FixVariableStyleGuide( var, dasdip.FulfilledQuantity() );
            nrfixed++; 
         }  
         else 
         {
            var.LowerBound( dasdip.SalesDemandQtyVarInitLowerBound() ); 
            var.UpperBound( dasdip.SalesDemandQtyVarInitUpperBound() ); 
            nrunfixed++; 
         }
      }
    }
    msg := msg + 'sales demands fixed, unfixed= ' + [String]nrfixed + ','+ [String] nrunfixed;
    debuginfo(  msg );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}