IntVec: Array;
IntVec: Array;
The IntVec property determines the numeric array used to set, which variables are integer ones.
The length of the IntVec array must be equal to the number of variables.
If value of the IntVec array element is equal to 0, the corresponding variable is considered a real one, if it is not equal to 0, it is considered an integer one.
If the IntVec array is not defined, all variables are considered real ones.
NOTE. IntVec is used only if the Gurobi solver is used for calculation.
Executing the example requires the Gurobi solver installed on the user computer.
Add a link to the Stat system assembly.
Sub UserProc;
Var
QP: SmQuadraticProgramming;
i, j, Res, N: Integer;
Time: Double;
CF, Lb, Ub, Init: Array Of Double;
LinC1: Array Of Double;
H: Array Of Double;
Bound: ISlBoundaryRegion;
LCon1: ISlLinearConstraint;
intVec: Array[8] Of Integer;
Begin
QP := New SmQuadraticProgramming.Create;
N := 8;
CF := New Double[N];
Lb := New Double[N];
Ub := New Double[N];
LinC1 := New Double[N];
Init := New Double[N];
// Domain of definition
Lb[0] := -1; Ub[0] := 1;
Lb[1] := -2.1; Ub[1] := 2;
Lb[2] := -3.2; Ub[2] := 3;
Lb[3] := -4.3; Ub[3] := 4;
Lb[4] := -5.4; Ub[4] := 5;
Lb[5] := -6.5; Ub[5] := 6;
Lb[6] := -7.6; Ub[6] := 7;
Lb[7] := -8.7; Ub[7] := 8;
// Initial approximations
Init[0] := -1;
Init[1] := -2;
Init[2] := -3;
Init[3] := -4;
Init[4] := -5;
Init[5] := -6;
Init[6] := -7;
Init[7] := -8;
QP.InitialApproximation.AutoCreate := False;
QP.InitialApproximation.InitValues := Init;
// Criterion function
CF[0] := 7;
CF[1] := 6;
CF[2] := 5;
CF[3] := 4;
CF[4] := 3;
CF[5] := 2;
CF[6] := 1;
CF[7] := 0;
H := New Double[N, N];
H[0, 0] := 1.69; H[0, 1] := 1.00; H[0, 2] := 2.00; H[0, 3] := 3.00; H[0, 4] := 4.00; H[0, 5] := 5.00; H[0, 6] := 6.00; H[0, 7] := 7.00;
H[1, 0] := 1.00; H[1, 1] := 1.69; H[1, 2] := 1.00; H[1, 3] := 2.00; H[1, 4] := 3.00; H[1, 5] := 4.00; H[1, 6] := 5.00; H[1, 7] := 6.00;
H[2, 0] := 2.00; H[2, 1] := 1.00; H[2, 2] := 1.69; H[2, 3] := 1.00; H[2, 4] := 2.00; H[2, 5] := 3.00; H[2, 6] := 4.00; H[2, 7] := 5.00;
H[3, 0] := 3.00; H[3, 1] := 2.00; H[3, 2] := 1.00; H[3, 3] := 1.69; H[3, 4] := 1.00; H[3, 5] := 2.00; H[3, 6] := 3.00; H[3, 7] := 4.00;
H[4, 0] := 4.00; H[4, 1] := 3.00; H[4, 2] := 2.00; H[4, 3] := 1.00; H[4, 4] := 1.69; H[4, 5] := 1.00; H[4, 6] := 2.00; H[4, 7] := 3.00;
H[5, 0] := 5.00; H[5, 1] := 4.00; H[5, 2] := 3.00; H[5, 3] := 2.00; H[5, 4] := 1.00; H[5, 5] := 1.69; H[5, 6] := 1.00; H[5, 7] := 2.00;
H[6, 0] := 6.00; H[6, 1] := 5.00; H[6, 2] := 4.00; H[6, 3] := 3.00; H[6, 4] := 2.00; H[6, 5] := 1.00; H[6, 6] := 1.69; H[6, 7] := 1.00;
H[7, 0] := 7.00; H[7, 1] := 6.00; H[7, 2] := 5.00; H[7, 3] := 4.00; H[7, 4] := 3.00; H[7, 5] := 2.00; H[7, 6] := 1.00; H[7, 7] := 1.<font color="#008000">69</font><font color="#000000">;<br/> </font><font color="#008080">For</font><font color="#000000"> i := </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> N - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br/> </font><font color="#008080">For</font><font color="#000000"> j := </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> N - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br/> </font><font color="#008080">If</font><font color="#000000"> i <> j </font><font color="#008080">Then</font><font color="#000000"><br/> H[i, j] := </font><font color="#008000">0</font><font color="#000000">;<br/> H[j, i] := </font><font color="#008000">0</font><font color="#000000">;<br/> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">If</font><font color="#000000">;<br/> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br/> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br/> </font><font color="#008000">// Specify integer variables<br/> </font><font color="#000000"> IntVec[</font><font color="#008000">0</font><font color="#000000">] := </font><font color="#008000">0</font><font color="#000000">;<br/> IntVec[</font><font color="#008000">1</font><font color="#000000">] := </font><font color="#008000">1</font><font color="#000000">;<br/> IntVec[</font><font color="#008000">2</font><font color="#000000">] := </font><font color="#008000">0</font><font color="#000000">;<br/> IntVec[</font><font color="#008000">3</font><font color="#000000">] := </font><font color="#008000">1</font><font color="#000000">;<br/> IntVec[</font><font color="#008000">4</font><font color="#000000">] := </font><font color="#008000">0</font><font color="#000000">;<br/> IntVec[</font><font color="#008000">5</font><font color="#000000">] := </font><font color="#008000">1</font><font color="#000000">;<br/> IntVec[</font><font color="#008000">6</font><font color="#000000">] := </font><font color="#008000">0</font><font color="#000000">;<br/> IntVec[</font><font color="#008000">7</font><font color="#000000">] := </font><font color="#008000">1</font><font color="#000000">;<br/> </font><font color="#008000">//Criterion function<br/> </font><font color="#000000"> QP.CriterionFunction := CF;<br/> QP.QuadraticForm := H;<br/> QP.IntVec := IntVec;<br/> Bound := QP.Boundary;<br/> Bound.BoundaryLower := Lb; </font><font color="#008000">//Lower area limit <br/> </font><font color="#000000"> Bound.BoundaryUpper := Ub; </font><font color="#008000">//Upper area limit<br/> </font><font color="#000000"> LCon1 := QP.LinearConstraints.Add;<br/> LinC1[</font><font color="#008000">0</font><font color="#000000">] := -</font><font color="#008000">1</font><font color="#000000">; LinC1[</font><font color="#008000">1</font><font color="#000000">] := </font><font color="#008000">1</font><font color="#000000">;<br/> LCon1.Value := LinC1; </font><font color="#008000">// Linear constraint coefficient<br/> </font><font color="#000000"> LCon1.BoundaryLower := -</font><font color="#008000">1</font><font color="#000000">.</font>00; // Lower linear constraint
LCon1.BoundaryUpper := Double.PositiveInfInity; //Upper linear constraint
LinC1[0] := 0; LinC1[1] := 0;
LCon1 := QP.LinearConstraints.Add;
LinC1[1] := -1; LinC1[2] := 1;
LCon1.Value := LinC1; // Linear constraint coefficient
LCon1.BoundaryLower := -1.05; // Lower linear constraint
LCon1.BoundaryUpper := Double.PositiveInfInity; //Upper linear constraint
LinC1[1] := 0; LinC1[2] := 0;
LCon1 := QP.LinearConstraints.Add;
LinC1[2] := -1; LinC1[3] := 1;
LCon1.Value := LinC1; // Linear constraint coefficient
LCon1.BoundaryLower := -1.10; // Lower linear constraint
LCon1.BoundaryUpper := Double.PositiveInfInity; //Upper linear constraint
LinC1[2] := 0; LinC1[3] := 0;
LCon1 := QP.LinearConstraints.Add;
LinC1[3] := -1; LinC1[4] := 1;
LCon1.Value := LinC1; // Linear constraint coefficient
LCon1.BoundaryLower := -1.15; // Lower linear constraint
LCon1.BoundaryUpper := Double.PositiveInfInity; //Upper linear constraint
LinC1[3] := 0; LinC1[4] := 0;
LCon1 := QP.LinearConstraints.Add;
LinC1[4] := -1; LinC1[5] := 1;
LCon1.Value := LinC1; // Linear constraint coefficient
LCon1.BoundaryLower := -1.2; // Lower linear constraint
LCon1.BoundaryUpper := Double.PositiveInfInity; //Upper linear constraint
LinC1[4] := 0; LinC1[5] := 0;
LCon1 := QP.LinearConstraints.Add;
LinC1[5] := -1; LinC1[6] := 1;
LCon1.Value := LinC1; // Linear constraint coefficient
LCon1.BoundaryLower := -1.25; // Lower linear constraint
LCon1.BoundaryUpper := Double.PositiveInfInity; //Upper linear constraint
LinC1[5] := 0; LinC1[6] := 0;
LCon1 := QP.LinearConstraints.Add;
LinC1[6] := -1; LinC1[7] := 1;
LCon1.Value := LinC1; // Linear constraint coefficient
LCon1.BoundaryLower := -1.<font color="#008000">30</font><font color="#000000">; </font><font color="#008000">// Lower linear constraint<br/> </font><font color="#000000"> LCon1.BoundaryUpper := Double.PositiveInfInity; </font><font color="#008000">//Upper linear constraint<br/> </font><font color="#000000"> LinC1[</font><font color="#008000">6</font><font color="#000000">] := </font><font color="#008000">0</font><font color="#000000">; LinC1[</font><font color="#008000">7</font><font color="#000000">] := </font><font color="#008000">0</font><font color="#000000">;<br/> </font><font color="#008000">// Use Gurobi<br/> </font><font color="#000000"> QP.SolverType := QPSolverType.Grb;<br/> QP.ExtraSettings.DLLPath := </font><font color="#800000">"c:\gurobi752\win64\bin\gurobi75.dll"</font><font color="#000000">;<br/> </font><font color="#008000">// Execute calculation<br/> </font><font color="#000000"> Res := QP.Execute;<br/> Time := QP.PerformanceTime / </font><font color="#008000">1000</font><font color="#000000">;<br/> Debug.WriteLine(</font><font color="#800000">"Time[sec] = "</font><font color="#000000"> + Time.ToString);<br/> Debug.WriteLine(</font><font color="#800000">"RES = "</font><font color="#000000"> + Res.ToString);<br/> Debug.WriteLine(QP.Errors);<br/> </font><font color="#008080">If</font><font color="#000000"> res = </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">Then</font><font color="#000000"><br/> Debug.WriteLine(</font><font color="#800000">"== Criterion function value =="</font><font color="#000000">);<br/> Debug.WriteLine(QP.OptimalFunctionValue.ToString);<br/> Debug.WriteLine(</font><font color="#800000">"== Solution =="</font><font color="#000000">);<br/> Debug.Indent;<br/> </font><font color="#008080">For</font><font color="#000000"> i := </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> QP.Solution.Length - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br/> Debug.WriteLine(i.ToString + </font><font color="#800000">": "</font><font color="#000000"> + lb[i].ToString + </font><font color="#800000">" <= "</font><font color="#000000"> + QP.Solution[i].ToString + </font><font color="#800000">" <= "</font><font color="#000000"> + ub[i].ToString);<br/> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br/> Debug.Unindent;<br/> Debug.WriteLine(</font><font color="#800000">"== Linear constraints =="</font><font color="#000000">);<br/> Debug.Indent;<br/> </font><font color="#008080">For</font><font color="#000000"> i := </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> QP.LinearConstraints.Count - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br/> LCon1 := QP.LinearConstraints.Item(i);<br/> Debug.WriteLine(i.ToString + </font><font color="#800000">": "</font><font color="#000000"> + LCon1.BoundaryLower.ToString + </font><font color="#800000">" <= "</font><font color="#000000"> + LCon1.Result.ToString + </font><font color="#800000">" <= "</font><font color="#000000"> + LCon1.BoundaryUpper.ToString);<br/> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br/> Debug.Unindent;<br/> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">If</font><font color="#000000">;<br/> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000"> UserProc;</font>
Imports Prognoz.Platform.Interop.Stat;
Sub UserProc();
Var
QP: SmQuadraticProgramming = New SmQuadraticProgramming();
i, j, Res, N: Integer;
Time: Double;
CF, Lb, Ub, Init, LinC1: Array Of Double;
H: Array[8, 8] Of Double;
Sol: Array;
Bound: ISlBoundaryRegion;
LCon1: ISlLinearConstraint;
intVec: Array[8] Of Integer;
Begin
N := 8;
CF := New Double[N];
Lb := New Double[N];
Ub := New Double[N];
LinC1 := New Double[N];
Init := New Double[N];
// Domain of definition
Lb[0] := -1; Ub[0] := 1;
Lb[1] := -2.1; Ub[1] := 2;
Lb[2] := -3.2; Ub[2] := 3;
Lb[3] := -4.3; Ub[3] := 4;
Lb[4] := -5.4; Ub[4] := 5;
Lb[5] := -6.5; Ub[5] := 6;
Lb[6] := -7.6; Ub[6] := 7;
Lb[7] := -8.7; Ub[7] := 8;
// Initial approximations
Init[0] := -1;
Init[1] := -2;
Init[2] := -3;
Init[3] := -4;
Init[4] := -5;
Init[5] := -6;
Init[6] := -7;
Init[7] := -8;
QP.InitialApproximation.AutoCreate := False;
QP.InitialApproximation.InitValues := Init;
// Criterion function
CF[0] := 7;
CF[1] := 6;
CF[2] := 5;
CF[3] := 4;
CF[4] := 3;
CF[5] := 2;
CF[6] := 1;
CF[7] := 0;
H := New Double[N, N];
H[0, 0] := 1.69; H[0, 1] := 1.00; H[0, 2] := 2.00; H[0, 3] := 3.00; H[0, 4] := 4.00; H[0, 5] := 5.00; H[0, 6] := 6.00; H[0, 7] := 7.00;
H[1, 0] := 1.00; H[1, 1] := 1.69; H[1, 2] := 1.00; H[1, 3] := 2.00; H[1, 4] := 3.00; H[1, 5] := 4.00; H[1, 6] := 5.00; H[1, 7] := 6.00;
H[2, 0] := 2.00; H[2, 1] := 1.00; H[2, 2] := 1.69; H[2, 3] := 1.00; H[2, 4] := 2.00; H[2, 5] := 3.00; H[2, 6] := 4.00; H[2, 7] := 5.00;
H[3, 0] := 3.00; H[3, 1] := 2.00; H[3, 2] := 1.00; H[3, 3] := 1.69; H[3, 4] := 1.00; H[3, 5] := 2.00; H[3, 6] := 3.00; H[3, 7] := 4.00;
H[4, 0] := 4.00; H[4, 1] := 3.00; H[4, 2] := 2.00; H[4, 3] := 1.00; H[4, 4] := 1.69; H[4, 5] := 1.00; H[4, 6] := 2.00; H[4, 7] := 3.00;
H[5, 0] := 5.00; H[5, 1] := 4.00; H[5, 2] := 3.00; H[5, 3] := 2.00; H[5, 4] := 1.00; H[5, 5] := 1.69; H[5, 6] := 1.00; H[5, 7] := 2.00;
H[6, 0] := 6.00; H[6, 1] := 5.00; H[6, 2] := 4.00; H[6, 3] := 3.00; H[6, 4] := 2.00; H[6, 5] := 1.00; H[6, 6] := 1.69; H[6, 7] := 1.00;
H[7, 0] := 7.00; H[7, 1] := 6.00; H[7, 2] := 5.00; H[7, 3] := 4.00; H[7, 4] := 3.00; H[7, 5] := 2.00; H[7, 6] := 1.00; H[7, 7] := 1.<font color="#008000">69</font><font color="#000000">;<br/> </font><font color="#008080">For</font><font color="#000000"> i := </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> N - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br/> </font><font color="#008080">For</font><font color="#000000"> j := </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> N - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br/> </font><font color="#008080">If</font><font color="#000000"> i <> j </font><font color="#008080">Then</font><font color="#000000"><br/> H[i, j] := </font><font color="#008000">0</font><font color="#000000">;<br/> H[j, i] := </font><font color="#008000">0</font><font color="#000000">;<br/> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">If</font><font color="#000000">;<br/> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br/> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br/> </font><font color="#008000">// Specify integer variables<br/> </font><font color="#000000"> IntVec[</font><font color="#008000">0</font><font color="#000000">] := </font><font color="#008000">0</font><font color="#000000">;<br/> IntVec[</font><font color="#008000">1</font><font color="#000000">] := </font><font color="#008000">1</font><font color="#000000">;<br/> IntVec[</font><font color="#008000">2</font><font color="#000000">] := </font><font color="#008000">0</font><font color="#000000">;<br/> IntVec[</font><font color="#008000">3</font><font color="#000000">] := </font><font color="#008000">1</font><font color="#000000">;<br/> IntVec[</font><font color="#008000">4</font><font color="#000000">] := </font><font color="#008000">0</font><font color="#000000">;<br/> IntVec[</font><font color="#008000">5</font><font color="#000000">] := </font><font color="#008000">1</font><font color="#000000">;<br/> IntVec[</font><font color="#008000">6</font><font color="#000000">] := </font><font color="#008000">0</font><font color="#000000">;<br/> IntVec[</font><font color="#008000">7</font><font color="#000000">] := </font><font color="#008000">1</font><font color="#000000">;<br/> </font><font color="#008000">//Criterion function<br/> </font><font color="#000000"> QP.CriterionFunction := CF;<br/> QP.QuadraticForm := H;<br/> QP.IntVec := IntVec;<br/> Bound := QP.Boundary;<br/> Bound.BoundaryLower := Lb; </font><font color="#008000">//Lower area limit <br/> </font><font color="#000000"> Bound.BoundaryUpper := Ub; </font><font color="#008000">//Upper area limit<br/> </font><font color="#000000"> LCon1 := QP.LinearConstraints.Add();<br/> LinC1[</font><font color="#008000">0</font><font color="#000000">] := -</font><font color="#008000">1</font><font color="#000000">; LinC1[</font><font color="#008000">1</font><font color="#000000">] := </font><font color="#008000">1</font><font color="#000000">;<br/> LCon1.Value := LinC1; </font><font color="#008000">// Linear constraint coefficient<br/> </font><font color="#000000"> LCon1.BoundaryLower := -</font><font color="#008000">1</font><font color="#000000">.</font>00; // Lower linear constraint
LCon1.BoundaryUpper := Double.PositiveInfInity; //Upper linear constraint
LinC1[0] := 0; LinC1[1] := 0;
LCon1 := QP.LinearConstraints.Add();
LinC1[1] := -1; LinC1[2] := 1;
LCon1.Value := LinC1; // Linear constraint coefficient
LCon1.BoundaryLower := -1.05; // Lower linear constraint
LCon1.BoundaryUpper := Double.PositiveInfInity; /Upper linear constraint
LinC1[1] := 0; LinC1[2] := 0;
LCon1 := QP.LinearConstraints.Add();
LinC1[2] := -1; LinC1[3] := 1;
LCon1.Value := LinC1; // Linear constraint coefficient
LCon1.BoundaryLower := -1.10; // Lower linear constraint
LCon1.BoundaryUpper := Double.PositiveInfInity; //Upper linear constraint
LinC1[2] := 0; LinC1[3] := 0;
LCon1 := QP.LinearConstraints.Add();
LinC1[3] := -1; LinC1[4] := 1;
LCon1.Value := LinC1; // Linear constraint coefficient
LCon1.BoundaryLower := -1.15; // Lower linear constraint
LCon1.BoundaryUpper := Double.PositiveInfInity; //Upper linear constraint
LinC1[3] := 0; LinC1[4] := 0;
LCon1 := QP.LinearConstraints.Add();
LinC1[4] := -1; LinC1[5] := 1;
LCon1.Value := LinC1; // Linear constraint coefficient
LCon1.BoundaryLower := -1.2; // Lower linear constraint
LCon1.BoundaryUpper := Double.PositiveInfInity; //Upper linear constraint
LinC1[4] := 0; LinC1[5] := 0;
LCon1 := QP.LinearConstraints.Add();
LinC1[5] := -1; LinC1[6] := 1;
LCon1.Value := LinC1; // Linear constraint coefficient
LCon1.BoundaryLower := -1.25; // Lower linear constraint
LCon1.BoundaryUpper := Double.PositiveInfInity; //Upper linear constraint
LinC1[5] := 0; LinC1[6] := 0;
LCon1 := QP.LinearConstraints.Add();
LinC1[6] := -1; LinC1[7] := 1;
LCon1.Value := LinC1; // Linear constraint coefficient
LCon1.BoundaryLower := -1.<font color="#008000">30</font><font color="#000000">; </font><font color="#008000">// Lower linear constraint<br/> </font><font color="#000000"> LCon1.BoundaryUpper := Double.PositiveInfInity; </font><font color="#008000">//Upper linear constraint<br/> </font><font color="#000000"> LinC1[</font><font color="#008000">6</font><font color="#000000">] := </font><font color="#008000">0</font><font color="#000000">; LinC1[</font><font color="#008000">7</font><font color="#000000">] := </font><font color="#008000">0</font><font color="#000000">;<br/> </font><font color="#008000">// Use Gurobi<br/> </font><font color="#000000"> QP.SolverType := QPSolverType.qpstGrb;<br/> QP.ExtraSettings.DLLPath := </font><font color="#800000">"c:\gurobi752\win64\bin\gurobi75.dll"</font><font color="#000000">;<br/> </font><font color="#008000">// Execute calculation<br/> </font><font color="#000000"> Res := QP.Execute();<br/> Time := QP.PerformanceTime / </font><font color="#008000">1000</font><font color="#000000">;<br/> System.Diagnostics.Debug.WriteLine(</font><font color="#800000">"Time[sec] = "</font><font color="#000000"> + Time.ToString());<br/> System.Diagnostics.Debug.WriteLine(</font><font color="#800000">"RES = "</font><font color="#000000"> + Res.ToString());<br/> System.Diagnostics.Debug.WriteLine(QP.Errors);<br/> </font><font color="#008080">If</font><font color="#000000"> res = </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">Then</font><font color="#000000"><br/> System.Diagnostics.Debug.WriteLine(</font><font color="#800000">"== Criterion function value =="</font><font color="#000000">);<br/> System.Diagnostics.Debug.WriteLine(QP.OptimalFunctionValue.ToString());<br/> System.Diagnostics.Debug.WriteLine(</font><font color="#800000">"== Solution =="</font><font color="#000000">);<br/> System.Diagnostics.Debug.Indent();<br/> Sol := QP.Solution;<br/> </font><font color="#008080">For</font><font color="#000000"> i := </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> Sol.Length - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br/> System.Diagnostics.Debug.WriteLine(i.ToString() + </font><font color="#800000">": "</font><font color="#000000"> + lb[i].ToString() + </font><font color="#800000">" <= "</font><font color="#000000"> + Sol[i].ToString() + </font><font color="#800000">" <= "</font><font color="#000000"> + ub[i].ToString());<br/> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br/> System.Diagnostics.Debug.Unindent();<br/> System.Diagnostics.Debug.WriteLine(</font><font color="#800000">"== Linear constraints =="</font><font color="#000000">);<br/> System.Diagnostics.Debug.Indent();<br/> </font><font color="#008080">For</font><font color="#000000"> i := </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> QP.LinearConstraints.Count - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br/> LCon1 := QP.LinearConstraints.Item[i];<br/> System.Diagnostics.Debug.WriteLine(i.ToString() + </font><font color="#800000">": "</font><font color="#000000"> + LCon1.BoundaryLower.ToString() + </font><font color="#800000">" <= "</font><font color="#000000"> + LCon1.Result.ToString() + </font><font color="#800000">" <= "</font><font color="#000000"> + LCon1.BoundaryUpper.ToString());<br/> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br/> System.Diagnostics.Debug.Unindent();<br/> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">If</font><font color="#000000">;<br/> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000">;</font>
On executing the example, the quadratic programming task is calculated using the Gurobi solver.
The development environment console displays the following:
Criterion function value
Found solutions.
Linear constraints.
See also: