Series: IMsMethodSeries;
The Series property returns the set of possible series used by the method during the calculation.
To determine whether the specified series took place in the calculation, use the IMsMethodSeries.IsAvailable property.
Executing the example requires that the repository includes a modeling container with the OBJ_MS identifier containing a model with the MODEL_GREY identifier. The model is calculated by the Grey forecast. Problem identifier for model calculation is PROBLEM_GREY. The variables with the following identifiers must be present in the modeling container: VAR_INPUT, VAR_FITTED, VAR_FORECAST, VAR_RESIDUALS, VAR_LOWER_CONF_LEVEL, VAR_UPPER_CONF_LEVEL, VAR_DYN_LOWER_CONF_LEVEL, VAR_DYN_UPPER_CONF_LEVEL.
This procedure sets the variables, to which the series are loaded used by the MODEL_GREY model during the calculation.
Add links to the Cubes, Metabase, Ms system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
MsDescrKey: Integer;
SerFitted, SerForecast, SerResiduals, SerInput: IMsVariableStub;
SerLowerConfLevel, SerUpperConfLevel: IMsVariableStub;
SerDynLowerConfLevel, SerDynUpperConfLevel: IMsVariableStub;
Model: IMsModel;
ModelTrans: IMsFormulaTransform;
Formula: IMsFormula;
Grey: IMsGreyForecastTransform;
MethodSeries: IMsMethodSeries;
TermInfo: IMsFormulaTermInfo;
Series: IMsFormulaTransformVariables;
Ser: IMsFormulaTransformVariable;
ModelCalc: IMsMethodCalculation;
CalcPeriod: IMsModelPeriod;
Coord: IMsFormulaTransformCoord;
Problem: IMsProblem;
CalcSett: IMsProblemCalculationSettings;
Calculation: IMsProblemCalculation;
TermText: String;
Begin
Mb := MetabaseClass.Active;
MsDescrKey := Mb.ItemById("OBJ_MS").Key;
// Receiving of variables
SerInput := MB.ItemByIdNamespace("VAR_INPUT", MsDescrKey).Edit As IMsVariableStub;
SerResiduals := MB.ItemByIdNamespace("VAR_RESIDUALS", MsDescrKey).Edit As IMsVariableStub;
SerForecast := MB.ItemByIdNamespace("VAR_FORECAST", MsDescrKey).Edit As IMsVariableStub;
SerFitted := MB.ItemByIdNamespace("VAR_FITTED", MsDescrKey).Edit As IMsVariableStub;
SerLowerConfLevel := MB.ItemByIdNamespace("VAR_LOWER_CONF_LEVEL", MsDescrKey).Edit As IMsVariableStub;
SerUpperConfLevel := MB.ItemByIdNamespace("VAR_UPPER_CONF_LEVEL", MsDescrKey).Edit As IMsVariableStub;
SerDynLowerConfLevel := MB.ItemByIdNamespace("VAR_DYN_LOWER_CONF_LEVEL", MsDescrKey).Edit As IMsVariableStub;
SerDynUpperConfLevel := MB.ItemByIdNamespace("VAR_DYN_UPPER_CONF_LEVEL", MsDescrKey).Edit As IMsVariableStub;
// Get model
Model := MB.ItemByIdNamespace("MODEL_GREY", MsDescrKey).Edit As IMsModel;
ModelTrans := Model.Transform;
// Set up model calculation parameters
Formula := ModelTrans.FormulaItem(0);
Grey := Formula.Method As IMsGreyForecastTransform;
MethodSeries := Grey.Series;
TermInfo := ModelTrans.CreateTermInfo;
// Specify series, to which calculation results are loaded
Series := ModelTrans.Series;
// Input series
Ser := Series.Add(SerInput As IVariableStub);
TermInfo.Slice := Ser.Slices.Add(Null);
MethodSeries.Input := TermInfo;
// Residual series
Ser := Series.Add(SerResiduals As IVariableStub);
TermInfo.Slice := Ser.Slices.Add(Null);
MethodSeries.Residuals := TermInfo;
// Forecasting series
Ser := Series.Add(SerForecast As IVariableStub);
TermInfo.Slice := Ser.Slices.Add(Null);
MethodSeries.Forecast := TermInfo;
// Modeling series
Ser := Series.Add(SerFitted As IVariableStub);
TermInfo.Slice := Ser.Slices.Add(Null);
MethodSeries.Fitted := TermInfo;
// Lower confidence limit
Ser := Series.Add(SerLowerConfLevel As IVariableStub);
TermInfo.Slice := Ser.Slices.Add(Null);
MethodSeries.LowerConfidenceLevel := TermInfo;
// Upper confidence limit
Ser := Series.Add(SerUpperConfLevel As IVariableStub);
TermInfo.Slice := Ser.Slices.Add(Null);
MethodSeries.UpperConfidenceLevel := TermInfo;
// Lower dynamic confidence limit
Ser := Series.Add(SerDynLowerConfLevel As IVariableStub);
TermInfo.Slice := Ser.Slices.Add(Null);
MethodSeries.DynamicLowerConfidenceLevel := TermInfo;
// Upper dynamic confidence limit
Ser := Series.Add(SerDynUpperConfLevel As IVariableStub);
TermInfo.Slice := Ser.Slices.Add(Null);
MethodSeries.DynamicUpperConfidenceLevel := TermInfo;
// Save model calculation parameters
(Model As IMetabaseObject).Save;
// Calculate the model
ModelCalc := ModelTrans.CreateCalculation;
CalcPeriod := ModelCalc.Period;
CalcPeriod.IdentificationStartDate := Model.Transform.Period.IdentificationStartDate;
CalcPeriod.IdentificationEndDate := Model.Transform.Period.IdentificationEndDate;
CalcPeriod.ForecastStartDate := Model.Transform.Period.ForecastStartDate;
CalcPeriod.ForecastEndDate := Model.Transform.Period.ForecastEndDate;
Coord := ModelTrans.CreateCoord(Null);
Grey.Execute(ModelCalc, Coord);
Problem := MB.ItemByIdNamespace("PROBLEM_GREY", MsDescrKey).Bind As IMsProblem;
CalcSett := Problem.CreateCalculationSettings;
Calculation := Problem.Calculate(CalcSett);
Calculation.Run;
// Display series, that were calculated
Debug.WriteLine("The following series are available for the model:");
If MethodSeries.IsAvailable(MsMethodSeriesType.Input) Then
TermText := MethodSeries.SeriesByType(MsMethodSeriesType.Input).TermText;
Debug.WriteLine(" Output series - " + TermText);
End If;
If MethodSeries.IsAvailable(MsMethodSeriesType.Fitted) Then
TermText := MethodSeries.SeriesByType(MsMethodSeriesType.Fitted).TermText;
Debug.WriteLine(" Modeling series - " + TermText);
End If;
If MethodSeries.IsAvailable(MsMethodSeriesType.Forecast) Then
TermText := MethodSeries.SeriesByType(MsMethodSeriesType.Forecast).TermText;
Debug.WriteLine(" Forecasting series - " + TermText);
End If;
If MethodSeries.IsAvailable(MsMethodSeriesType.Residuals) Then
TermText := MethodSeries.SeriesByType(MsMethodSeriesType.Residuals).TermText;
Debug.WriteLine(" Residual series - " + TermText);
End If;
If MethodSeries.IsAvailable(MsMethodSeriesType.LowerConfidenceLevel) Then
TermText := MethodSeries.SeriesByType(MsMethodSeriesType.LowerConfidenceLevel).TermText;
Debug.WriteLine(" Lower confidence limit - " + TermText);
End If;
If MethodSeries.IsAvailable(MsMethodSeriesType.UpperConfidenceLevel) Then
TermText := MethodSeries.SeriesByType(MsMethodSeriesType.UpperConfidenceLevel).TermText;
Debug.WriteLine(" Upper confidence limit - " + TermText);
End If;
If MethodSeries.IsAvailable(MsMethodSeriesType.DynamicLowerConfidenceLevel) Then
TermText := MethodSeries.SeriesByType(MsMethodSeriesType.DynamicLowerConfidenceLevel).TermText;
Debug.WriteLine(" Lower dynamic confidence limit - " + TermText);
End If;
If MethodSeries.IsAvailable(MsMethodSeriesType.DynamicUpperConfidenceLevel) Then
TermText := MethodSeries.SeriesByType(MsMethodSeriesType.DynamicUpperConfidenceLevel).TermText;
Debug.WriteLine(" Upper dynamic confidence limit - " + TermText);
End If;
End Sub UserProc;
After executing the example the parameters, where the series, that is used during the model calculation, are loaded, are determined. The model is calculated. The series names, that are received after calculation, is displayed inin the console window. For example:
For model are available next series:
Input series - VAR_INPUT[t]
Modeling series - VAR_FITTED[t]
forecast series - VAR_FORECAST[t]
Series of excesses - VAR_RESIDUALS[t]
Low confidence bound - VAR_LOWER_CONF_LEVEL[t]
high confidence bound - VARhigh_CONF_LEVEL[t]
See also: