Add: IMsCompositeFormulaTermSet;
The Add method adds a set of the composite terms to the collection.
Executing the example requires that the modeling container (CONT_MODEL) contains a model (BinReg) that uses the binary regression method for calculation. The X2 variable also must be present in this container.
Sub Main;
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("Added set index: " + 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 Main;
After executing the example a new set is added to the model explanatory composite terms set. Its index in the collection is displayed in the console window.
See also: