AutoCreate: Boolean;
The AutoCreate property determines whether to create initial values automatically.
Available values:
True. Default value. Initial values will be created automatically.
False. Initial values must be set in the ILinearProgrammingInitApproximation.InitValues property.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
LP: SmLinearProgramming;
Bound: ISlBoundaryRegion;
LCon1, LCon2: ISlLinearConstraint;
i, N, Res: Integer;
d, OptVal: Double;
CF, Lb, Ub, LinC1, LinC2, InVal: Array[4] Of Double;
Sol: Array Of Double;
Begin
LP := New SmLinearProgramming.Create;
N := 4;
CF[0] := 5; Lb[0] := 0; Ub[0] := 5; LinC1[0] := 2; LinC2[0] := 3; InVal[0] := 0;
CF[1] := -7; Lb[1] := 0; Ub[1] := 10; LinC1[1] := 4; LinC2[1] := 3; InVal[1] := 0;
CF[2] := 2; Lb[2] := 0; Ub[2] := 5; LinC1[2] := 1; LinC2[2] := 0; InVal[2] := 0;
CF[3] := -2; Lb[3] := 0; Ub[3] := 5; LinC1[3] := 0; LinC2[3] := 2; InVal[3] := 0;
LP.InitialApproximation.AutoCreate := False;
LP.InitialApproximation.InitValues := InVal;
//Criterion function:
LP.CriterionFunction := CF;
Bound := LP.Boundary;
//Lower and upper area borders:
Bound.BoundaryLower := Lb;
Bound.BoundaryUpper := Ub;
//First linear constraint:
LCon1 := LP.LinearConstraints.Add;
//Linear constraint coefficients:
LCon1.Value := LinC1;
//Lower and upper linear constraints:
LCon1.BoundaryLower := -100;
LCon1.BoundaryUpper := 100;
//Second linear constraint:
LCon2 := LP.LinearConstraints.Add;
LCon2.Value := LinC2;
LCon2.BoundaryLower := -100;
LCon2.BoundaryUpper := 90;
Res := LP.Execute;
If Res <> 0 Then
Debug.WriteLine(LP.Errors);
Else
Debug.WriteLine("== Criterion function value ==");
OptVal := LP.OptimalFunctionValue;
Debug.WriteLine(OptVal.ToString);
Debug.WriteLine("== Solution ==");
Sol := LP.Solution;
For i := 0 To N - 1 Do
d := Sol[i];
Debug.WriteLine(i.ToString + " = " + d.ToString);
End For;
End If;
End Sub UserProc;
After executing the example the console window displays the found solution and criterion function value corresponding to this solution:
== Criterion function value ==
-80
== Solution ==
0 = 0
1 = 10
2 = 0
3 = 5
See also: