Tolerance: Double;
Tolerance: double;
The Tolerance property determines accuracy of solution.
The default value is 0.0001.
To execute the example, add a link to the Cp system assembly.
The example uses the MyCallBackCycle custom class. Implementation of this class is given in the example for ICallbackCycle.Execute.
Sub UserProc;
Var
TargetAdj: ICpTargetAdjustment;
T: Integer;
RetroX1, RetroX2, RetroU, RetroV: Array Of Double;
InitApproximation, ValuesI, ValuesJ: Array Of Double;
i, j: Integer;
VarsP: ITargetPhaseVariablesArray;
VrblP: ITargetPhaseVariable;
VarConstrs: IVarTargetConstraintsArray;
VarConstr: IVarTargetConstraint;
VarsC: ITargetControlVariablesArray;
VrblC: ITargetControlVariable;
Expls: INonLinearExplanatories;
Expl: INonLinearExplanatory;
Ser: Array[4] Of Double;
Constraints: ITargetConstraints;
Constraint: ITargetConstraint;
ConInfoArray: ITargetConstraintInfoArray;
ConInfo: ITargetConstraintInfo;
Res: ITargetResults;
Val: Double;
MyCallBackC: MyCallBackCycle;
Begin
TargetAdj := New TargetAdjustment.Create;
// Set period
T := 6;
// Create variables with retrospective
RetroX1 := New Double[T];
RetroX2 := New Double[T];
RetroU := New Double[T];
RetroV := New Double[T];
ValuesI := New Double[T];
ValuesJ := New Double[T];
// Create an array of initial approximations
InitApproximation := New Double[T];
// Set initial variable values
For i := 0 To T - 1 Do
RetroX1[i] := 0.8 + i / 5;
RetroX2[i] := 0.85 + i / 4;
RetroU[i] := 0.9 + i / 10;
RetroV[i] := 0.95 + i / 10;
ValuesI[i] := 0.6 + i / 8;
ValuesJ[i] := 0.7 + i / 6;
End For;
// Get phase variables
VarsP := TargetAdj.PhaseVariables;
// Add the x1 phase variable
VrblP := VarsP.Add("x1");
VrblP.Name := "x1";
// Set retrospective values
VrblP.Retrospective := RetroX1;
// Set order of variables
VrblP.CoefficientsOrder := "x1[t];x1[t-1]";
// Get constraints of phase variable
VarConstrs := VrblP.Constraints;
For i := 0 To T - 1 Do
// Create a new constraint
VarConstr := VarConstrs.Add;
// Set borders
VarConstr.LowerBound := -10 - i / 100;
VarConstr.UpperBound := 10 + i / 100;
// Determine current time point
VarConstr.TimeMoment := i;
End For;
// Set frequency equation
VrblP.FunctionExpression := "0.3 * x1[t-1] + 0.1 * x2[t-1] + u[t-1] * x1[t-1] *x2[t-1]";
// Add the x2 phase variable
VrblP := VarsP.Add("x2");
VrblP.Name := "x2";
VrblP.Retrospective := RetroX2;
VrblP.CoefficientsOrder := "x2[t];x2[t-1]";
VarConstrs := VrblP.Constraints;
For i := 0 To T - 1 Do
VarConstr := VarConstrs.Add;
VarConstr.LowerBound := -100-i;
VarConstr.UpperBound := 100+i;
VarConstr.TimeMoment := i;
End For;
VrblP.FunctionExpression := "(-0.2) * x1[t-1] + 0.4 *x2[t-1] + (x1[t-1] * x2[t-1])/(v[t]+1)";
// Get controlling variables
VarsC := TargetAdj.ControlVariables;
// Add the u controlling variable
VrblC := VarsC.Add("u");
VrblC.Name := "u";
// Set retrospective values
VrblC.Retrospective := RetroU;
// Set order of coefficients
VrblC.CoefficientsOrder := "u[t];u[t-1]";
// Set values of initial approximations
For i := 0 To T - 1 Do
InitApproximation[i] := 1.2 + (i + 1) / 100;
End For;
VrblC.InitApproximation := InitApproximation;
// Get constraints of controlling variable
VarConstrs := VrblC.Constraints;
For i := 0 To T - 1 Do
// Add a constraint
VarConstr := VarConstrs.Add;
// Set constraint borders
VarConstr.LowerBound := 1;
VarConstr.UpperBound := 2;
// Set current moment of time
VarConstr.TimeMoment := i;
End For;
// Add a controlling dimension v
VrblC := VarsC.Add("v");
VrblC.Name := "v";
VrblC.Retrospective := RetroV;
VrblC.CoefficientsOrder := "v[t];v[t-1]";
For i:=0 To T-1 Do
InitApproximation[i] := 1.5+ (i+1)/100;
End For;
VrblC.InitApproximation := InitApproximation;
VarConstrs := VrblC.Constraints;
For i := 0 To T - 1 Do
VarConstr := VarConstrs.Add;
VarConstr.LowerBound := 0.8;
VarConstr.UpperBound := 7;
VarConstr.TimeMoment := i;
End For;
// Get explanatory series
Expls := TargetAdj.Explanatories;
// Set controlling series i
Expl := Expls.Add;
Expl.VariableName := "i";
Expl.CoefficientsOrder := "i[t]";
Expl.Series := ValuesI;
// Set explanatory series j
Expl := Expls.Add;
Expl.VariableName := "j";
Expl.CoefficientsOrder := "j[t]";
Expl.Series := ValuesJ;
// Set target trajectory
ser[0] := 1;
ser[1] := 2;
ser[2] := 3;
ser[3] := 4;
TargetAdj.TargetTrajectory := Ser;
// Set target function
TargetAdj.CriterionFunction := "x1[t] + x2[t-1] - u[t] + i[t] + j[t]";
// Set number of iterations
TargetAdj.MaxIterationsCount := 25000;
// Set solution accuracy
TargetAdj.Tolerance := 0.00001;
// Get non-linear constraints of target function
Constraints := TargetAdj.Constraints;
// Add a non-linear constraint
Constraint := Constraints.Add;
// Set expression of non-linear constraint
Constraint.Expression := "v[t] + u[t] + x1[t]*0.001";
ConInfoArray := Constraint.Constraints;
For i := 0 To T - 1 Do
conInfo := ConInfoArray.Add;
conInfo.TimeMoment := i;
conInfo.LowerBound := -10.5555;
coninfo.UpperBound := 10.55555;
coninfo.LowerBoundFixed := False;
coninfo.UpperBoundFixed := False;
End For;
// Set problem type
TargetAdj.AutoSearchType := TargetAutoSearchType.MinError;
// Set number of cycles
TargetAdj.AutoAdjustMaxIter := 10;
// Set satisfactory tolerance
TargetAdj.AutoAdjustSatisfactoryTolerance := 1.<font color="#008000">01</font><font color="#000000">;<br/> </font><font color="#008000">// Set number of constraints deleted during one iteration<br/> </font><font color="#000000"> TargetAdj.AutoAdjustRemoveCount := </font><font color="#008000">2</font><font color="#000000">;<br/> </font><font color="#008000">// Set handler to calculate values for controlling variables<br/> </font><font color="#000000"> MyCallBackC := </font><font color="#008080">New</font><font color="#000000"> MyCallbackCycle.Create;<br/> TargetAdj.CallbackCycle := MyCallBackC;<br/> </font><font color="#008000">// Calculate<br/> </font><font color="#000000"> Res := TargetAdj.Evaluate(T) </font><font color="#008080">As</font><font color="#000000"> ITargetResults;<br/> </font><font color="#008000">// If calculation is without errors, then display results to console<br/> </font><font color="#000000"> </font><font color="#008080">If</font><font color="#000000"> res.Status = </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">Then</font><font color="#000000"><br/> </font><font color="#008000">// Display optimal value<br/> </font><font color="#000000"> Debug.WriteLine(</font><font color="#800000">"Optimal value:"</font><font color="#000000">);<br/> Debug.Indent;<br/> Debug.WriteLine(res.OptimalValue);<br/> Debug.Unindent;<br/> </font><font color="#008000">// Display values of controlling variables<br/> </font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000"> j := </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> VarsC.Count </font><font color="#008080">Do</font><font color="#000000"><br/> VrblC := VarsC.Item(j - </font><font color="#008000">1</font><font color="#000000">);<br/> Debug.WriteLine(</font><font color="#800000">"Values of controlling variable '"</font><font color="#000000"> + VrblC.Id + </font><font color="#800000">"':"</font><font color="#000000">);<br/> Debug.Indent;<br/> </font><font color="#008080">For</font><font color="#000000"> i := </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> T </font><font color="#008080">Do</font><font color="#000000"><br/> Val := Res.VarValues(VrblC.Id)[i - </font><font color="#008000">1</font><font color="#000000">];<br/> Debug.WriteLine(i.ToString + </font><font color="#800000">": "</font><font color="#000000"> + Val.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">For</font><font color="#000000">;<br/> </font><font color="#008000">// Display values of phase variables<br/> </font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000"> j := </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> VarsP.Count </font><font color="#008080">Do</font><font color="#000000"><br/> VrblP := VarsP.Item(j - </font><font color="#008000">1</font><font color="#000000">);<br/> Debug.WriteLine(</font><font color="#800000">"Values of phase variable '"</font><font color="#000000"> + VrblP.Id + </font><font color="#800000">"':"</font><font color="#000000">);<br/> Debug.Indent;<br/> </font><font color="#008080">For</font><font color="#000000"> i := </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> T </font><font color="#008080">Do</font><font color="#000000"><br/> Val := Res.VarValues(VrblP.Id)[i - </font><font color="#008000">1</font><font color="#000000">];<br/> Debug.WriteLine(i.ToString + </font><font color="#800000">": "</font><font color="#000000"> + Val.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">For</font><font color="#000000">;<br/> </font><font color="#008000">// Display progress of target function change during calculation<br/> </font><font color="#000000"> </font><font color="#008000">// of non-linear programming problem <br/> </font><font color="#000000"> Debug.WriteLine(</font><font color="#800000">"Progress of target function change during calculation"</font><font color="#000000"> +<br/> </font><font color="#800000">" of non-linear programming problem:"</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"> Res.ObjValByIter.Length - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br/> Debug.WriteLine(Res.ObjValByIter[i]);<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="#008000">// Display progress of target function change during<br/> </font><font color="#000000"> </font><font color="#008000">// consecutive weakening of borders<br/> </font><font color="#000000"> Debug.WriteLine(</font><font color="#800000">"Progress of target function change during"</font><font color="#000000"> +<br/> </font><font color="#800000">" consecutive weakening of borders:"</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"> Res.ObjValByAdjustIter.Length - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br/> Debug.WriteLine(Res.ObjValByAdjustIter[i]);<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="#008000">// Display optimal trajectory of target function<br/> </font><font color="#000000"> Debug.WriteLine(</font><font color="#800000">"Optimal trajectory of target function:"</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"> Res.CriterionFunctionTrajectory.Length - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br/> Debug.WriteLine(Res.CriterionFunctionTrajectory[i]);<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="#008000">// If calculation is finished with error, then display its text<br/> </font><font color="#000000"> </font><font color="#008080">Else</font><font color="#000000"><br/> Debug.WriteLine(res.ErrorMsg);<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.Cp;
…
Public Shared Sub Main(Params: StartParams);
Var
TargetAdj: ICpTargetAdjustment;
T: Integer;
RetroX1, RetroX2, RetroU, RetroV: Array Of Double;
InitApproximation, ValuesI, ValuesJ: Array Of Double;
i, j: Integer;
VarsP: ITargetPhaseVariablesArray;
VrblP: ITargetPhaseVariable;
VarConstrs: IVarTargetConstraintsArray;
VarConstr: IVarTargetConstraint;
VarsC: ITargetControlVariablesArray;
VrblC: ITargetControlVariable;
Expls: INonLinearExplanatories;
Expl: INonLinearExplanatory;
Ser: Array[4] Of Double;
Constraints: ITargetConstraints;
Constraint: ITargetConstraint;
ConInfoArray: ITargetConstraintInfoArray;
ConInfo: ITargetConstraintInfo;
Res: ITargetResults;
Val: Double;
MyCallBackC: MyCallBackCycle;
Begin
TargetAdj := New TargetAdjustment.Create();
// Set period
T := 6;
// Create variables with retrospective
RetroX1 := New Double[T];
RetroX2 := New Double[T];
RetroU := New Double[T];
RetroV := New Double[T];
ValuesI := New Double[T];
ValuesJ := New Double[T];
// Create an array of initial approximations
InitApproximation := New Double[T];
// Set initial variable values
For i := 0 To T - 1 Do
RetroX1[i] := 0.8 + i / 5;
RetroX2[i] := 0.85 + i / 4;
RetroU[i] := 0.9 + i / 10;
RetroV[i] := 0.95 + i / 10;
ValuesI[i] := 0.6 + i / 8;
ValuesJ[i] := 0.7 + i / 6;
End For;
// Get phase variables
VarsP := TargetAdj.PhaseVariables;
// Add the x1 phase variable
VrblP := VarsP.Add("x1");
VrblP.Name := "x1";
// Set retrospective values
VrblP.Retrospective := RetroX1;
// Set order of variables
VrblP.CoefficientsOrder := "x1[t];x1[t-1]";
// Get phase variable constraints
VarConstrs := VrblP.Constraints;
For i := 0 To T - 1 Do
// Create a new constraint
VarConstr := VarConstrs.Add();
// Set borders
VarConstr.LowerBound := -10 - i / 100;
VarConstr.UpperBound := 10 + i / 100;
// Specify the current moment of time
VarConstr.TimeMoment := i;
End For;
// Set frequency equation
VrblP.FunctionExpression := "0.3 * x1[t-1] + 0.1 * x2[t-1] + u[t-1] * x1[t-1] *x2[t-1]";
// Add phase variable x2
VrblP := VarsP.Add("x2");
VrblP.Name := "x2";
VrblP.Retrospective := RetroX2;
VrblP.CoefficientsOrder := "x2[t];x2[t-1]";
VarConstrs := VrblP.Constraints;
For i := 0 To T - 1 Do
VarConstr := VarConstrs.Add();
VarConstr.LowerBound := -100-i;
VarConstr.UpperBound := 100+i;
VarConstr.TimeMoment := i;
End For;
VrblP.FunctionExpression := "(-0.2) * x1[t-1] + 0.4 *x2[t-1] + (x1[t-1] * x2[t-1])/(v[t]+1)";
// Get controlling variables
VarsC := TargetAdj.ControlVariables;
// Add the u controlling variable
VrblC := VarsC.Add("u");
VrblC.Name := "u";
// Set retrospective values
VrblC.Retrospective := RetroU;
// Set order of coefficients
VrblC.CoefficientsOrder := "u[t];u[t-1]";
// Set values of initial approximations
For i := 0 To T - 1 Do
InitApproximation[i] := 1.2 + (i + 1) / 100;
End For;
VrblC.InitApproximation := InitApproximation;
// Get controlling variable constraints
VarConstrs := VrblC.Constraints;
For i := 0 To T - 1 Do
// Add a constraint
VarConstr := VarConstrs.Add();
// Set constraint borders
VarConstr.LowerBound := 1;
VarConstr.UpperBound := 2;
// Set the current moment of time
VarConstr.TimeMoment := i;
End For;
// Add controlling variable v
VrblC := VarsC.Add("v");
VrblC.Name := "v";
VrblC.Retrospective := RetroV;
VrblC.CoefficientsOrder := "v[t];v[t-1]";
For i:=0 To T-1 Do
InitApproximation[i] := 1.5+ (i+1)/100;
End For;
VrblC.InitApproximation := InitApproximation;
VarConstrs := VrblC.Constraints;
<font color="#008080">For</font> i := <font color="#008000">0</font> <font color="#008080">To</font> T - <font color="#008000">1</font> <font color="#008080">Do</font><br/> VarConstr := VarConstrs.Add();<br/> VarConstr.LowerBound := <font color="#008000">0</font>.<font color="#008000">8</font>;<br/> VarConstr.UpperBound := <font color="#008000">7</font>;<br/> VarConstr.TimeMoment := i;<br/> <font color="#008080">End</font> <font color="#008080">For</font>;<br/> <font color="#008000">// Get explanatory series<br/> </font> Expls := TargetAdj.Explanatories;<br/> <font color="#008000">// Set an explanatory series i<br/> </font> Expl := Expls.Add();<br/> Expl.VariableName := <font color="#800000">"i"</font>;<br/> Expl.CoefficientsOrder := <font color="#800000">"i[t]"</font>;<br/> Expl.Series := ValuesI;<br/> <font color="#008000">// Set an explanatory series j<br/> </font> Expl := Expls.Add();<br/> Expl.VariableName := <font color="#800000">"j"</font>;<br/> Expl.CoefficientsOrder := <font color="#800000">"j[t]"</font>;<br/> Expl.Series := ValuesJ;<br/> <font color="#008000">// Set criterion trajectory<br/> </font> ser[<font color="#008000">0</font>] := <font color="#008000">1</font>;<br/> ser[<font color="#008000">1</font>] := <font color="#008000">2</font>;<br/> ser[<font color="#008000">2</font>] := <font color="#008000">3</font>;<br/> ser[<font color="#008000">3</font>] := <font color="#008000">4</font>;<br/> TargetAdj.TargetTrajectory := Ser;<br/> <font color="#008000">// Set criterion function<br/> </font> TargetAdj.CriterionFunction := <font color="#800000">"x1[t] + x2[t-1] - u[t] + i[t] + j[t]"</font>;<br/> <font color="#008000">// Set number of iterations<br/> </font> TargetAdj.MaxIterationsCount := <font color="#008000">25000</font>;<br/> <font color="#008000">// Set accuracy of solution<br/> </font> TargetAdj.Tolerance := <font color="#008000">0</font>.<font color="#008000">00001</font>;<br/> <font color="#008000">// Get non-linear constraints of criterion function<br/> </font> Constraints := TargetAdj.Constraints;<br/> <font color="#008000">// Add non-linear constraint<br/> </font> Constraint := Constraints.Add();<br/> <font color="#008000">// Set non-linear constraint expression<br/> </font> Constraint.Expression := <font color="#800000">"v[t] + u[t] + x1[t]*0.001"</font>;<br/> ConInfoArray := Constraint.Constraints;<br/> <font color="#008080">For</font> i := <font color="#008000">0</font> <font color="#008080">To</font> T - <font color="#008000">1</font> <font color="#008080">Do</font><br/> conInfo := ConInfoArray.Add();<br/> conInfo.TimeMoment := i;<br/> conInfo.LowerBound := -<font color="#008000">10</font>.<font color="#008000">5555</font>;<br/> coninfo.UpperBound := <font color="#008000">10</font>.<font color="#008000">55555</font>;<br/> coninfo.LowerBoundFixed := <font color="#008080">False</font>;<br/> coninfo.UpperBoundFixed := <font color="#008080">False</font>;<br/> <font color="#008080">End</font> <font color="#008080">For</font>;<br/> <font color="#008000">// Set problem type<br/> </font> TargetAdj.AutoSearchType := TargetAutoSearchType.tastMinError;<br/> <font color="#008000">// Set number of cycles<br/> </font> TargetAdj.AutoAdjustMaxIter := <font color="#008000">10</font>;<br/> <font color="#008000">// Set satisfactory tolerance<br/> </font> TargetAdj.AutoAdjustSatisfactoryTolerance := <font color="#008000">1</font>.<font color="#008000">01</font>;<br/> <font color="#008000">// Set number of constraints removed in one iteration<br/> </font> TargetAdj.AutoAdjustRemoveCount := <font color="#008000">2</font>;<br/> <font color="#008000">// Set handler for calculating values of controlling variables<br/> </font> MyCallBackC := <font color="#008080">New</font> MyCallbackCycle.Create();<br/> TargetAdj.CallbackCycle := MyCallBackC;<br/> <font color="#008000">// Execute calculation<br/> </font> Res := TargetAdj.Evaluate(T) <font color="#008080">As</font> ITargetResults;<br/> <font color="#008000">// If calculation is completed without errors, output results to console<br/> </font> <font color="#008080">If</font> res.Status = <font color="#008000">0</font> <font color="#008080">Then</font><br/> <font color="#008000">// Output optimal value<br/> </font> System.Diagnostics.Debug.WriteLine(<font color="#800000">"Optimal value:"</font>);<br/> System.Diagnostics.Debug.Indent();<br/> <font color="#008080">For</font> i := <font color="#008000">0</font> <font color="#008080">To</font> res.ObjValByAdjustIter.Length - <font color="#008000">1</font> <font color="#008080">Do</font><br/> System.Diagnostics.Debug.WriteLine(res.ObjValByAdjustIter.GetValue(i));<br/> <font color="#008080">End</font> <font color="#008080">For</font>;<br/> System.Diagnostics.Debug.Unindent();<br/> <font color="#008000">// Output values of controlling variables<br/> </font> <font color="#008080">For</font> j := <font color="#008000">1</font> <font color="#008080">To</font> VarsC.Count <font color="#008080">Do</font><br/> VrblC := VarsC.Item[j - <font color="#008000">1</font>];<br/> System.Diagnostics.Debug.WriteLine(<font color="#800000">"Values of controlling variable '"</font> + VrblC.Id + <font color="#800000">"':"</font>);<br/> System.Diagnostics.Debug.Indent();<br/> <font color="#008080">For</font> i := <font color="#008000">1</font> <font color="#008080">To</font> T <font color="#008080">Do</font><br/> Val := Res.VarValues[VrblC.Id].GetValue(i - <font color="#008000">1</font>) <font color="#008080">As</font> double;<br/> System.Diagnostics.Debug.WriteLine(i.ToString() + <font color="#800000">": "</font> + Val.ToString());<br/> <font color="#008080">End</font> <font color="#008080">For</font>;<br/> System.Diagnostics.Debug.Unindent();<br/> <font color="#008080">End</font> <font color="#008080">For</font>;<br/> <font color="#008000">// Output values of phase variables<br/> </font> <font color="#008080">For</font> j := <font color="#008000">1</font> <font color="#008080">To</font> VarsP.Count <font color="#008080">Do</font><br/> VrblP := VarsP.Item[j - <font color="#008000">1</font>];<br/> System.Diagnostics.Debug.WriteLine(<font color="#800000">"Values of phase variable '"</font> + VrblP.Id + <font color="#800000">"':"</font>);<br/> System.Diagnostics.Debug.Indent();<br/> <font color="#008080">For</font> i := <font color="#008000">1</font> <font color="#008080">To</font> T <font color="#008080">Do</font><br/> Val := Res.VarValues[VrblP.Id].GetValue(i - <font color="#008000">1</font>) <font color="#008080">As</font> double;<br/> System.Diagnostics.Debug.WriteLine(i.ToString() + <font color="#800000">": "</font> + Val.ToString());<br/> <font color="#008080">End</font> <font color="#008080">For</font>;<br/> System.Diagnostics.Debug.Unindent();<br/> <font color="#008080">End</font> <font color="#008080">For</font>;<br/> <font color="#008000">// Output change progress of criterion function during solution of<br/> </font> <font color="#008000">// non-linear programming problem <br/> </font> System.Diagnostics.Debug.WriteLine(<font color="#800000">"Change progress of criterion function during solution of"</font> +<br/> <font color="#800000">" non-linear programming problem:"</font>);<br/> System.Diagnostics.Debug.Indent();<br/> <font color="#008080">For</font> i := <font color="#008000">0</font> <font color="#008080">To</font> Res.ObjValByIter.Length - <font color="#008000">1</font> <font color="#008080">Do</font><br/> System.Diagnostics.Debug.WriteLine(Res.ObjValByIter.GetValue(i));<br/> <font color="#008080">End</font> <font color="#008080">For</font>;<br/> System.Diagnostics.Debug.Unindent();<br/> <font color="#008000">// Output change progress of criterion function during <br/> </font> <font color="#008000">// sequential loosening of limits<br/> </font> System.Diagnostics.Debug.WriteLine(<font color="#800000">"Change progress of criterion function during"</font> +<br/> <font color="#800000">" sequential loosening of limits:"</font>);<br/> System.Diagnostics.Debug.Indent();<br/> <font color="#008080">For</font> i := <font color="#008000">0</font> <font color="#008080">To</font> Res.ObjValByAdjustIter.Length - <font color="#008000">1</font> <font color="#008080">Do</font><br/> System.Diagnostics.Debug.WriteLine(Res.ObjValByAdjustIter.GetValue(i));<br/> <font color="#008080">End</font> <font color="#008080">For</font>;<br/> System.Diagnostics.Debug.Unindent();<br/> <font color="#008000">// Output optimal trajectory of criterion function<br/> </font> System.Diagnostics.Debug.WriteLine(<font color="#800000">"Optimal trajectory of criterion function:"</font>);<br/> System.Diagnostics.Debug.Indent();<br/> <font color="#008080">For</font> i := <font color="#008000">0</font> <font color="#008080">To</font> Res.CriterionFunctionTrajectory.Length - <font color="#008000">1</font> <font color="#008080">Do</font><br/> System.Diagnostics.Debug.WriteLine(Res.CriterionFunctionTrajectory.GetValue(i));<br/> <font color="#008080">End</font> <font color="#008080">For</font>;<br/> System.Diagnostics.Debug.Unindent();<br/> <font color="#008000">// If calculation is completed with error, output its text<br/> </font> <font color="#008080">Else</font><br/> System.Diagnostics.Debug.WriteLine(res.ErrorMsg);<br/> <font color="#008080">End</font> <font color="#008080">If</font>;<br/> <font color="#008080">End</font> <font color="#008080">Sub</font>;
After executing the example optimization problem parameters are set, the problem is calculated, results are displayed in the console.
See also: