PerformanceInfo: IPerformanceInfo;
The PerformanceInfo property returns information about executed optimization.
To determine parameters of linear constraints, use the ISmQuadraticProgramming.LinearConstraints property.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
QP: SmQuadraticProgramming;
i, j, Res, N: Integer;
d, time: double;
CF, Lb, Ub, init: Array Of Double;
LinC1: Array Of Double;
H, A: Array Of Double;
Bound: ISlBoundaryRegion;
LinCons: ISlLinearConstraints;
LCon1: ISlLinearConstraint;
InitP, Sol, BoundL, PerformanceObj, PerformancePoint: Array Of Double;
Begin
QP := New SmQuadraticProgramming.Create;
N := 7;
CF := New Double[N];
Lb := New Double[N];
Ub := New Double[N];
LinC1 := New Double[N];
init := New double[N];
// Definition area
Lb[0] := -0.01; Ub[0] := 0.01;
Lb[1] := -0.10; Ub[1] := 0.15;
Lb[2] := -0.01; Ub[2] := 0.03;
Lb[3] := -0.04; Ub[3] := 0.02;
Lb[4] := -0.10; Ub[4] := 0.05;
Lb[5] := -0.01; Ub[5] := double.PositiveInfinity;
Lb[6] := -0.01; Ub[6] := Double.PositiveInfinity;
// Initial approximations
init[0] := -0.01;
init[1] := -0.03;
init[2] := 0.0;
init[3] := -0.01;
init[4] := -0.1;
init[5] := 0.02;
init[6] := 0.01;
QP.InitialApproximation.AutoCreate := False;
QP.InitialApproximation.InitValues := init;
// Criterion function
CF[0] := -0.02;
CF[1] := -0.2;
CF[2] := -0.2;
CF[3] := -0.2;
CF[4] := -0.2;
CF[5] := 0.04;
CF[6] := 0.04;
// Area borders
Bound := QP.Boundary;
// Lower area border
Bound.BoundaryLower := Lb;
// Upper area border
Bound.BoundaryUpper := Ub;
// Linear constraint coefficient
LCon1 := QP.LinearConstraints.Add;
For i := 0 To N - 1 Do
LinC1[i] := A[0, i];
End For;
LCon1.Value := LinC1;
// Lower linear constraint
LCon1.BoundaryLower := -0.13;
// Upper linear constraint
LCon1.BoundaryUpper := -0.13;
// Linear constraint coefficient
LCon1 := QP.LinearConstraints.Add;
For i := 0 To N - 1 Do
LinC1[i] := A[1,i];
End For;
LCon1.Value := LinC1;
// Lower linear constraint
LCon1.BoundaryLower := double.NegativeInfinity;
// Upper linear constraint
LCon1.BoundaryUpper := -0.0049;
// Linear constraint coefficient
LCon1 := QP.LinearConstraints.Add;
For i := 0 To N - 1 Do
LinC1[i] := A[2, i];
End For;
LCon1.Value := LinC1;
If res = 0 Then
Debug.WriteLine("== Criterion function value ==");
Debug.WriteLine(QP.OptimalFunctionValue.ToString);
Debug.WriteLine("Number of criterion function calls: "
+ qp.PerformanceInfo.ObjFunCalls.ToString);
Debug.WriteLine("Number of constraints calls: "
+ qp.PerformanceInfo.ConstraintsCalls.ToString);
Debug.WriteLine("Actual number of iterations: "
+ qp.PerformanceInfo.Iterations.ToString);
Debug.WriteLine("== Solution ==");
Sol := QP.Solution;
For i := 0 To Sol.Length - 1 Do
Debug.WriteLine(i.ToString + ": " + Sol[i].ToString);
End For;
Debug.WriteLine("== Common constraints: ==");
d := 0;
BoundL := Bound.LagrangeMultiplier;
For i := 0 To N - 1 Do //
d := Sol[i];
Debug.WriteLine(i.ToString + ": ");
Debug.WriteLine(Lb[i].ToString + "<=" + d.ToString +
"<= " + Ub[i].ToString);
Debug.WriteLine("Lagrange multiplier: " + BoundL[i].ToString);
Debug.WriteLine(" ");
End For;
Debug.WriteLine(" ");
Debug.WriteLine("== Linear constraints ==");
LinCons := QP.LinearConstraints;
For i := 0 To LinCons.Count - 1 Do
LCon1 := LinCons.Item(i);
Debug.WriteLine(i.ToString + ": " + LCon1.BoundaryLower.ToString + " <= "
+ LCon1.Result.ToString + " <= " + LCon1.BoundaryUpper.ToString);
Debug.WriteLine("Lagrange multiplier: " + LCon1.LagrangeMultiplier.ToString);
Debug.WriteLine(" ");
End For;
End If;
Debug.WriteLine("== Initial approximation ==");
PerformancePoint := QP.PerformanceInfo.InitFeasiblePoint;
For i := 0 To PerformancePoint.Length - 1 Do
Debug.WriteLine(i.ToString + ": " + PerformancePoint[i].ToString);
End For;
End Sub UserProc;
After executing the example the console window displays:
If there are any calculation errors.
Optimal and reference value.
Information about executed optimization.
Criterion function values.
Constraints and Lagrange multipliers.
See also: