ISmQuadraticProgramming.CriterionFunction

Syntax

CriterionFunction: Array;

Description

The CriterionFunction property determines the linear part of the criterion function.

Comments

Indexing of array of coefficients of criterion function must start with zero.

Quadratic part of the criterion function is determined by the ISmQuadraticProgramming.QuadraticForm property.

Example

Add a link to the Stat system assembly.

Sub UserProc;
Var
    QP: SmQuadraticProgramming;
    i, Res: Integer;
    CF, Lb, Ub, LinC1, LinC2, LinC3, init: Array[3Of Double;
    H: Array[33Of Double;
    Bound: ISlBoundaryRegion;
    LCon1, LCon2, LCon3: ISlLinearConstraint;
Begin
    QP := New SmQuadraticProgramming.Create;
    // Set initial approximations
    init[0] := 1; init[1] := 1;
    QP.InitialApproximation.AutoCreate := False;
    QP.InitialApproximation.InitValues := init;
    // Set linear part of criterion function
    CF[0] := 1; CF[1] := 1; CF[2] := -1;
    QP.CriterionFunction := CF;
    //Set quadratic part of criterion function
    H[00] := -2; H[01] := 2; H[02] := 0;
    H[10] := 2; H[11] := -2; H[12] := 0;
    H[20] := 0; H[21] := 0; H[22] := -2;
    QP.QuadraticForm := H;
    // Set definition area
    Lb[0] := 0; Lb[1] := 0; Lb[2] := 0;
    Ub[0] := 1; Ub[1] := 1; Ub[2] := 1;
    Bound := QP.Boundary;
    // Set area borders
    Bound.BoundaryLower := Lb;
    Bound.BoundaryUpper := Ub;
    // Set first coefficient of linear constraint
    LinC1[0] := 1; LinC1[1] := 1; LinC1[2] := 1;
    LCon1 := QP.LinearConstraints.Add;
    LCon1.Value := LinC1;
    // Set borders of first coefficient of linear constraint
    LCon1.BoundaryLower := 1;
    LCon1.BoundaryUpper := Double.PositiveInfinity;
    // Set second coefficient of linear constraint
    LinC2[0] := 2; LinC2[1] := 1; LinC2[2] := -1;
    LCon2 := QP.LinearConstraints.Add;
    LCon2.Value := LinC2;
    // Set borders of second coefficient of linear constraint
    LCon2.BoundaryLower := -1;
    LCon2.BoundaryUpper := Double.PositiveInfinity;
    // Set third coefficient of linear constraint
    LinC3[0] := 1; LinC3[1] := -1; LinC3[2] := 1;
    LCon3 := QP.LinearConstraints.Add;
    LCon3.Value := LinC3;
    // Set borders of third coefficient of linear constraint
    LCon3.BoundaryLower := 0;
    LCon3.BoundaryUpper := 0;
    // Run calculation and show results
    Res := QP.Execute;
    If res = 0 Then
        Debug.WriteLine("== Criterion function value ==");
        Debug.WriteLine(QP.OptimalFunctionValue.ToString);
        Debug.WriteLine("== Solution ==");
        For i := 0 To QP.Solution.Length - 1 Do
            Debug.WriteLine(i.ToString + ": " + QP.Solution[i].ToString);
        End For;
    End If;
End Sub UserProc;

After executing the example the console window displays the results of quadratic programming problem calculation.

See also

ISmQuadraticProgramming