ISlLinearConstraint.Result

Fore Syntax

Result: Double;

Fore.NET Syntax

Result: double;

Description

The Result property returns the value of linear constraints.

Comments

To determine value of linear constraint coefficients, use the ISlLinearConstraint.Value property.

Fore Example

Add a link to the Stat system assembly.

Sub UserProc;
Var
    LP: SmLinearProgramming;
    Bound: ISlBoundaryRegion;
    LCon1, LCon2: ISlLinearConstraint;
    CF, Lb, Ub, LinC1, LinC2: Array[4Of Double;
    i, Res: Integer;
    OptVal: Double;
    Sol: Array Of Double;
Begin
    LP := New SmLinearProgramming.Create;
    CF[0] := 5;  Lb[0] := 0; Ub[0] := 5;  LinC1[0] := 2; LinC2[0] := 3;
    CF[1] := -7; Lb[1] := 0; Ub[1] := 10; LinC1[1] := 4; LinC2[1] := 3;
    CF[2] := 2;  Lb[2] := 0; Ub[2] := 5;  LinC1[2] := 1; LinC2[2] := 0;
    CF[3] := -2; Lb[3] := 0; Ub[3] := 5;  LinC1[3] := 0; LinC2[3] := 2;
    LP.InitialApproximation.AutoCreate := True;
    //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;
    LCon1.Value := LinC1;
    LCon1.BoundaryLower := -100;
    LCon1.BoundaryUpper := 100;
    // Second linear constraint
    LCon2 := LP.LinearConstraints.Add;
    LCon2.Value := LinC2;
    LCon2.BoundaryLower := -100;
    LCon2.BoundaryUpper := 90;
    // Calculate model
    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 Sol.Length - 1 Do
                Debug.WriteLine(i.ToString + " = " + Sol[i].ToString);
            End For;
            Debug.WriteLine("== Linear constraint values ==");
            Debug.WriteLine("1. " + LCon1.Result.ToString);
            Debug.WriteLine("2. " + LCon2.Result.ToString);
    End If;
End Sub UserProc;

After executing the example the console window displays the solution, criterion function values corresponding to the found solution, and linear constraint values.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Stat;

Public Shared Sub Main(Params: StartParams);
Var
    LP: SmLinearProgramming;
    Bound: ISlBoundaryRegion;
    LCon1, LCon2: ISlLinearConstraint;
    CF, Lb, Ub, LinC1, LinC2: Array[4Of Double;
    i, Res: Integer;
    OptVal: Double;
    Sol: System.Array;
Begin
    LP := New SmLinearProgramming.Create();
    CF[0] := 5;  Lb[0] := 0; Ub[0] := 5;  LinC1[0] := 2; LinC2[0] := 3;
    CF[1] := -7; Lb[1] := 0; Ub[1] := 10; LinC1[1] := 4; LinC2[1] := 3;
    CF[2] := 2;  Lb[2] := 0; Ub[2] := 5;  LinC1[2] := 1; LinC2[2] := 0;
    CF[3] := -2; Lb[3] := 0; Ub[3] := 5;  LinC1[3] := 0; LinC2[3] := 2;
    LP.InitialApproximation.AutoCreate := True;
    //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();
    LCon1.Value := LinC1;
    LCon1.BoundaryLower := -100;
    LCon1.BoundaryUpper := 100;
    // Second linear constraint
    LCon2 := LP.LinearConstraints.Add();
    LCon2.Value := LinC2;
    LCon2.BoundaryLower := -100;
    LCon2.BoundaryUpper := 90;
    // Calculate model
    Res := LP.Execute();
    If Res <> 0 Then
        System.Diagnostics.Debug.WriteLine(LP.Errors);
        Else
            System.Diagnostics.Debug.WriteLine("== Criterion function value ==");
            OptVal := LP.OptimalFunctionValue;
            System.Diagnostics.Debug.WriteLine(OptVal.ToString());
            System.Diagnostics.Debug.WriteLine("== Solution ==");
            Sol := LP.Solution;
            For i := 0 To Sol.Length - 1 Do
                System.Diagnostics.Debug.WriteLine(i.ToString() + " = " + Sol[i].ToString());
            End For;
            System.Diagnostics.Debug.WriteLine("== Criterion function values ==");
            System.Diagnostics.Debug.WriteLine("1. " + LCon1.Result.ToString());
            System.Diagnostics.Debug.WriteLine("2. " + LCon2.Result.ToString());
    End If;
End Sub;

See also:

ISlLinearConstraint