ISmBoxConstrainedOptimization.Solution

Syntax

Solution: Array;

Description

The Solution property returns the found solution.

Comments

To get the value of criterion function by iterations, use the ISmBoxConstrainedOptimization.ObjValByIter property.

Example

Add a link to the Stat system assembly.

Sub UserProc;
Var
    p1: SmBoxConstrainedOptimization;
    ub, lb, init: Array[3Of Double;
    res, i: Integer;
Begin
    p1 := New smboxconstrainedoptimization.Create;
    ub[0] := 5;  ub[1] := 2;  ub[2] := 1
    lb[0] := -1; lb[1] := -1; lb[2] := -1;
    // Definition area
    p1.Boundary.BoundaryUpper := ub;
    p1.Boundary.BoundaryLower := lb;
    // Coefficients order
    p1.CoefficientsOrder := "a;b;c";
    // Criterion function:
    p1.FunctionString := "a-4*b+2*c";
    // Initial approximations
    init[0]:=100; init[1]:=-50; init[2]:=800;
    p1.InitApproximation:=init;
    // Use of variables
    p1.UseDerivatives := False;
    // Maximum number of iterations and accuracy
    p1.MaxIteration := 500;
    p1.Tolerance := 0.00001;
    res := p1.Execute;
    If res = 0 Then
        Debug.WriteLine("=== Criterion function ===");
        Debug.Indent;
        Debug.WriteLine("CF = " + p1.FunctionString);
        Debug.WriteLine(lb[0].ToString + " <= a <= " + ub[0].ToString);
        Debug.WriteLine(lb[1].ToString + " <= b <= " + ub[1].ToString);
        Debug.WriteLine(lb[2].ToString + " <= c <= " + ub[2].ToString);
        Debug.WriteLine("Criterion function value: " + p1.OptimalFunctionValue.ToString);
        Debug.WriteLine("Criterion function values by iterations:");
        For i := 0 To p1.ObjValByIter.Length - 1 Do
            Debug.WriteLine(i.ToString + ". " + p1.ObjValByIter[i].ToString);
        End For;
        Debug.Unindent;
        Debug.WriteLine("=== Solution ===");
        Debug.Indent;
        For i := 0 To p1.Solution.Length - 1 Do
            Debug.WriteLine(i.ToString + ". " + p1.Solution[i].ToString);
        End For;
        Debug.Unindent;
        Debug.WriteLine("=== Criterion function gradient ===");
        Debug.Indent;
        For i := 0 To p1.FunctionGradient.Length - 1 Do
            Debug.WriteLine(i.ToString + ". " + p1.FunctionGradient[i].ToString);
        End For;
        Debug.Unindent;
        Debug.WriteLine("=== Actually used initial approximations ===");
        Debug.Indent;
        For i := 0 To p1.InitApproximationActual.Length - 1 Do
            Debug.WriteLine(i.ToString + ". " + p1.InitApproximationActual[i].ToString);
        End For;
        Debug.Unindent;
    Else
        Debug.WriteLine(p1.Errors);
    End If;
End Sub UserProc;

After executing the example the console window displays the following:

See also:

ISmBoxConstrainedOptimization