ISmNonLinearEquations.InitExpression

Fore Syntax

InitExpression: Integer;

Fore.NET Syntax

InitExpression(): integer;

Description

The InitExpression method checks if entered variables and equations without executing statistical method are correct.

Comments

If input parameters are set correctly, the 0 value is returned, otherwise error code is returned, which can be seen by means of the IStatMethod.ErrorByStatus property.

Fore Example

To execute the example, add a link to the Stat system assembly.

Sub UserProc;
Var
    Eqs: ISmNonLinearEquations;
    Funcs: Array[0..2Of String;
    inits: Array[0..2Of Double;
Begin
    Eqs := New SmNonLinearEquations.Create;
    funcs[0] := "X1-22+0.5*X2-X3";
    funcs[1] := "X2-26.5+2*X1+0.5*X3";
    funcs[2] := "X3+9-X1+6*X2";
    Eqs.Functions := Funcs;
    Eqs.CoefficientsOrder := "X1;X2";
    Eqs.CalcInitExpressionMode := CalcInitExpressionType.Manual;
    inits[0] := 10//x1
    inits[1] := 7//x2
    inits[2] := -1//x3
    Eqs.InitApproximation := inits;
    Eqs.MethodType := NonLinearEquationsType.MinErrorGaussNewtonMethod;
    Eqs.Tolerance := 0.0001;
    Debug.WriteLine("Error code: " + Eqs.InitExpression.ToString);
    Debug.WriteLine(Eqs.ErrorByStatus(Eqs.InitExpression));
End Sub UserProc;

After executing the example the console window displays error code and text:

Error code: 102

Error 102: The number of initial approximations is not equal to the number of coefficients

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Stat;

Public Shared Sub Main(Params: StartParams);
Var
    Eqs: ISmNonLinearEquations;
    Funcs: Array[0..2Of String;
    inits: Array[0..2Of Double;
    Solution: System.Array;
Begin
    Eqs := New SmNonLinearEquations.Create();
    funcs[0] := "X1-22+0.5*X2-X3";
    funcs[1] := "X2-26.5+2*X1+0.5*X3";
    funcs[2] := "X3+9-X1+6*X2";
    Eqs.Functions := Funcs;
    Eqs.CoefficientsOrder := "X1;X2";
    Eqs.CalcInitExpressionMode := CalcInitExpressionType.cietManual;
    inits[0] := 10//x1
    inits[1] := 7//x2
    inits[2] := -1//x3
    Eqs.InitApproximation := inits;
    Eqs.MethodType := NonLinearEquationsType.nletMinErrorGaussNewtonMethod;
    Eqs.Tolerance := 0.0001;
    System.Diagnostics.Debug.WriteLine("Error code: " + Eqs.InitExpression().ToString());
    System.Diagnostics.Debug.WriteLine(Eqs.ErrorByStatus[Eqs.InitExpression()]);
End Sub;

See also:

ISmNonLinearEquations