GetGroupVariablesData(
EntryKeys: Array;
ScenarioKeys: Array;
pCalculation: IMsMethodCalculation;
Filter: Boolean;
SuppressEmptyArea: LnSuppressEmptyArea;
Var ResDates: Array;
Var ResLevels: Array;
Var ResValues: Array);
EntryKeys. Array of keys of variables.
ScenarioKeys. Array of scenario keys.
pCalculation. Model calculation options.
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.
The GetGroupVariablesData method returns data of several variables.
This method allows to get variable data event if it has different calendar frequency.
Available values of the Filter parameter:
True. Variable data must be filtered. Filtering method must be specified in the SuppressEmptyArea parameter.
False. Variable data must not be filtered.
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[0, 0, 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.
See also: