Residuals: IVariableStub;
The Residuals property determines the variable to which residual series is unloaded on modeling problem calculation.
The property is outdated, use IMsMethodSeries.Residuals.
Executing the example requires a modeling problem in the container. The first model of the problem uses the Grey forecast for calculation.
Sub Main;
Var
MB: IMetabase;
KontKey: Integer;
MObj: IMetabaseObject;
Problem: IMsProblem;
CalcSett: IMsProblemCalculationSettings;
Calculation: IMsProblemCalculation;
Model: IMsModel;
Trans: IMsFormulaTransform;
VarTrans: IMsFormulaTransformVariable;
Tree: IMsFormulaTransformSlicesTree;
Slice: IMsFormulaTransformSlice;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
Grey: IMsGreyForecastTransform;
Residuals_Var: IVariableStub;
Begin
MB := MetabaseClass.Active;
KontKey := MB.ItemById("KONT_MODEL").Key;
MObj := MB.ItemByIdNamespace("PROBLEM_1", KontKey).Edit;
//variables to which the data are loaded
Residuals_Var := MB.ItemByIdNamespace("Residuals_Var", KontKey).Edit As IVariableStub;
Problem := MObj As IMsProblem;
Model := (Problem.MetaModel.CalculationChain.Item(0) As IMsCalculationChainModel).Model;
Model := (Model As IMetabaseObject).Edit As IMsModel;
Model.Transform.Series.Add(Residuals_Var);
Trans := Model.Transform;
VarTrans := Trans.Outputs.Item(0);
Tree := VarTrans.SlicesTree(VarTrans);
Slice := Tree.CreateSlice(1);
Selector := Model.Transform.CreateSelector;
Selector.Slice := Slice;
Formula := Model.Transform.Transform(Selector);
Grey := Formula.Method As IMsGreyForecastTransform;
//residual series
Grey.Residuals := Residuals_Var;
//parameters for problem calculation
CalcSett := Problem.CreateCalculationSettings;
Calculation := Problem.Calculate(CalcSett);
Calculation.Run;
(Model As IMetabaseObject).Save;
MObj.Save;
End Sub Main;
After executing the example, the variable with the Residuals_Var identifier is added to the list of output variables of the model. After calculating the problem, the residual series is unloaded to it.
See also: