ILinDecompResults.VarValues

Syntax

VarValues(VarId: String): Array;

Parameters

VarId - variable identifier.

Description

The property is read-only.

The VarValues property returns array of calculated values of variable.

Example

Sub Main;

Var

FPAS: LinearDecomposition;

Vrbl: ILoVariable; //variable with retrospective

Addend: ILoAddend; //summand

Eq: ILoEquation; //equation

VarS: ILoVariables; //list of variables

AddendS: ILoAddends; //list of summands

EqS: ILoEquations; //list of equations

Res: ILinDecompResults;

Retro, Forestall: Array[2] Of double;

Trajectory: Array[5] Of double;

I,J: 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];

For i := 0 To 4 Do

Trajectory[i] := 2 + i;

End For;

Vars:= FPAS.Variables;

For I := 1 To 2 Do

s := "x" + i.ToString;

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.ControlVariable := True;

 

//EQUATIONS

EqS := FPAS.Equations;

 

// EQUATION #1

Eq := EqS.Add;

AddendS := Eq.Addends;

Addend := Addends.Add(Vars.FindById("x1")); //left side of equation

Addend.Coeff := 1;//variable held constant

Addend.Lag := 0;//lag

Addend := Addends.Add(Vars.FindById("x1")); //first summand

Addend.Coeff := 2;//variable held constant

Addend.Lag := 1;//lag

Addend := Addends.Add(Vars.FindById("x1"));//second summand

Addend.Coeff := 0.25 ;//variable held constant

Addend.Lag := -1;//lag

Addend := Addends.Add(Vars.FindById("U2")); //controlling variable

Addend.Coeff := 1; //variable held constant

Addend.Lag := 1; //lag

// EQUATIOn #2

Eq := EqS.Add;

AddendS := Eq.Addends;

Addend := Addends.Add(Vars.FindById("x2")); //left side of equation

Addend.Coeff := 1;//variable held constant

Addend.Lag := 0;//lag

Addend := Addends.Add(Vars.FindById("x1")); //first summand

Addend.Coeff := 12.6;//variable held constant

Addend.Lag := -1;//lag

Addend := Addends.Add(Vars.FindById("x2"));//second summand

Addend.Coeff := 26;//variable held constant

Addend.Lag := 1; //lag

 

FPAS.Extremum:=ExtremumType.Maximum;

TimeInterval := 5;

Res := FPAS.Evaluate(TimeInterval) As ILinDecompResults;

Debug.WriteLine(Res.ErrorMsg);

 

For j := 1 To Vars.Count Do

Vrbl := Vars.Item(j - 1);

If (Vrbl.ControlVariable = False) Then

s := s + Vrbl.Id + ",             ";

End If;

End For;

Debug.WriteLine(s);

 

For i := 1 To TimeInterval Do

s := "t=" + i.ToString + ",    ";

For j := 1 To Vars.Count Do

Vrbl := Vars.Item(j - 1);

If (Vrbl.ControlVariable = False) Then

Val := Res.VarValues(Vrbl.Id)[i - 1];

s := s + Val.ToString + ", ";

End If;

End For;

Debug.WriteLine(s);

End For;

 

End Sub Main;

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

See also:

ILinDecompResults