SetMatrix(StubKey: Integer; Value: IMatrix);
StudKey. Key of the data source, for which a matrix is set.
Value. Data matrix that will be used during modeling problem calculation.
The SetMatrix method sets a data matrix for algorithm calculation .
The SetMatrix method enables the user to set a data matrix for the data source that is used in the problem, which will be used during algorithm calculation instead of real 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 by with changed data selection. To select the changed values of the matrix in use, set the flag by setting the IMatrix.ValueFlag property.
Executing the example requires that the repository contains a calculation algorithm with the ALGORITHM identifier and two standard cubes with equal dimensions:
The cube with the CUBE identifier is a data source of the calculation block.
The cube with the CUBE_2 identifier is used to load the data matrix to the source.
Add links to the Algo, Cubes, Dimensions, Metabase, and Matrix system assemblies. Add links to the assemblies required for working with calculation algorithms.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObjectDescriptor;
Cube: ICubeInstance;
DefDes: ICubeInstanceDestination;
Matr, Matr1: IMatrix;
DimSS, DimSS1: IDimSelectionSet;
SSFact: IDimSelectionSetFactory;
DimS: IDimSelection;
Algo: ICalcObject;
CalcAlgo: ICalcAlgorithm;
CalcAlgoExecuter: IAlgorithmCalculationExecutor;
CalcResult: IAlgorithmCalculationResult;
i: Integer;
Begin
// Get current repository
MB := MetabaseClass.Active;
// Open the cube, which data matrix will be used during algorithm calculation
Cube := Mb.ItemById("CUBE_2").Open(Null) As ICubeInstance;
// Set cube dimension selection
DefDes := Cube.Destinations.DefaultDestination;
DimSS := DefDes.CreateDimSelectionSet;
For Each DimS In DimSS Do
DimS.SelectAll;
End For;
// Get matrix
Matr := DefDes.Execute(DimSS);
// Get calculation algorithm
MObj := MB.ItemById("ALGORITHM");
Algo := CalcObjectFactory.CreateCalcObject(MObj, True);
CalcAlgo := Algo As ICalcAlgorithm;
CalcAlgoExecuter := CalcObjectFactory.CreateCalculationExecutor(MObj);
// Set matrix for algorithm calculation
CalcAlgoExecuter.SetMatrix(Mb.ItemById("CUBE").Key, Matr);
// Start calculation
CalcResult := CalcAlgoExecuter.Run;
Debug.WriteLine(" Calculation is finished in " + CalcResult.TotalElapsedMilliseconds.ToString + " ms.");
End Sub UseProc;
When executing the example for algorithm calculation a data matrix will be defined, which will be used on its calculation, then calculation will be executed.
See also: