Result: IMsFormulaTerm;
Result: Prognoz.Platform.Interop.Ms.IMsFormulaTerm;
The Result property returns the term corresponding to output variable.
To get spliced series, use the IMsSpliceTransform.Operands property.
Executing the example requires that the repository contains a modeling container with the MS identifier. This container should include a standard model with the MODEL_SPLICE identifier containing one or mode factors.
Add links to the Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
ModelCont: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
InputsVar: IMsFormulaTransformVariables;
TransformVar: IMsFormulaTransformVariable;
Slice: IMsFormulaTransformSlice;
Operands: IMsFormulaTermList;
x1, x2: IMsSpliceFormulaTerm;
Formula: IMsFormula;
Splice: IMsSpliceTransform;
Coord: IMsFormulaTransformCoord;
Calc: IMsModelCalculation;
Arr: Array Of Double;
i: Integer;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get modelling container
ModelCont := mb.ItemById("MS");
// Get model
Model := mb.ItemByIdNamespace("MODEL_SPLICE", ModelCont.Key).Edit As IMsModel;
// Set up model parameters
Transform := Model.Transform;
Formula := Transform.FormulaItem(0);
// Determine that model will splice series
Formula.Kind := MsFormulaKind.Splice;
Splice := Formula.Method As IMsSpliceTransform;
// Set method and direction of series splice
Splice.MethodType := MsSpliceType.Butt;
Splice.SpliceDirection := MsSpliceDirection.Both;
// Set the first spiced series and its parameters
InputsVar := Transform.Inputs;
TransformVar := InputsVar.Item(0);
Slice := TransformVar.Slices.Item(0);
Operands := Splice.Operands;
Operands.Clear;
x1 := Operands.Add(Slice) As IMsSpliceFormulaTerm;
x1.StartDate := DateTime.Parse("01.01.2001");
x1.EndDate := DateTime.Parse("01.01.2004");
x1.BoundByData := False;
// Set the second spliced series and its parameters
TransformVar := InputsVar.Item(1);
Slice := TransformVar.Slices.Item(0);
x2 := Operands.Add(Slice) As IMsSpliceFormulaTerm;
x2.StartDate := DateTime.Parse("01.01.2005");
x2.EndDate := DateTime.Parse("01.01.2008");
x2.BoundByData := False;
// Save model
(Model As IMetabaseObject).Save;
// Determine settings to calculate model
Coord := Transform.CreateCoord(Transform.Outputs.Item(0));
Calc := Model.CreateCalculation;
Calc.Period.IdentificationStartDate := DateTime.Parse("01.01.1990");
Calc.Period.IdentificationEndDate := DateTime.Parse("31.12.2016");
Calc.Period.ForecastStartDate := DateTime.Parse("01.01.2017");
Calc.Period.ForecastEndDate := DateTime.Parse("31.12.2025");
// Get output variable data and display it in the console window
Arr := Splice.Result.Serie(Calc As IMsMethodCalculation);
For i := 0 To Arr.Length - 1 Do
Debug.WriteLine(Arr[i]);
End For;
End Sub UserProc;
After executing the example the MODEL_SPLICE model will splice data of the first factor (from 2001 to 2004) and the second factor of the model (from 2005 to 2008). The console window displays data of output variable.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
ModelCont: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
InputsVar: IMsFormulaTransformVariables;
TransformVar: IMsFormulaTransformVariable;
Slice: IMsFormulaTransformSlice;
Operands: IMsFormulaTermList;
x1, x2: IMsSpliceFormulaTerm;
Formula: IMsFormula;
Splice: IMsSpliceTransform;
Coord: IMsFormulaTransformCoord;
Calc: IMsModelCalculation;
Arr: System.Array;
i: Integer;
Begin
// Get current repository
mb := Params.Metabase;
// Get modeling container
ModelCont := mb.ItemById["MS"];
// Get model
Model := mb.ItemByIdNamespace["MODEL_SPLICE", ModelCont.Key].Edit() As IMsModel;
// Set up model parameters
Transform := Model.Transform;
Formula := Transform.FormulaItem[0];
// Determine that model will splice series
Formula.Kind := MsFormulaKind.mfkSplice;
Splice := Formula.Method As IMsSpliceTransform;
// Set method and direction of method splice
Splice.MethodType := MsSpliceType.mstButt;
Splice.SpliceDirection := MsSpliceDirection.msdBoth;
// Set the first spliced series and its parameters
InputsVar := Transform.Inputs;
TransformVar := InputsVar.Item[0];
Slice := TransformVar.Slices.Item[0];
Operands := Splice.Operands;
Operands.Clear();
x1 := Operands.Add(Slice) As IMsSpliceFormulaTerm;
x1.StartDate := DateTime.Parse("01.01.2001");
x1.EndDate := DateTime.Parse("01.01.2004");
x1.BoundByData := False;
// Set the second spliced series and its parameters
TransformVar := InputsVar.Item[1];
Slice := TransformVar.Slices.Item[0];
x2 := Operands.Add(Slice) As IMsSpliceFormulaTerm;
x2.StartDate := DateTime.Parse("01.01.2005");
x2.EndDate := DateTime.Parse("01.01.2008");
x2.BoundByData := False;
// Save the model
(Model As IMetabaseObject).Save();
// Determine settings to calculate model
Coord := Transform.CreateCoord(Transform.Outputs.Item[0]);
Calc := Model.CreateCalculation();
Calc.Period.IdentificationStartDate := DateTime.Parse("01.01.1990");
Calc.Period.IdentificationEndDate := DateTime.Parse("31.12.2016");
Calc.Period.ForecastStartDate := DateTime.Parse("01.01.2017");
Calc.Period.ForecastEndDate := DateTime.Parse("31.12.2025");
// Get output variable data and display it in the console window
Arr := Splice.Result.Serie[Calc As IMsMethodCalculation];
For i := 0 To Arr.Length - 1 Do
System.Diagnostics.Debug.WriteLine(Arr[i]);
End For;
End Sub;
See also: