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
Quintiq file version 2.0
#parent: #root
StaticMethod Create (
  ScenarioManager scenariomanager,
  Strategy strategy,
  String name,
  Number displayindex,
  String description,
  Real massscalingfactor,
  Real monetaryscalingfactor,
  Real timescalingfactor,
  Real timeaccountscalingfactor,
  Real inventoryholdingscalingfactor,
  DateTime lastautoscalingrun,
  Boolean isvisible
) as Strategy
{
  Description: 'Create strategy'
  TextBody:
  [*
    // Create new strategy
    newstrategy := scenariomanager.Strategy( relnew,
                                             Name := name,
                                             DisplayIndexForKT := displayindex,
                                             Description := description,
                                             MassScalingFactor := massscalingfactor,
                                             MonetaryScalingFactor := monetaryscalingfactor,
                                             TimeScalingFactor := timescalingfactor,
                                             TimeAccountScalingFactor := timeaccountscalingfactor,
                                             InventoryHoldingScalingFactor := inventoryholdingscalingfactor,
                                             LastAutoScalingRun := lastautoscalingrun,
                                             IsVisible := isvisible );
    
    // Update new strategy
    newstrategy.Update( name );
    
    // Check if strategy is null
    if( not isnull( strategy ) )
    {
      // Traverse all KPIWeigth of the passed in strategy
      traverse( strategy, KPIWeight, kpiweight, kpiweight.KPI( relsize ) >0 )
      {
        // Create/Update KPIWeight of the new strategy
        KPIWeight::Create( newstrategy, kpiweight.KPI(), kpiweight.Weight(), kpiweight.Level() );
      }
    }
    else
    {
      // Create/Update KPIWeight of the new strategy
      traverse( scenariomanager, KPI, kpi )
      {
        KPIWeight::Create( newstrategy, kpi, 0.0, 0 );
      }
    }
    
    // To be used in the scenario comparison
    if( scenariomanager.Strategy( relsize ) = 1 )
    {
      scenariomanager.ActiveStrategy( relset, newstrategy );
    }
    
    return newstrategy;
  *]
}