SetMatrix(StubKey: Integer; Value: IMatrix);
StudKey. Key of the data source, for which a matrix is set.
Value. The data matrix that will be used during modeling problem calculation.
The SetMatrix method sets a data matrix for modeling problem calculation.
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.
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:
The cube with the CUBE identifier is a data source of the modeling problem.
The cube with the CUBE_2 identifier is used to load the data matrix to the source.
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(Null) As 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: