Status: Integer;
The Status property returns error code. If no error occurred, it returns 0.
The property is read-only.
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[2] Of 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;
// List of variable
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;
// List of variables
EqS := FPAS.Equations;
// Equation 1
Eq := EqS.Add;
// list of summands
AddendS := Eq.Addends;
//left part of equation
Addend := Addends.Add(Vars.FindById("x1"));
//variable coefficient
Addend.Coeff := 1;
//lag
Addend.Lag := 0;
//first summand
Addend := Addends.Add(Vars.FindById("x1"));
//variable coefficient
Addend.Coeff := 2;
//lag
Addend.Lag := 1;
//second summand
Addend := Addends.Add(Vars.FindById("x1"));
//variable coefficient
Addend.Coeff := 0.25 ;
//lag
Addend.Lag := -1;
// Equation 2
Eq := EqS.Add;
// list of summands
AddendS := Eq.Addends;
//left part of equation
Addend := Addends.Add(Vars.FindById("x2"));
//variable coefficient
Addend.Coeff := 1;
//lag
Addend.Lag := 0;
//first summand
Addend := Addends.Add(Vars.FindById("x1"));
//variable coefficient
Addend.Coeff := 12.6;
//lag
Addend.Lag := -1;
//second summand
Addend := Addends.Add(Vars.FindById("x2"));
//variable coefficient
Addend.Coeff := 26;
//lag
Addend.Lag := 1;
FPAS.Extremum:=ExtremumType.Maximum;
TimeInterval := 5;
Res := FPAS.Evaluate(TimeInterval) As ILinDecompResults;
Debug.WriteLine(Res.ErrorMsg + " (Code :" + Res.Status.ToString + ")");
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: