IMsFormulaTermInfo.SetDate

Fore Syntax

SetDate(Value: DateTime; DateFormat: String);

Fore.NET Syntax

SetDate(Value: System.DateTime; DateFormat: string);

Parameters

Value. Date, which needs to be fixed for this term.

DateFormat. Date format, according to which the fixation is made.

Description

The SetDate method fixes the date for the term.

Comments

On calling the method the IMsFormulaTermInfo.Type property is automatically set to the MsFormulaTermType.Date value, and on calculating the model the value of the point corresponding to the specified date will be substituted as the value of the term.

Examples of formats, which the DateFormat parameter may take:

Fore Example

Executing the example requires that the repository contains a modeling container with the MODEL_SPACE identifier. The container has the VAR variable, which will be used as a modeling one, and the VAR_F variable, used as a factor.

Add links to the Metabase, Ms, Cubes, Dimensions system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Kont: IMetabaseObjectDescriptor;
    CrInf: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    Model: IMsModel;
    Trans: IMsFormulaTransform;
    VarTrans: IMsFormulaTransformVariable;
    Tree: IMsFormulaTransformSlicesTree;
    Slice: IMsFormulaTransformSlice;
    Selector: IMsFormulaTransformSelector;
    Formula: IMsFormula;
    NonLinear: IMsNonLinearRegressionTransform;
    Varr: IVariableStub;
    TransVar: IMsFormulaTransformVariable;
    TermX1, TermX2: IMsFormulaTerm;
    TermX1Info, TermX2Info: IMsFormulaTermInfo;
Begin
    MB := MetabaseClass.Active;
    Kont := Mb.ItemById(
"MODEL_SPACE");
    
//creating model
    CrInf := Mb.CreateCreateInfo;
    CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSMODEL;
    CrInf.Id := MB.GenerateId(
"New_NonLinReg", Kont.Key);
    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", Kont.Key).Bind As IVariableStub;
    Trans.Outputs.Add(Varr);
    VarTrans := Trans.Outputs.Item(
0);
    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_F", Kont.Key).Bind As IVariableStub;
    Trans.Inputs.Add(Varr);
    TransVar := Trans.Inputs.Item(
0);
    Slice := TransVar.SlicesTree(VarTrans).CreateSlice(
1);
    
//comparing term to the slice in a variable
    TermX1 := NonLinear.Operands.Add(Slice);
    TermX2 := NonLinear.Operands.Add(Slice);
    TermX1Info := TermX1.TermInfo;
    TermX2Info := TermX2.TermInfo;
    TermX2Info.Type := MsFormulaTermType.Date;
    TermX2Info.SetDate(DateTime.ComposeDay(
200011), "YYYY");
    
//creating equation
    NonLinear.Expression.AsString := "A0+" + TermX1Info.TermInnerText + "/" + TermX2Info.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 calculation of the model, the coordinate value, that corresponds to the year 2000, is substituted as the value of the second term.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Ms;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    Kont: IMetabaseObjectDescriptor;
    CrInf: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    Model: IMsModel;
    Trans: IMsFormulaTransform;
    VarTrans: IMsFormulaTransformVariable;
    Tree: IMsFormulaTransformSlicesTree;
    Slice: IMsFormulaTransformSlice;
    Selector: IMsFormulaTransformSelector;
    Formula: IMsFormula;
    NonLinear: IMsNonLinearRegressionTransform;
    Varr: IVariableStub;
    TransVar: IMsFormulaTransformVariable;
    TermX1, TermX2: IMsFormulaTerm;
    TermX1Info, TermX2Info: IMsFormulaTermInfo;
Begin
    MB := Params.Metabase;
    Kont := Mb.ItemById["MODEL_SPACE"];
    //creating model
    CrInf := Mb.CreateCreateInfo();
    CrInf.ClassId := MetabaseObjectClass.KE_CLASS_MSMODEL As integer;
    CrInf.Id := MB.GenerateId("New_NonLinReg", Kont.Key);
    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", Kont.Key].Bind() As IVariableStub;
    Trans.Outputs.Add(Varr);
    VarTrans := Trans.Outputs.Item[0];
    Tree := VarTrans.SlicesTree[VarTrans];
    Slice := Tree.CreateSlice(1);
    Selector := Trans.CreateSelector();
    Selector.Slice := Slice;
    Formula := Trans.Transform[Selector];
    Formula.Kind := MsFormulaKind.mfkNonLinearRegression;
    Formula.Level := DimCalendarLevel.dclYear;
    NonLinear := Formula.Method As IMsNonLinearRegressionTransform;
    //adding factor
    Varr := MB.ItemByIdNamespace["VAR_F", Kont.Key].Bind() As IVariableStub;
    Trans.Inputs.Add(Varr);
    TransVar := Trans.Inputs.Item[0];
    Slice := TransVar.SlicesTree[VarTrans].CreateSlice(1);
    //comparing the term to the slice in variable
    TermX1 := NonLinear.Operands.Add(Slice);
    TermX2 := NonLinear.Operands.Add(Slice);
    TermX1Info := TermX1.TermInfo;
    TermX2Info := TermX2.TermInfo;
    TermX2Info.Type := MsFormulaTermType.mfttDate;
    TermX2Info.SetDate(DateTime.Parse("01.01.2000"), "YYYY");
    //creating equation
    NonLinear.Expression.AsString := "A0+" + TermX1Info.TermInnerText + "/" + TermX2Info.TermInnerText;
    MObj.Save();
End Sub;

See also:

IMsFormulaTermInfo | IMsFormulaTermInfo.Date