IMsCumulativeTransform.CumulativeMethod

Fore Syntax

CumulativeMethod: MsCumulativeMethodType;

Fore.NET Syntax

CumulativeMethod: Prognoz.Platform.Interop.Ms.MsCumulativeMethodType;

Description

The CumulativeMethod property determines a cumulative method.

Comments

By default, the property is set to MsCumulativeMethodType.Average.

Fore Example

Executing the example requires that the repository contains a modeling container with the MS identifier. The modeling container must include a cumulative model with the MODEL_CUMULATIVE identifier.

Add links to the Dimensions, Cubes, Ms, Metabase system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    ModelCont: IMetabaseObjectDescriptor;
    Model: IMsModel;
    Transform: IMsFormulaTransform;
    TransformVar: IMsFormulaTransformVariable;
    Slice: IMsFormulaTransformSlice;
    Formula: IMsFormula;
    CumTr: IMsCumulativeTransform;
    trInfo: IMsFormulaTermInfo;
    DataSC: IVariableStub;
    Calcul: IMsModelCalculation;
    SelSetFactory: IDimSelectionSetFactory;
    SelSet: IDimSelectionSet;
    Sel: IDimSelection;
    i: Integer;
    ResultVals: Array Of Double;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get modeling container
    ModelCont := mb.ItemById("MS");
    // Get cumulative model
    Model := mb.ItemByIdNamespace("MODEL_CUMULATIVE", ModelCont.Key).Edit As IMsModel;
    // Get model parameters
    Transform := Model.Transform;
    Formula := Transform.FormulaItem(0);
    CumTr := Formula.Method As IMsCumulativeTransform;
    // Replace input variable
    Transform.Inputs.Clear;
    DataSC := (ModelCont.Bind As IMsModelSpace).DefaultObject As IVariableStub;
    TransformVar := Transform.Inputs.Add(DataSC);
    SelSetFactory := New DimSelectionSetFactory.Create;
    SelSet := SelSetFactory.CreateDimSelectionSet;
    For i := 0 To DataSC.DimensionCount - 1 Do
        Sel := SelSet.Add((DataSC.Dimension(i) As IMetabaseObject).Open(NullAs IDimInstance);
        Sel.SelectElement(2False);
    End For;
    Slice := TransformVar.Slices.Add(SelSet);
    trInfo := Transform.CreateTermInfo;
    trInfo.Slice := Slice;
    CumTr.Input := trInfo;
    // Determine cumulative method
    CumTr.CumulativeMethod := MsCumulativeMethodType.Median;
    // Create calculation parameters    
    calcul := Model.CreateCalculation;
    calcul.Period.IdentificationStartDate := Transform.Period.IdentificationStartDate;
    calcul.Period.IdentificationEndDate := Transform.Period.IdentificationEndDate;
    calcul.Period.ForecastStartDate := Transform.Period.ForecastStartDate;
    calcul.Period.ForecastEndDate := Transform.Period.ForecastEndDate;
    // Get and display values of output variable
    ResultVals := CumTr.Result.Serie(Calcul As IMsMethodCalculation);
    For i := 0 To ResultVals.Length - 1 Do
        Debug.WriteLine(ResultVals[i]);
    End For;
    // Save model
    (Model As IMetabaseObject).Save;
End Sub UserProc;

After executing the example the input variable and the cumulative calculation method will be changed for the model. The console window displays values of output variable.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example. Use Fore.NET analogs instead of Fore components.

Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Ms;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    ModelCont: IMetabaseObjectDescriptor;
    Model: IMsModel;
    Transform: IMsFormulaTransform;
    TransformVar: IMsFormulaTransformVariable;
    Slice: IMsFormulaTransformSlice;
    Formula: IMsFormula;
    CumTr: IMsCumulativeTransform;
    trInfo: IMsFormulaTermInfo;
    DataSC: IVariableStub;
    Calcul: IMsModelCalculation;
    SelSetFactory: IDimSelectionSetFactory;
    SelSet: IDimSelectionSet;
    Sel: IDimSelection;
    i: Integer;
    ResultVals: System.Array;
Begin
    // Get current repository
    mb := Params.Metabase;
    // Get modeling container
    ModelCont := mb.ItemById["MS"];
    // Get cumulative model
    Model := mb.ItemByIdNamespace["MODEL_CUMULATIVE", ModelCont.Key].Edit() As IMsModel;
    // Get model parameters
    Transform := Model.Transform;
    Formula := Transform.FormulaItem[0];
    CumTr := Formula.Method As IMsCumulativeTransform;
    // Replace input variable
    Transform.Inputs.Clear();
    DataSC := (ModelCont.Bind() As IMsModelSpace).DefaultObject As IVariableStub;
    TransformVar := Transform.Inputs.Add(DataSC);
    SelSetFactory := New DimSelectionSetFactory.Create();
    SelSet := SelSetFactory.CreateDimSelectionSet();
    For i := 0 To DataSC.DimensionCount - 1 Do
        Sel := SelSet.Add((DataSC.Dimension[i] As IMetabaseObject).Open(NullAs IDimInstance);
        Sel.SelectElement(2False);
    End For;
    Slice := TransformVar.Slices.Add(SelSet);
    trInfo := Transform.CreateTermInfo();
    trInfo.Slice := Slice;
    CumTr.Input := trInfo;
    // Determine cumulative method
    CumTr.CumulativeMethod := MsCumulativeMethodType.mcmtMedian;
    // Create calculation parameters    
    calcul := Model.CreateCalculation();
    calcul.Period.IdentificationStartDate := Transform.Period.IdentificationStartDate;
    calcul.Period.IdentificationEndDate := Transform.Period.IdentificationEndDate;
    calcul.Period.ForecastStartDate := Transform.Period.ForecastStartDate;
    calcul.Period.ForecastEndDate := Transform.Period.ForecastEndDate;
    // Get and display values of output variable
    ResultVals := CumTr.Result.Serie[Calcul As IMsMethodCalculation];
    For i := 0 To ResultVals.Length - 1 Do
        System.Diagnostics.Debug.WriteLine(ResultVals[i]);
    End For;
    // Save model
    (Model As IMetabaseObject).Save();
End Sub;

See also:

IMsCumulativeTransform