PowerI(Input: Variant; PowerValue: Variant): Variant;
PowerI(Input: object;
PowerValue: object;
Context: Prognoz.Platform.Interop.Fore.ForeRuntimeContext): object;
Input. Variable that sets the base of power.
PowerValue. Power exponent.
Context. Context. The parameter is used only in Fore.NET.
The PowerI method returns the result of raising variable points to the specified power. All variable points and the power must be integers.
Use the IModelling.Power method to raise points of the variable, containing not only integer values, to the power.
Executing the example requires that the repository contains a modeling container with the MS identifier. This container includes a model with the MODEL_D identifier that is calculated by method of determinate equation and containing more than one input variable. The first and the second input variables must contain only integer values.
Add links to the Metabase, Ms system assemblies.
Sub UserPowerI;
Var
Mb: IMetabase;
ModelSpace, ModelObj: IMetabaseObject;
Transf: IMsFormulaTransform;
Formula: IMsFormula;
Model: IMsModel;
Determ: IMsDeterministicTransform;
Term: IMsFormulaTerm;
Inp_1, Inp_2: String;
Expr: IExpression;
Begin
Mb := MetabaseClass.Active;
// Get the model
ModelSpace := Mb.ItemById("MS").Bind;
ModelObj := Mb.ItemByIdNamespace("MODEL_D", ModelSpace.Key).Edit;
Model := ModelObj As IMsModel;
Transf := Model.Transform;
Formula := Transf.FormulaItem(0);
Determ := Formula.Method As IMsDeterministicTransform;
// Get the first input variable
Term := Determ.Operands.Item(0);
Inp_1 := Term.TermToInnerText;
// Get the second input variable
Term := Determ.Operands.Item(1);
Inp_2 := Term.TermToInnerText;
// Set expression for calculation
Expr := Determ.Expression;
Expr.References := "Ms";
Expr.AsString := "PowerI(" + Inp_1 + "," + Inp_2 + ")";
If Expr.Valid
Then ModelObj.Save;
Else Debug.WriteLine(Model is not saved: error in formula);
End If;
End Sub UserPowerI;
After executing the example the model raises the first input variable points to power set by the points of the second input variable.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
Mb: IMetabase;
ModelSpace, ModelObj: IMetabaseObject;
Transf: IMsFormulaTransform;
Formula: IMsFormula;
Model: IMsModel;
Determ: IMsDeterministicTransform;
Term: IMsFormulaTerm;
Inp_1, Inp_2: String;
Expr: IExpression;
Begin
Mb := Params.Metabase;
// Get the model
ModelSpace := Mb.ItemById["MS"].Bind();
ModelObj := Mb.ItemByIdNamespace["MODEL_D", ModelSpace.Key].Edit();
Model := ModelObj As IMsModel;
Transf := Model.Transform;
Formula := Transf.FormulaItem[0];
Determ := Formula.Method As IMsDeterministicTransform;
// Get the first input variable
Term := Determ.Operands.Item[0];
Inp_1 := Term.TermToInnerText();
// Get the second input variable
Term := Determ.Operands.Item[1];
Inp_2 := Term.TermToInnerText();
// Set expression for calculation
Expr := Determ.Expression;
Expr.References := "Ms";
Expr.AsString := "PowerI(" + Inp_1 + "," + Inp_2 + ")";
If Expr.Valid
Then ModelObj.Save();
Else System.Diagnostics.Debug.WriteLine("Model is not saved: error in formulaquot;);
End If;
End Sub;
Expression 1:
PowerI({Brazil|BCA},{Canada|BCA})
Result: Brazil|BCA factor observations are raised to the power, that is set by the observations of the Canada|BCA factor. If any of time series contains the real values, an error appears.
Use: it can be used in formulas of calculated series of time series database and model formulas of modeling container that is a child of the time series database.
Expression 2:
PowerI(X1,2)
Result: all X1 factor points are raised to the second power.
Use: it can be used in model formulas of modeling container.
Expression 3:
PowerI(2,4)
Result: 24=16.
Use: it can be used in formulas of calculated series of time series database and modeling container models.
See also:
IModelling | Time Series Database: Calculator | Modeling Container: Editing Regressor or Formula