TermInnerText: String;
The TermInnerText property returns the internal presentation term.
This view is substituted to the model equation.
Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier. The container has the Var_1 variable, which will be later used as a modeling one, and the Var_Factor variable, used as a factor.
Sub UserProc;
Var
MB: IMetabase;
Kont: IMetabaseObjectDescriptor;
CrInf: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
Model: IMsModel;
Trans: IMsFormulaTransform;
VarTrans, VarTrans1: IMsFormulaTransformVariable;
Tree: IMsFormulaTransformSlicesTree;
Slice: IMsFormulaTransformSlice;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
NonLinear: IMsNonLinearRegressionTransform;
Varr: IVariableStub;
TermList: IMsFormulaTermList;
TermX1, TermX2, TermX3: IMsFormulaTerm;
TermX1Info, TermX2Info, TermX3Info: IMsFormulaTermInfo;
Begin
MB := MetabaseClass.Active;
Kont := Mb.ItemById("MODEL_SPACE");
//creating model
CrInf := Mb.CreateCreateInfo;
CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSMODEL;
CrInf.Id := "New_NonLinReg";
CrInf.Name := "New_NonLinReg";
CrInf.Parent := Kont;
MObj := Mb.CreateObject(CrInf).Edit;
Model := MObj As IMsModel;
Trans := Model.Transform;
//adding output variable
Varr := MB.ItemByIdNamespace("Var_1", Kont.Key).Bind As IVariableStub;
VarTrans := Trans.Outputs.Add(Varr);
Tree := VarTrans.SlicesTree(VarTrans);
Slice := Tree.CreateSlice(1);
Selector := Trans.CreateSelector;
Selector.Slice := Slice;
Formula := Trans.Transform(Selector);
Formula.Kind := MsFormulaKind.NonLinearRegression;
Formula.Level := DimCalendarLevel.Year;
NonLinear := Formula.Method As IMsNonLinearRegressionTransform;
//adding factor
Varr := MB.ItemByIdNamespace("Var_Factor", Kont.Key).Bind As IVariableStub;
VarTrans1 := Trans.Inputs.Add(Varr);
Slice := VarTrans1.SlicesTree(VarTrans).CreateSlice(1);
//comparing the term to the slice in variable
TermList := NonLinear.Operands;
TermX1 := TermList.Add(Slice);
TermX2 := TermList.Add(Slice);
TermX3 := TermList.Add(Slice);
TermX1Info := TermX1.TermInfo;
TermX2Info := TermX2.TermInfo;
TermX3Info := TermX3.TermInfo;
//Parameters of second term
TermX2Info.Type := MsFormulaTermType.Date;
TermX2Info.SetDate(DateTime.ComposeDay(2000, 1, 1), "YYYY");
//Setting of parameters of third term, as and of the second
TermX3Info.ParseTerm(TermX2Info.TermInnerText);
//Changing of date for third term
TermX3Info.SetDate(DateTime.ComposeDay(2001, 1, 1), "YYYY");
//creating equation
NonLinear.Expression.AsString :=
"A0+" + TermX1Info.TermInnerText + "/(" +
TermX2Info.TermInnerText + "+" + TermX3Info.TermInnerText + ")";
MObj.Save;
End Sub UserProc;
After executing the example, a new model is created in the modeling container. The method of non-linear regression is used for model calculation. The output variable and one input variable is added into the model. To set up an equation, terms referring to the slice of the input variable will be created. On calculating the model the coordinate value that corresponds to 2000 and 2001 respectively is substituted as the value of the second and the third term.
See also: