IMsProblemCalculation.GetFormulaInfo

Syntax

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

GetFormulaInfo(StubKey: UInteger; SelSet: IPrognoz.Platform.Interop.Dimensions.IDimSelectionSet): Prognoz.Platform.Interop.Ms.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 the formulas applied for calculation in 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 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;
            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(
"--- Number of operand values: " + Point.ValuesCount.ToString);
                
For l := 0 To Point.ValuesCount - 1 Do
                    Debug.WriteLine(
"--- Value No. " + l.ToString + " = " + Point.Value(l));
                
End For;
                s := "";
                OperandsIterator.Next;
            
End While;
        
End For;
    
End If;
End Sub UserProc;

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

Public Shared Sub Main(Params: StartParams);
Var
    Mb: IMetabase;
    Problem: IMsProblem;
    CalcSet: IMsProblemCalculationSettings;
    Calc: IMsProblemCalculation;
    Variable: IVariableStub;
    SelFactory: DimSelectionSetFactory = 
New DimSelectionSetFactoryClass();
    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 := Params.Metabase;
    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
    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
        System.Diagnostics.Debug.WriteLine(
"Point is not calculated");
    
Else
        System.Diagnostics.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];
            System.Diagnostics.Debug.WriteLine(
"=========== " + (i + 1).ToString() + " ===========");
            System.Diagnostics.Debug.WriteLine(
"Model: " + ResI.Model.Name);
            System.Diagnostics.Debug.WriteLine(
"Metamodel: " + ResI.MetaModel.Name);
            System.Diagnostics.Debug.WriteLine(
"Problem: " + ResI.Problem.Name);
            System.Diagnostics.Debug.WriteLine(
"Formula expression: " + ResI.Expression);
            
// Information about calculation point
            InstIterator := ResI.InstancesIterator;
            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] As uinteger)] + "; ";
            
End For;
            System.Diagnostics.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]) As uinteger] + "; ";
                
End For;
                System.Diagnostics.Debug.WriteLine(
"Operand: " + s);
                System.Diagnostics.Debug.WriteLine(
"--- Number of operand values: " + Point.ValuesCount.ToString());
                
For l := 0 To Point.ValuesCount - 1 Do
                    System.Diagnostics.Debug.WriteLine(
"--- Value No. " + l.ToString() + " = " + Point.Value[l]);
                
End For;
                s := "";
                OperandsIterator.Next();
            
End While;
        
End For;
    
End If;
End Sub;

The modeling problem is calculated on executing the example. The development environment console displays information about formulas that are used to calculate in the first model calculation point.

See also:

IMsProblemCalculation