ISmNonLinearEquations.CalcInitExpressionMode

Fore Syntax

CalcInitExpressionMode: CalcInitExpressionType;

Fore.NET Syntax

CalcInitExpressionMode: Prognoz.Platform.Interop.Stat.CalcInitExpressionType;

Description

The CalcInitExpressionMode property determines the mode of defining initial values of the target variables.

Comments

If CalcInitExpressionMode = CalcInitExpressionType.Manual, values of initial variables are selected manually using the ISmNonLinearEquations.InitApproximation 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;
    res: Integer;
    Sub Print(Data: Array Of Double);
    Var
        i: Integer;
        CI: ICultureInfo;
    Begin
        CI := CultureInfo.Current;
        Debug.WriteLine("---Begin---");
        For i := 0 To Data.Length - 1 Do
            If Double.IsNan(Data[i]) Then
                Debug.WriteLine("---empty---");
            Else
                Debug.WriteLine(i.ToString + ", " + CI.FormatDoublePrec(Data[i], 4));
            End If;
        End For;
        Debug.WriteLine("---End---");
    End Sub Print;
Begin
    Eqs := New SmNonLinearEquations.Create As ISmNonLinearEquations;
    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;X3";
    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;
    res := Eqs.Execute;
    If res <> 0 Then
        Debug.WriteLine(Eqs.Errors);
    Else
        Print(Eqs.Solution);
    End If;
End Sub UserProc;

After executing the example the console window displays a solution for a system of non-linear equations.

Fore.NET 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;
    res: Integer;
    Solution: Array Of Double;
Begin
    Eqs := New SmNonLinearEquations.Create() As ISmNonLinearEquations;
    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;X3";
    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;
    res := Eqs.Execute();
    If res <> 0 Then
        System.Diagnostics.Debug.WriteLine(Eqs.Errors);
    Else
        Solution := Eqs.Solution As Array Of Double;
        Print(Solution);
    End If;
End Sub;

Public Shared Sub Print(Data: Array Of Double);
    Var
        i: Integer;
    Begin
        System.Diagnostics.Debug.WriteLine("---Begin---");
        For i := 0 To Data.Length - 1 Do
            If Double.IsNan(Data[i]) Then
                System.Diagnostics.Debug.WriteLine("---empty---");
            Else
                System.Diagnostics.Debug.WriteLine(i.ToString() + ", " + Data[i]);
            End If;
        End For;
        System.Diagnostics.Debug.WriteLine("---End---");
    End Sub Print;

After executing the example the console window displays a solution for a system of non-linear equations.

See also:

ISmNonLinearEquations