CreateExpress(Metabase: IMetabase, ParamProvider: IMsParamProvider);
CreateExpress(Metabase: Prognoz.Platform.Interop.Ms.IMetabase, ParamProvider: Prognoz.Platform.Interop.Ms.IMsParamProvider);
Metabase. Repository that contains the model.
ParamProvider. The object containing settings of parameters.
The CreateExpress constructor creates settings of calculation of the parametric model.
To create calculation parameters of the standard model, use the MsFormulaTransform.Create constructor.
Executing the example requires a form containing the LanerBox component and the UiErAnalyzer component with UiErAnalyzer1 identifier, which is a data source for LanerBox. UiErAnalyzer1 must contain the workbook of the time series database containing series.
Add links to the Cubes, Dal, Dimensions, Metabase, Ms, Xml system assemblies.
Sub UserProc;
Var
Eax: IEaxAnalyzer;
ParamProv: IMsParamProvider;
Params: IMsModelParams;
Param: IMsModelParam;
Transform: IMsFormulaTransform;
Output: IMsFormulaTransformVariable;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
SeriesTransform: IMsFormulaTransform;
xmlDoc: FreeThreadedDomDocument60;
xmlElem: IXmlDomElement;
Expression: IExpression;
CalcSeries: ILanerCalculateSerie;
Determ: IMsDeterministicTransform;
Begin
Eax := UiErAnalyzer1.ErAnalyzer;
// Get the object for working with parameters
ParamProv := Eax.ParamProvider As IMsParamProvider;
// Get the collection of parameters
Params := ParamProv.Params;
// Create the parameter determining the minimum value
Param := Params.Add;
Param.DataType := DbDataType.Integer;
Param.DefaultValue := 20;
Param.Hidden := False;
Param.Id := "MIN_VAL";
Param.Name := "MIN_VAL";
// Create the parameter determining the maximum value
Param := Params.Add;
Param.DataType := DbDataType.Integer;
Param.DefaultValue := 50;
Param.Hidden := False;
Param.Id := "MAX_VAL";
Param.Name := "MAX_VAL";
// Update the object to work with parameters
Eax.UpdateParamProvider;
// Create an object for setting up calculation parameters
Transform := New MsFormulaTransform.CreateExpress(MetabaseClass.Active, ParamProv);
// Add output variable
Transform.Outputs.Add(Eax.Laner.Series.Item(0).Stub);
// Set up slice of the output variable
Selector := Transform.CreateSelector;
Output := Transform.Outputs.Item(0);
Selector.Slice := Output.Slices.Add(Null);
// Set up calculation method
Formula := Transform.Transform(Selector);
Formula.Kind := MsFormulaKind.Deterministic;
Formula.Level := DimCalendarLevel.Year;
Determ := Formula.Method As IMsDeterministicTransform;
Expression := Determ.Expression;
// Set the parametric calculation formula
Expression.AsString := "RandBetween({MIN_VAL}, {MAX_VAL})";
// Create a calculated series and set the parameters of it's calculation
CalcSeries := Eax.Laner.Series.AddCalculateSerie("Arbitrary values", DimCalendarLevel.Year);
CalcSeries.CreateDerivedSeries := False;
CalcSeries.UseTransform := True;
// Use parametric formula to calculate values of the series
SeriesTransform := CalcSeries.Transform.Transform As IMsFormulaTransform;
xmlDoc := New FreeThreadedDomDocument60.Create;
xmlElem := xmlDoc.createElement("Root");
Transform.SaveToXml(xmlElem);
SeriesTransform.LoadFromXml(xmlElem);
// Update data of the calculated series
CalcSeries.Transform.UpdateOutputVariable;
CalcSeries.Calculate;
End Sub UserProc;
Example execution result: MIN_VAL, MAX_VAL and a calculated series, calculating values based on these parameters are added to the workbook.
The requirements and result of the Fore.NET example execution match with those in the Fore example. Use Fore.NET analogs instead of Fore components.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Laner;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.MsXml2;
…
Public Sub UserProc();
Var
Eax: IEaxAnalyzer;
ParamProv: IMsParamProvider;
Params: IMsModelParams;
Param: IMsModelParam;
Transform: MsFormulaTransformClass;
Output: IMsFormulaTransformVariable;
Selector: IMsFormulaTransformSelector;
Formula: IMsFormula;
SeriesTransform: IMsFormulaTransform;
xmlDoc: FreeThreadedDomDocument60;
xmlElem: IXmlDomElement;
Expression: IExpression;
CalcSeries: ILanerCalculateSerie;
Determ: IMsDeterministicTransform;
Begin
Eax := uiErAnalyzerNet1.ErAnalyzer.ErAnalyzer;
// Get the object for working with parameters
ParamProv := Eax.ParamProvider As IMsParamProvider;
// Get the collection of parameters
Params := ParamProv.Params;
// Create the parameter determining the minimum value
Param := Params.Add();
Param.DataType := DbDataType.ddtInteger;
Param.DefaultValue := 20;
Param.Hidden := False;
Param.Id := "MIN_VAL";
Param.Name := "MIN_VAL";
// Create the parameter determining the maximum value
Param := Params.Add();
Param.DataType := DbDataType.ddtInteger;
Param.DefaultValue := 50;
Param.Hidden := False;
Param.Id := "MAX_VAL";
Param.Name := "MAX_VAL";
// Update the object to work with parameters
Eax.UpdateParamProvider();
// Create an object for setting up calculation parameters
Transform := New MsFormulaTransformClass.Create();
Transform.CreateExpress(Self.Metabase, ParamProv);
// Add output variable
Transform.Outputs.Add(Eax.Laner.Series.Item[0].Stub);
// Set up slice of the output variable
Selector := Transform.CreateSelector();
Output := Transform.Outputs.Item[0];
Selector.Slice := Output.Slices.Add(Null);
// Set up calculation method
Formula := Transform.Transform[Selector];
Formula.Kind := MsFormulaKind.mfkDeterministic;
Formula.Level := DimCalendarLevel.dclYear;
Determ := Formula.Method As IMsDeterministicTransform;
Expression := Determ.Expression;
// Set the parametric calculation formula
Expression.AsString := "RandBetween({MIN_VAL}, {MAX_VAL})";
// Create a calculated series and set the parameters of it's calculation
CalcSeries := Eax.Laner.Series.AddCalculateSerie("Arbitrary values", DimCalendarLevel.dclYear, -1);
CalcSeries.CreateDerivedSeries := False;
CalcSeries.UseTransform := True;
// Use parametric formula to calculate values of the series
SeriesTransform := CalcSeries.Transform.Transform As IMsFormulaTransform;
xmlDoc := New FreeThreadedDomDocument60.Create();
xmlElem := xmlDoc.createElement("Root");
Transform.SaveToXml(xmlElem);
SeriesTransform.LoadFromXml(xmlElem);
// Update data of the calculated series
CalcSeries.Transform.UpdateOutputVariable();
CalcSeries.Calculate();
End Sub UserProc;
See also: