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 a modeling container with the OBJ_MS identifier containing a model with the MODEL_GREY identifier in the repository. 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, VARUPPER_CONF_LEVEL, VAR_DYN_LOWER_CONF_LEVEL, VAR_DYNUPPER_CONF_LEVEL.
This procedure sets the variables, to which the series are unloaded, used by the MODEL_GREY model during the calculation. For its correct execution it is necessary to add links to the Ms, Metabase and Cubes 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 is unloaded results of calculation
Series := ModelTrans.Series;
// Input series
Ser := Series.Add(SerInput As IVariableStub);
TermInfo.Slice := Ser.Slices.Add(Null);
MethodSeries.Input := TermInfo;
// Series of excesses
Ser := Series.Add(SerResiduals As IVariableStub);
TermInfo.Slice := Ser.Slices.Add(Null);
MethodSeries.Residuals := TermInfo;
// forecast 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;
// Low confidence bound
Ser := Series.Add(SerLowerConfLevel As IVariableStub);
TermInfo.Slice := Ser.Slices.Add(Null);
MethodSeries.LowerConfidenceLevel := TermInfo;
// high confidence bound
Ser := Series.Add(SerUpperConfLevel As IVariableStub);
TermInfo.Slice := Ser.Slices.Add(Null);
MethodSeries.UpperConfidenceLevel := TermInfo;
// Low dynamic confidence bound
Ser := Series.Add(SerDynLowerConfLevel As IVariableStub);
TermInfo.Slice := Ser.Slices.Add(Null);
MethodSeries.DynamicLowerConfidenceLevel := TermInfo;
// high dynamic confidence bound
Ser := Series.Add(SerDynUpperConfLevel As IVariableStub);
TermInfo.Slice := Ser.Slices.Add(Null);
MethodSeries.DynamicUpperConfidenceLevel := TermInfo;
// Save model calculation parameters
(Model As IMetabaseObject).Save;
// Calculates model
ModelCalc := ModelTrans.CreateCalculation;
CalcPeriod := ModelCalc.Period;
CalcPeriod.IdentificationStartDate := Model.Period.IdentificationStartDate;
CalcPeriod.IdentificationEndDate := Model.Period.IdentificationEndDate;
CalcPeriod.ForecastStartDate := Model.Period.ForecastStartDate;
CalcPeriod.ForecastEndDate := Model.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(For model are available next series:);
If MethodSeries.IsAvailable(MsMethodSeriesType.Input) Then
TermText := MethodSeries.SeriesByType(MsMethodSeriesType.Input).TermText;
Debug.WriteLine( Input 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(" forecast series - " + TermText);
End If;
If MethodSeries.IsAvailable(MsMethodSeriesType.Residuals) Then
TermText := MethodSeries.SeriesByType(MsMethodSeriesType.Residuals).TermText;
Debug.WriteLine(" Series of excesses - " + TermText);
End If;
If MethodSeries.IsAvailable(MsMethodSeriesType.LowerConfidenceLevel) Then
TermText := MethodSeries.SeriesByType(MsMethodSeriesType.LowerConfidenceLevel).TermText;
Debug.WriteLine(" Low confidence bound - " + TermText);
End If;
If MethodSeries.IsAvailable(MsMethodSeriesType.UpperConfidenceLevel) Then
TermText := MethodSeries.SeriesByType(MsMethodSeriesType.UpperConfidenceLevel).TermText;
Debug.WriteLine(" high confident bound - " + TermText);
End If;
If MethodSeries.IsAvailable(MsMethodSeriesType.DynamicLowerConfidenceLevel) Then
TermText := MethodSeries.SeriesByType(MsMethodSeriesType.DynamicLowerConfidenceLevel).TermText;
Debug.WriteLine( Low dyn. confidence bound - + TermText);
End If;
If MethodSeries.IsAvailable(MsMethodSeriesType.DynamicUpperConfidenceLevel) Then
TermText := MethodSeries.SeriesByType(MsMethodSeriesType.DynamicUpperConfidenceLevel).TermText;
Debug.WriteLine(" high dyn. confidence bound - " + TermText);
End If;
End Sub UserProc;
After executing the example the parameters, where the series, that is used during the model calculation, are unloaded, 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: