Period: IMsModelPeriod;
The Period property returns model calculation period.
The property allows to set the following parameters of model calculation period:
Sample period start date | Sample period end date | Forecasting period start date |
Specified date (default). | Specified date (default). | Specified date (default). |
Today plus/minus k points. | Today plus/minus k points. | Today plus/minus k points. |
Start of data plus/minus k points. | End of data plus/minus k points. | End of data plus/minus k points. |
Sample period end minus k points. | Sample period start plus k points. | Sample period end plus k points. |
Setting value by parameter. | Setting value by parameter. | Setting value by parameter. |
Start of data plus k points. |
NOTE. Value cannot be set by parameter for the models used in series mode of the time series database.
Executing the example requires that the repository contains a modeling container with the MS identifier. This container must have a metamodel with the METAMODEL_PERIOD identifier including calculation chain with the MODEL_PERIOD identifier.
Add links to the Dal, Dimensions, Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsKey: Integer;
MetaModel: IMsMetaModel;
pParams: IMsModelParams;
pPar: IMsModelParam;
pModel: IMsModel;
pPeriod: IMsModelPeriod;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get metamodel
MetaModel := mb.ItemByIdNamespace("METAMODEL_PERIOD", MsKey).Edit As IMsMetaModel;
// Get metamodel parameters
pParams := MetaModel.Params;
// Remove all parameters
pParams.Clear;
// Add metamodel parameter for creating sample period start
pPar := pParams.Add;
pPar.Id := "IDSTART";
pPar.Name := "Sample period";
pPar.DataType := DbDataType.Date;
pPar.DefaultValue := DateTime.Parse("01.01.1995");
// Add metamodel parameter for setting sample period end
pPar := pParams.Add;
pPar.Id := "IDEND";
pPar.Name := "Identification end";
pPar.DataType := DbDataType.Date;
pPar.DefaultValue := DateTime.Parse("01.01.2015");
// Save changes of the metamodel
(MetaModel As IMetabaseObject).Save;
// Get the model
pModel := mb.ItemByIdNamespace("MODEL_PERIOD", MsKey).Edit As IMsModel;
// Set daily calculation frequency for model
pModel.Transform.FormulaItem(0).Level := DimCalendarLevel.Day;
// Get model calculation period parameters
pPeriod := pModel.Transform.Period;
// Set parameters for model that determine sample period start and end
pPeriod.IdentificationStartDateParamID := "IDSTART";
pPeriod.IdentificationEndDateParamID := "IDEND";
// Display calendar element calculation method in the console
Debug.WriteLine(pModel.Transform.CalendarMode);
// Save changes in model
(pModel As IMetabaseObject).Save;
End Sub UserProc;
Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Dimensions;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
MsKey: uinteger;
MetaModel: IMsMetaModel;
pParams: IMsModelParams;
pPar: IMsModelParam;
pModel: IMsModel;
pPeriod: IMsModelPeriod;
Begin
// Get current repository
mb := Params.Metabase;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get metamodel
MetaModel := mb.ItemByIdNamespace["METAMODEL_PERIOD", MsKey].Edit() As IMsMetaModel;
// Get metamodel parameters
pParams := MetaModel.Params;
// Remove all parameters
pParams.Clear();
// Add metamodel parameter for creating sample period start
pPar := pParams.Add();
pPar.Id := "IDSTART";
pPar.Name := "Sample period";
pPar.DataType := DbDataType.ddtDate;
pPar.DefaultValue := DateTime.Parse("01.01.1995");
// Add metamodel parameter for setting sample period end
pPar := pParams.Add();
pPar.Id := "IDEND";
pPar.Name := "Identification end";
pPar.DataType := DbDataType.ddtDate;
pPar.DefaultValue := DateTime.Parse("01.01.2015");
// Save changes of the metamodel
(MetaModel As IMetabaseObject).Save();
// Get the model
pModel := mb.ItemByIdNamespace["MODEL_PERIOD", MsKey].Edit() As IMsModel;
// Set daily calculation frequency for model
pModel.Transform.FormulaItem[0].Level := DimCalendarLevel.dclDay;
// Get model calculation period parameters
pPeriod := pModel.Transform.Period;
// Set parameters for model that determine sample period start and end
pPeriod.IdentificationStartDateParamID := "IDSTART";
pPeriod.IdentificationEndDateParamID := "IDEND";
// Display calendar element calculation method in the console
System.Diagnostics.Debug.WriteLine(pModel.Transform.CalendarMode);
// Save changes in model
(pModel As IMetabaseObject).Save();
End Sub;
After executing the example, the start and end of model sample period is set by the IDSTART and IDEND parameters. The console displays calendar element calculation method.
See also: