ExecuteFromMPI(Path: String; NumberOfVariables: Integer): Integer;
ExecuteFromMPI(Path: string; NumberOfVariables: integer): integer;
Path. Path to MPI file containing a LINDO problem.
NumberOfVariables. Number of problem variables.
The ExecuteFromMPI method performs non-linear optimization of problem from the specified file by means of LINDO.
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.
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 <> 0) Or (LindoSettings.nErrorCode <> 0) Then
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.
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
nlo: ISmNonLinearOptimization;
LindoSettings: ILindoSettings;
i, res: Integer;
Warnings: System.Array;
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.nlostLindo;
// 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 <> 0) Or (LindoSettings.nErrorCode <> 0) Then
System.Diagnostics.Debug.WriteLine(nlo.Errors);
System.Diagnostics.Debug.WriteLine("LINDO error code: " + LindoSettings.nErrorCode.ToString());
System.Diagnostics.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
System.Diagnostics.Debug.WriteLine("Warning: " + Warnings[i]);
End For;
// Display calculation results
System.Diagnostics.Debug.WriteLine("== Criterion function value ==");
OptVal := nlo.OptimalFunctionValue;
System.Diagnostics.Debug.WriteLine(OptVal.ToString());
End If;
End Sub;
See also: