ILoVariable.InitApproximation

Syntax

InitApproximation: Array;

Description

The InitApproximation property determines an array of initial approximations for controlling variable.

Example

Add a link to the Cp system assembly.

Sub UserProc;
Var
    FPAS: LinearDecomposition;
    VarS: ILoVariables;
    Vrbl: ILoVariable;
    EqS: ILoEquations;  
    Eq: ILoEquation;
    AddendS: ILoAddends;
    Addend: ILoAddend;
    Res: ILinDecompResults;
    Retro, Forestall: Array[2Of Double;
    Trajectory, InitAppr: Array[5Of Double;
    I: Integer;
    TimeInterval: Integer;
    S: String;
Begin
    FPAS := New LinearDecomposition.Create;
    // VARIABLES
    Retro := New Double[2];
    Retro[0] := 1;
    Retro[1] := 2;
    Forestall := New Double[2];
    Forestall[0] := 3;
    Forestall[1] := 4;
    Trajectory := New Double[5];
    InitAppr := New Double[5];
    For i := 0 To 4 Do
        Trajectory[i] := 2 + i;
        InitAppr[i] := 2 * i;
    End For;
    // List of variables    
    Vars:= FPAS.Variables;
    For I := 1 To 2 Do
        s := "x" + i.ToString;
        // Variable with retrospective
        Vrbl:=Vars.Add(s);
        Vrbl.Retrospective := Retro;
        Vrbl.Forestall := Forestall;
    End For;
    // Controlling variable
    Vrbl := Vars.Add("U2");
    Vrbl.Name := "Control Variable";
    Vrbl.Retrospective := Retro;
    Vrbl.Forestall := Forestall;
    Vrbl.Trajectory := Trajectory;
    Vrbl.InitApproximation := InitAppr;
    Vrbl.ControlVariable := True;
    // List of equations
    EqS := FPAS.Equations;
    // Equation 1
    Eq := EqS.Add;
    // List of summands
    AddendS := Eq.Addends;
    Addend := Addends.Add(Vars.FindById("x1")); //left part of equation
    Addend.Coeff := 1;//variable coefficients
    Addend.Lag := 0;//lag
    Addend := Addends.Add(Vars.FindById("x1")); //first summand
    Addend.Coeff := 2;//variable coefficients
    Addend.Lag := 1;//lag
    Addend := Addends.Add(Vars.FindById("x1"));//second summand
    Addend.Coeff := 0.25 ;//variable coefficients
    Addend.Lag := -1;//lag
    Addend := Addends.Add(Vars.FindById("U2")); //controlling variable
    Addend.Coeff := 1//variable coefficient
    Addend.Lag := 1//lag
    // Equation 2
    Eq := EqS.Add;
    // List of summands
    AddendS := Eq.Addends;
    Addend := Addends.Add(Vars.FindById("x2")); //left part of equation
    Addend.Coeff := 1;//variable coefficients
    Addend.Lag := 0;//lag
    Addend := Addends.Add(Vars.FindById("x1")); //first summand
    Addend.Coeff := 12.6;//variable coefficients
    Addend.Lag := -1;//lag
    Addend := Addends.Add(Vars.FindById("x2"));//second summand
    Addend.Coeff := 26;//variable coefficients
    Addend.Lag := 1//lag
    FPAS.Extremum:=ExtremumType.Maximum;
    TimeInterval := 5;
    Res := FPAS.Evaluate(TimeInterval) As ILinDecompResults;
    Debug.WriteLine(Res.ErrorMsg);
End Sub UserProc;

After executing the example the linear system is calculated, the message with the errors found is displayed in the console window.

See also:

ILoVariable