陈清红
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
Quintiq file version 2.0
#parent: #root
MethodOverride Initialize (
  const LibOpt_Task task,
  MathematicalProgram program_basetype
)
{
  TextBody:
  [*
    debuginfo( 'Synchronous start = ', DateTime::ActualTime() ); 
    scope := task.Scope(); 
    runcontext := this.GetRunContextConst();  
    pispipssmartplan := scope.GetSmartPlanPISPIPsInOptimizerRunConst(); 
    
    userperiodtasks := runcontext.GetUserPeriodTaskOperationsConst(); 
    userproductintrips :=runcontext.GetUserProductInTrips(); 
    pispipsinrun := scope.GetPISPIPInOptimizerRunConst(); 
    leafpispipsinrun := selectset(  pispipsinrun, Elements.astype(  ProductInStockingPointInPeriodPlanningLeaf ), pispip, true, true ); 
    pispsinrun := scope.GetProductInStockingPointInOptimizerRunConst(); 
    pitinrun := scope.GetProductInTripInOptimizerRunConst(); 
    
    // use Algorithm_MP to create the math program
    program := program_basetype.astype( CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm ); 
    
    this.CapacityPlanningAlgorithmInitInstance( program, runcontext, scope );  
    
    this.CapacityPlanningAlgorithmInitVariables( program, runcontext, userperiodtasks, userproductintrips, pispipssmartplan, scope, pispipsinrun, leafpispipsinrun, pispsinrun, pitinrun ); 
    
    this.SetStartSolutionForPTLotSizes( program, runcontext, scope ); 
    
    this.SetStartSolutionForCampaignSequencing( program, runcontext, scope ); 
    
    this.CapacityPlanningAlgorithmInitGoals( program, runcontext, scope  );// workaround we should add the goal after cloning because otherwise the goal term constant become = nr of threads. 
    
    this.CapacityPlanningAlgorithmInitConstraints_ParallelTypeA( program, pispipssmartplan, userperiodtasks, task, pispipsinrun, leafpispipsinrun, pispsinrun, pitinrun  ); 
    
    this.CapacityPlanningAlgorithmInitConstraints_ParallelTypeB( program, pispipssmartplan, task, pispipsinrun, leafpispipsinrun, pispsinrun, pitinrun ); 
    
    this.CapacityPlanningAlgorithmInitConstraints_ParallelTypeC( program, pispipssmartplan, task, pispipsinrun, leafpispipsinrun, pispsinrun, pitinrun ); 
    
    // note we run this.FilterCPLEXNoiseInitialization( program, runcontext ) in above parallel threads (filters RHS of constraints)
    // meaning this filtering is excluded from any constraints added below. 
    
    this.InitConstraintsSequentialAtEnd( program, runcontext, scope, leafpispipsinrun );
    
    //Generate names for debugging purposes
    //this method should already generate names only if needed (sav file saved, MPAnalysis on,...) so no need to add an if statement
    program.GenerateNames()
    isdisplay := not runcontext.IsInventoryOptimizationRun(); 
    if( isdisplay )
    {
      progress( 'Invoking CPLEX', DateTime::ActualTime() );
      info( 'Invoking CPLEX', DateTime::ActualTime() );
    }
  *]
}