InitExpression: Integer;
The InitExpression method checks if entered variables and equations without executing statistical method are correct.
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.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
Eqs: ISmNonLinearEquations;
Funcs: Array[0..2] Of String;
inits: Array[0..2] Of 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
See also: