Add: IMsCompositeFormulaTermSet;
The Add method adds a set of the composite terms to the collection.
Executing the example requires that the repository contains the CONT_MODEL modeling container with the BINREG model that uses binary regression method for calculation. This container should also have the X2 variable.
Add links to the Metabase and Ms system assemblies.
Sub UserProc;
Var
MB: IMetabase;
SpaceDescr: IMetabaseObjectDescriptor;
MObj: IMetabaseObject;
Model: IMsModel;
Trans: IMsFormulaTransform;
VarTrans: IMsFormulaTransformVariable;
Tree: IMsFormulaTransformSlicesTree;
Slice: IMsFormulaTransformSlice;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
Binary: IMsBinaryRegressionTransform;
Explanatories: IMsCompositeFormulaTermSetList;
TermSet: IMsCompositeFormulaTermSet;
CompTerm: IMsCompositeFormulaTerm;
Var_inp: IMsVariable;
pF_inp: IMsFormulaTransformVariable;
pSlice: IMsFormulaTransformSlice;
pTermInfo: IMsFormulaTermInfo;
Begin
MB := MetabaseClass.Active;
SpaceDescr := mb.ItemById("CONT_MODEL");
MObj := MB.ItemByIdNamespace("BinReg",SpaceDescr.Key).Edit;
Model := MObj As IMsModel;
Trans := Model.Transform;
VarTrans := Trans.Outputs.Item(0);
Tree := VarTrans.SlicesTree(VarTrans);
Slice := Tree.CreateSlice(1);
Selector := Model.Transform.CreateSelector;
Selector.Slice := Slice;
Formula := Model.Transform.Transform(Selector);
Binary := Formula.Method As IMsBinaryRegressionTransform;
Explanatories := Binary.Explanatories;
TermSet := Explanatories.Add;
Debug.WriteLine("Index of added set: " + Explanatories.IndexOf(TermSet).ToString);
CompTerm := TermSet.Add;
Var_inp := mb.ItemByIdNamespace("X2",SpaceDescr.Key).Bind As IMsVariable;
pF_inp := Trans.Inputs.Add(Var_inp As IVariableStub);
pSlice := pF_inp.Slices.Add(Null);
CompTerm.Operands.Add(pSlice);
pTermInfo := Trans.CreateTermInfo;
pTermInfo.Slice := pSlice;
CompTerm.Expression.AsString:= pTermInfo.TermInnerText;
MObj.Save;
End Sub;
After executing the example a new set is added to the collection of model explanatory composite terms sets. Its index in the collection is displayed in the console window.
See also: