FiniteUseMatrix: IMsFormulaTerm;
The FiniteUseMatrix property determines the term corresponding to the variable, based on which the final use structure is calculated. It is used in II quadrant calculation.
Sub Main;
Var
MB: IMetabase;
CrInf: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
Model: IMsModel;
Trans: IMsFormulaTransform;
EndVar, ValVar, AVar, XVar, TwoKvadrVar: IMsVariable;
Dim, Dim1: IDimensionModel;
TransVar: IMsFormulaTransformVariable;
Tree: IMsFormulaTransformSlicesTree;
Slice: IMsFormulaTransformSlice;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
Industry: IMsInterindustryBalanceTransform;
Term: IMsFormulaTerm;
Begin
MB := MetabaseClass.Active;
CrInf := Mb.CreateCreateInfo;
CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSMODEL;
CrInf.Id := "New_MOB";
CrInf.Name := "New_MOB";
CrInf.Parent := Mb.ItemById("KONT_MODEL");
CrInf.Permanent := False;
MObj := Mb.CreateObject(CrInf).Edit;
Model := MObj As IMsModel;
Trans := Model.Transform;
Model.Kind := MsModelKind.InterindustryBalance;
//Add a variable of final use in Outputs models, and gross output, a matrix A and matrix X in Inputs
EndVar := MB.ItemByIdNamespace("EndVar", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;
Model.Output.Add(EndVar);
ValVar := MB.ItemByIdNamespace("Val_Prod", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;
Model.Input.Add(ValVar);
AVar := MB.ItemByIdNamespace("MatrA", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;
Model.Input.Add(AVar);
XVar := MB.ItemByIdNamespace("MatrX", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;
Model.Input.Add(XVar);
//For a variable of final use and gross output the through dimensions are set
Dim := EndVar.Dimensions.Item(0).Model;
Dim1 := ValVar.Dimensions.Item(0).Model;
Trans.DimensionTransparent(Trans.Outputs.Item(0), Dim) := True;
Trans.DimensionTransparent(Trans.Outputs.Item(0), Dim1) := True;
//Fill the model parameters
//Add the variable of finish use
TransVar := Model.Transform.Outputs.FindById("EndVar");
Tree := TransVar.SlicesTree(Null);
Slice := Tree.CreateSlice(1);
Selector := EndVar.Transform.CreateSelector;
Selector.Slice := Slice;
Formula := Model.Transform.Transform(Selector);
Formula.Kind := MsFormulaKind.InterindustryBalance;
Formula.Level := DimCalendarLevel.Year;
Industry := Formula.Method As IMsInterindustryBalanceTransform;
//Indicate the dimensions by lines
Industry.BranchRowDimension := Dim;
//Assign the variable of gross output
TransVar := Model.Transform.Inputs.FindById("Val_Prod");
Tree := TransVar.SlicesTree(Null);
Slice := Tree.CreateSlice(1);
Term := Industry.Operands.Add(Slice);
Industry.Argument := Term;
//Indicate the dimension by columns
Industry.BranchColumnDimension := Dim1;
//Assign the variable of A matrix
TransVar := Model.Transform.Inputs.FindById("MatrA");
Tree := TransVar.SlicesTree(Null);
Slice := Tree.CreateSlice(1);
Term := Industry.Operands.Add(Slice);
Industry.NewMatrixA := Term;
//Assign the variable of X matrix
TransVar := Model.Transform.Inputs.FindById("MatrX");
Tree := TransVar.SlicesTree(Null);
Slice := Tree.CreateSlice(1);
Term := Industry.Operands.Add(Slice);
Industry.MatrixA := Term;
//Second quadrant
TwoKvadrVar := MB.ItemByIdNamespace("TwoKvadr", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;
Model.Input.Add(TwoKvadrVar);
TwoKvadrVar := MB.ItemByIdNamespace("var_11", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;
Model.Input.Add(TwoKvadrVar);
TwoKvadrVar := MB.ItemByIdNamespace("var_22", MB.ItemById("KONT_MODEL").Key).Bind As IMsVariable;
Model.Input.Add(TwoKvadrVar);
//Assign the variable for II quadrant
TransVar := Model.Transform.Inputs.FindById("TwoKvadr");
Tree := TransVar.SlicesTree(Null);
Slice := Tree.CreateSlice(1);
Term := Industry.Operands.Add(Slice);
Industry.SecondQuadrant := Term;
//Assign the variable by which the calculation is executed
TransVar := Model.Transform.Inputs.FindById("var_11");
Tree := TransVar.SlicesTree(Null);
Slice := Tree.CreateSlice(1);
Term := Industry.Operands.Add(Slice);
Industry.FiniteUseMatrix := Term;
//Assign the variable where the matrix is loaded
TransVar := Model.Transform.Inputs.FindById("var_22");
Tree := TransVar.SlicesTree(Null);
Slice := Tree.CreateSlice(1);
Term := Industry.Operands.Add(Slice);
Industry.NewFiniteUseMatrix := Term;
Industry.GenerateFiniteUse := True;
MObj.Save;
End Sub Main;
After executing the example a new model of interindustrial balance is created in the modeling container. This model solves the problem of finding the final use. The variables of final use, gross output, variables for calculation and uploading of the A matrix are added. The calculation of the second quadrant is also set. The structure of final use is calculated on the basis of a variable with the identifier var_11.
See also:
IMsInterindustryBalanceTransform | IMsInterindustryBalanceTransform.SecondQuadrant | IMsInterindustryBalanceTransform.NewFiniteUseMatrix