IMsProblemCalculation.GetFormulaInfo

Syntax

GetFormulaInfo(StubKey: Integer; SelSet: IDimSelectionSet): IMsFormulaInfoList;

Parameters

StubKey. Key of the data source, for which calculation is executed.

SelSet. Selection that creates the point, in which information about formulas should be obtained.

Description

The GetFormulaInfo method returns information about formulas used for modeling problem calculation at the specified point.

Comments

The information about formulas can be obtained if the following requirements are met:

The SelSet parameter should send a single selection based on dimensions of the data source, which key is sent in StubKey.

Example

Executing the example requires that the repository includes a modeling container with the MODEL_SPACE identifier in which the PROBLEM modeling problem is created. The problem is set up to calculate determinate equation model.

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

Sub UserProc;
Var
    Mb: IMetabase;
    Problem: IMsProblem;
    CalcSet: IMsProblemCalculationSettings;
    Calc: IMsProblemCalculation;
    Variable: IVariableStub;
    SelFactory: DimSelectionSetFactory;
    SelSet: IDimSelectionSet;
    Sel: IDimSelection;
    Res: IMsFormulaInfoList;
    ResI: IMsFormulaInfo;
    InstIterator: IMsFormulaGenInstanceIterator;
    OperandsIterator: IMsFormulaGenTermIterator;
    Point: IMsFormulaGenTermPoint;
    DimInst: IDimInstance;
    k, i, l: Integer;
    s: String;
Begin
    
// Get problem
    Mb := MetabaseClass.Active;
    Problem := Mb.ItemByIdNamespace(
"PROBLEM", Mb.GetObjectKeyById("MODEL_SPACE")).Bind As IMsProblem;
    
// Calculate problem
    CalcSet := Problem.CreateCalculationSettings;
    CalcSet.SupportPartialCalculation := 
True;
    Calc := Problem.Calculate(CalcSet);
    Calc.Run;
    
// Get data source, for which calculation is executed
    Variable := Calc.VariableStubs.Item(0);
    
// Create selection. First dimension elements are selected
    SelFactory := New DimSelectionSetFactory.Create;
    SelSet := SelFactory.CreateDimSelectionSet;
    Sel := SelSet.Add((Variable.Calendar 
As IMetabaseObject).Open(NullAs IDimInstance);
    Sel.SelectElement(
0False);
    k := Variable.DimensionCount;
    
For i := 0 To k - 1 Do
        Sel := SelSet.Add((Variable.Dimension(i) 
As IMetabaseObject).Open(NullAs IDimInstance);
        Sel.SelectElement(
0False);
    
End For;
    
// Get information about formulas in calculation point
    Res := Calc.GetFormulaInfo(Variable.Key, SelSet);
    
If (Res.Count = 0Then
        Debug.WriteLine(
"Point is not calculated");
    
Else
        Debug.WriteLine(
"Total number of models, by which point is calculated: " + Res.Count.ToString);
        
For i := 0 To Res.Count - 1 Do
            ResI := Res.Item(i);
            Debug.WriteLine(
"=========== " + (i + 1).ToString + " ===========");
            Debug.WriteLine(
"Model: " + ResI.Model.Name);
            Debug.WriteLine(
"Metamodel: " + ResI.MetaModel.Name);
            Debug.WriteLine(
"Problem: " + ResI.Problem.Name);
            Debug.WriteLine(
"Formula expression: " + ResI.Expression);
            // Information about calculation point
            InstIterator := ResI.InstancesIterator;
            
If InstIterator.ErrorType = MsFormulaGenerationErrorType.NoError Then
                Point := InstIterator.LeftPart.Point;
                SelSet := (Point.Coord(
0).MatrixModel As IMatrix).Dimensions;
                
For k := 0 To SelSet.Count - 1 Do
                    DimInst := SelSet.Item(k).Dimension;
                    s := s + DimInst.Name + 
" = " + DimInst.Elements.Name(Point.Coord(0).Item(k)) + "; ";
                
End For;
                Debug.WriteLine(
"Calculation point: " + s);
                
// Information about operands used in calculation point
                s := "";
                OperandsIterator := InstIterator.Operands;
                
While Not OperandsIterator.Eof Do
                    Point := OperandsIterator.Term.Point;
                    SelSet := (Point.Coord(
0).MatrixModel As IMatrix).Dimensions;
                    
For k := 0 To SelSet.Count - 1 Do
                        DimInst := SelSet.Item(k).Dimension;
                        s := s + DimInst.Name + 
" = " + DimInst.Elements.Name(Point.Coord(0).Item(k)) + "; ";
                    
End For;
                    Debug.WriteLine(
"Operand: " + s);
                    Debug.WriteLine(
"Aggr: " + OperandsIterator.Term.Aggregation.ToString);
                    Debug.WriteLine(
"---Number of operand values: " + Point.ValuesCount.ToString);
                    
For l := 0 To Point.ValuesCount - 1 Do
                        Debug.WriteLine(
"---Value # " + l.ToString + " = " + Point.Value(l));
                    
End For;
                    s := 
"";
                    OperandsIterator.Next;
                
End While;
            
Else
                Debug.WriteLine(
"Error: " + InstIterator.ErrorText);
            
End If;
        
End For;
    
End If;
End Sub UserProc;

The modeling problem is calculated on executing the example. Formulas will be checked for correctness, and if there are no errors, the development environment console will display information about the formulas used in calculation in the first calculation point of the model.

See also:

IMsProblemCalculation