IMsProblemCalculation.SetMatrix

Syntax

SetMatrix(StubKey: Integer; Value: IMatrix);

Parameters

StudKey. Key of the data source, for which a matrix is set.

Value. The data matrix that will be used during modeling problem calculation.

Description

The SetMatrix method sets a data matrix for modeling problem calculation.

Comments

The SetMatrix method can be used to set for a data source a data matrix that will be used during modeling problem calculation instead of actual data of cube/DBMS/cache. This matrix can be fully created and filled in manually using the Fore language, loaded from another cube with the same dimensions or from the source cube with changed data selection. To select the changed values of the used matrix, set the flag by setting the IMatrix.ValueFlag property.

Example

Executing the example requires that the repository contains a modeling container with the MS identifier that contains a modeling problem with the PROBLEM identifier and two standard cubes with equal dimensions:

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

Sub UserProc;
Var
    MB: IMetabase;
    MObj: IMetabaseObject;
    Problem: IMsProblem;
    CalcSett: IMsProblemCalculationSettings;
    Calculation: IMsProblemCalculation;
    Cube: ICubeInstance;
    DefDes: ICubeInstanceDestination;
    Matr: IMatrix;
    DimSS: IDimSelectionSet;
    SSFact: IDimSelectionSetFactory;
    DimS: IDimSelection;
    i: Integer;
Begin
    // Get the current repository
    MB := MetabaseClass.Active;
    // Open the cube, which data matrix will be used during calculation
    Cube := Mb.ItemById("CUBE_2").Open(NullAs ICubeInstance;
    // Set selection of cube dimensions
    DefDes := Cube.Destinations.DefaultDestination;
    DimSS := DefDes.CreateDimSelectionSet;
    For Each DimS In DimSS Do
        DimS.SelectAll;
    End For;
    // Get matrix
    Matr := DefDes.Execute(DimSS);
    // Get problem in modeling container
    MObj := MB.ItemByIdNamespace("PROBLEM", MB.ItemById("MS").Key).Edit;
    Problem := MObj As IMsProblem;
    // Set problem calculation options
    CalcSett := Problem.CreateCalculationSettings;
    Calculation := Problem.Calculate(CalcSett);
    // Set matrix for problem calculation
    Calculation.SetMatrix(Mb.ItemById("CUBE").Key, Matr);
    // Start calculation
    Calculation.Run;
    MObj.Save;
End Sub UserProc;

After executing the example a data matrix is defined for the modeling problem that will be used during modeling problem calculation, then the problem will be calculated.

See also:

IMsProblemCalculation