IMsMetaModelVisualController.GetGroupVariablesData

Fore Syntax

GetGroupVariablesData(
                      EntryKeys: Array;
                      ScenarioKeys: Array;
                      pCalculation: IMsMethodCalculation;
                      Filter: Boolean;
                      SuppressEmptyArea: LnSuppressEmptyArea;
                      Var ResDates: Array;
                      Var ResLevels: Array;
                      Var ResValues: Array);

Fore.NET Syntax

GetGroupVariablesData(
                      EntryKeys: System.Array;
                      ScenarioKeys: System.Array;
                      pCalculation: Prognoz.Platform.Interop.Ms.IMsMethodCalculation;
                      Filter: boolean;
                      SuppressEmptyArea: Prognoz.Platform.Interop.Laner.LnSuppressEmptyArea;
                      var ResDates: System.Array;
                      var ResLevels: System.Array;
                      var ResValues: System.Array);

Parameters

EntryKeys. Array of keys of variables.

ScenarioKeys. Array of scenario keys.

pCalculation. Model calculation parameters.

Filter. Indicates whether variable data must be filtered.

SuppressEmptyArea. Variable data filtering method.

ResDates. Array of dates for variable values.

ResLevels. Array of calendar frequencies used by variables.

ResValues. Array of variable values.

Description

The GetGroupVariablesData method returns data of several variables.

Comments

This method allows to get variable data event if it has different calendar frequency.

Available values of the Filter parameter:

Fore Example

Executing the example requires that the repository contains a modeling container with the MS identifier, containing a modeling problem with the MODEL_VAR_LVL identifier. This problem must contain an internal metamodel, the calculation chain of which contains at least one model.

Add links to the Laner, Metabase, Ms system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Problem: IMsProblem;
    Meta: IMsMetaModel;
    MetaVisual: IMsMetaModelVisualController;
    ChainEnts: IMsCalculationChainEntries;
    ChainEl: IMsCalculationChainEntry;
    i, j: Integer;
    Model: IMsModel;
    Transform: IMsFormulaTransform;
    OutVars, InpVars: IMsFormulaTransformVariables;
    VarsKey: Array Of Integer;
    Calc: IMsMethodCalculation;
    ScenKeys: Array Of Integer;
    ResDates: Array Of String;
    ResLevels: Array Of Integer;
    ResValues: Array Of Double;
    Val: Double;
Begin
    mb := MetabaseClass.Active;
    // Get modeling container
    MsObj := mb.ItemById("MS");
    // Get modeling problem
    Problem := mb.ItemByIdNamespace("MODEL_VAR_LVL", MsObj.Key).Bind As IMsProblem;
    // Get metamodel
    Meta := Problem.MetaModel;
    MetaVisual := Meta.VisualController;
    // Get the first model in the calculation chain
    ChainEnts := Meta.CalculationChain;
    For i := 0 To ChainEnts.Count - 1 Do
        ChainEl := ChainEnts.Item(i);
        If ChainEl.Type = MsCalculationChainEntryType.Model Then
            Model := (ChainEl As IMsCalculationChainModel).Model;
            Break;
        End If;
    End For;
    // Get model parameters
    Transform := Model.Transform;
    // Get number of variables included into model
    OutVars := Transform.Outputs;
    InpVars := Transform.Inputs;
    i := OutVars.Count + InpVars.Count;
    // Get array of variable keys included into model
    VarsKey := New Integer[i];
    For i := 0 To OutVars.Count - 1 Do
        VarsKey[i] := OutVars.Item(i).Key;
    End For;
    For j := 0 To InpVars.Count - 1 Do
        VarsKey[j + i] := InpVars.Item(j).Key;
    End For;
    // Create model calculation parameters
    Calc := Transform.CreateCalculation;
    Calc.Period.IdentificationStartDate := model.Transform.Period.IdentificationStartDate;
    Calc.Period.IdentificationEndDate := model.Transform.Period.IdentificationEndDate;
    Calc.Period.ForecastStartDate := model.Transform.Period.ForecastStartDate;
    Calc.Period.ForecastEndDate := model.Transform.Period.ForecastEndDate;
    // Create an array of scenario keys and specify the Fact scenario there
    ScenKeys := New Integer[1];
    ScenKeys[0] := -1;
    // Get input variable values 
    MetaVisual.GetGroupVariablesData(VarsKey, ScenKeys, Calc, True,
        LnSuppressEmptyArea.SerieBounds, ResDates, ResLevels, ResValues);
    // Output values to console window  
    Debug.WriteLine("Number of various calendar frequencies: " + ResLevels.Length.ToString);
    Debug.WriteLine("Variable values:");
    For i := 0 To ResDates.Length - 1 Do
        Debug.Write(ResDates[i]);
        Debug.Write(" - ");
        Val := ResValues[00, i];
        For j := 0 To VarsKey.Length - 1 Do
            Val := ResValues[0, j, i];
            If Not Double.IsNan(val) Then
                If j > 0 Then
                    Debug.Write("          ");
                End If;
                Debug.Write(Val);
            End If;
        End For;
        Debug.WriteLine("");
    End For;
End Sub UserProc;

After executing the example the console window displays data of the variables included into the first model in the metamodel calculation chain.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Laner;
Imports Prognoz.Platform.Interop.Ms;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Problem: IMsProblem;
    Meta: IMsMetaModel;
    MetaVisual: IMsMetaModelVisualController;
    ChainEnts: IMsCalculationChainEntries;
    ChainEl: IMsCalculationChainEntry;
    i, j: Integer;
    Model: IMsModel;
    Transform: IMsFormulaTransform;
    OutVars, InpVars: IMsFormulaTransformVariables;
    VarsKey: System.Array;
    Calc: IMsMethodCalculation;
    ScenKeys: System.Array;
    ResDates: System.Array;
    ResLevels: System.Array;
    ResValues: System.Array;
    Val: Double;
Begin
    mb := Params.Metabase;
    // Get modeling container
    MsObj := mb.ItemById["MS"];
    // Get modeling problem
    Problem := mb.ItemByIdNamespace["MODEL_VAR_LVL", MsObj.Key].Bind() As IMsProblem;
    // Get metamodel
    Meta := Problem.MetaModel;
    MetaVisual := Meta.VisualController;
    // Get the first model in the calculation chain
    ChainEnts := Meta.CalculationChain;
    For i := 0 To ChainEnts.Count - 1 Do
        ChainEl := ChainEnts.Item[i];
        If ChainEl.Type = MsCalculationChainEntryType.mccetModel Then
            Model := (ChainEl As IMsCalculationChainModel).Model;
            Break;
        End If;
    End For;
    // Get model parameters
    Transform := Model.Transform;
    // Get number of variables included into model
    OutVars := Transform.Outputs;
    InpVars := Transform.Inputs;
    i := OutVars.Count + InpVars.Count;
    // Get array of variable keys included into model
    VarsKey := New Integer[i];
    For i := 0 To OutVars.Count - 1 Do
        VarsKey[i] := OutVars.Item[i].Key As integer;
    End For;
    For j := 0 To InpVars.Count - 1 Do
        VarsKey[j + i] := InpVars.Item[j].Key As integer;
    End For;
    // Create model calculation parameters
    Calc := Transform.CreateCalculation();
    Calc.Period.IdentificationStartDate := model.Transform.Period.IdentificationStartDate;
    Calc.Period.IdentificationEndDate := model.Transform.Period.IdentificationEndDate;
    Calc.Period.ForecastStartDate := model.Transform.Period.ForecastStartDate;
    Calc.Period.ForecastEndDate := model.Transform.Period.ForecastEndDate;
    // Create an array of scenario keys and specify the Fact scenario there
    ScenKeys := New Integer[1];
    ScenKeys[0] := -1;
    // Get input variable values 
    MetaVisual.GetGroupVariablesData(VarsKey, ScenKeys, Calc, True,
        LnSuppressEmptyArea.lseaSerieBounds, Var ResDates, Var ResLevels, Var ResValues);
    // Output values to console window  
    System.Diagnostics.Debug.WriteLine("Number of various calendar frequencies: " + ResLevels.Length.ToString());
    System.Diagnostics.Debug.WriteLine("Variable values:");
    For i := 0 To ResDates.Length - 1 Do
        System.Diagnostics.Debug.Write(ResDates[i]);
        System.Diagnostics.Debug.Write(" - ");
        Val := ResValues[i, 00As double;
        For j := 0 To VarsKey.Length - 1 Do
            Val := ResValues[i, j, 0As double;
            If Not Double.IsNan(val) Then
                If j > 0 Then
                    System.Diagnostics.Debug.Write("          ");
                End If;
                System.Diagnostics.Debug.Write(Val);
            End If;
        End For;
        System.Diagnostics.Debug.WriteLine("");
    End For;
End Sub;

See also:

IMsMetaModelVisualController