ISmNonLinearOptimization.ExecuteFromMPI

Syntax

ExecuteFromMPI(Path: String; NumberOfVariables: Integer): Integer;

Parameters

Path. Path to MPI file containing a LINDO problem.

NumberOfVariables. Number of problem variables.

Description

The ExecuteFromMPI method performs non-linear optimization of problem from the specified file by means of LINDO.

Comments

All problem parameters are passed by means of the specified MPI file.

For correct calculation, it is required to specify path to LINDO library and license in the ISmNonLinearOptimization.LindoSettings property.

NOTE. Install the LINDO module to use it. For details on the LINDO module and terms of its use see the site www.lindo.com.

To get file, to which LINDO problem is unloaded, use the ILindoSettings.MPIPath property.

Example

Executing the example requires the C:\Problem.mpi file with a LINDO problem in the file system.

Add a link to the Stat system assembly.

Sub UserProc;
Var
    nlo: ISmNonLinearOptimization;
    LindoSettings: ILindoSettings;
    i, res: Integer;
    Warnings: Array Of String;
    OptVal: Double;
Begin
    // Create an object for solving optimization problem
    nlo := New SmNonLinearOptimization.Create;
    // Specify that problem will be solved by means of LINDO module
    nlo.SolverType := NLOSolverType.Lindo;
    // Get module parameters
    LindoSettings := nlo.LindoSettings;
    // Specify paths to library and license for LINDO
    LindoSettings.DLLPath := "c:\Lindoapi\bin\win32\lindo8_0.dll";
    LindoSettings.LicensePath := "c:\Lindoapi\license\lndapi80.lic";
    // Specify file, from which problem is loaded, and perform calculation
    res := nlo.ExecuteFromMPI("c:\Problem.mpi"4);
    If (res <> 0Or (LindoSettings.nErrorCode <> 0Then
        Debug.WriteLine(nlo.Errors);
        Debug.WriteLine("LINDO error code: " + LindoSettings.nErrorCode.ToString);
        Debug.WriteLine("LINDO error text: " + LindoSettings.MessageString);
    Else
        // Get warnings occurred on calculation and display them
        Warnings := LindoSettings.Warnings;
        For i := 0 To Warnings.Length - 1 Do
            Debug.WriteLine("Warning: " + Warnings[i]);
        End For;
        // Display calculation results   
        Debug.WriteLine("== Criterion function value ==");
        OptVal := nlo.OptimalFunctionValue;
        Debug.WriteLine(OptVal.ToString);
    End If;
End Sub UserProc;

After executing the example the LINDO problem is calculated from the specified file. Calculation results are displayed to the browser console.

See also:

ISmNonLinearOptimization