Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
Expand all | Collapse all

Problem calling Cplex dll library through VB.Net

  • 1.  Problem calling Cplex dll library through VB.Net

    Posted Thu March 05, 2009 09:20 PM

    Originally posted by: SystemAdmin


    [mnaiman said:]

    Hello,
    I am having problem invoking the cplex library to load the linear programming problem. The problem is generated in LP format by using a shell(...) command and zimpl as shown in the code. Now I want to load the file into cplex to perform optimization and get the solution. However, I am unable to do so and coming accross following problems.

    If I use the firstcode... then it gives me the error... "Object reference not set to an instance of an object." and asks me to use NEW to  Instantiate the object.  which is understandable. So I change he code as shown in the second code.


    -------
    Imports ILOG.Concert
    Imports ILOG.CPLEX
    Imports System.Collections
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Shell("cmd.exe /c zimplopt RMh.txt", AppWinStyle.NormalFocus)  ' to generate RMh.lp file in the same folder
            Dim modelname As String = "C:\Backup old PC Jalil\MJalil\Data\Visual Studio 2008\Projects\CPLEXIMPORT\CPLEXIMPORT\bin\Debug\RMh.lp"  ' assign filename to string
            Dim CModel As Cplex
            CModel.ImportModel(modelname)  ' to load file
        End Sub
    End Class
    -------
    So I replace Dim CModel As Cplex ==> Dim CModel As New Cplex() as shown in the next code and it gives me the following error. "Unable to load DLL 'cplex110': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"

    -------
    Imports ILOG.Concert
    Imports ILOG.CPLEX
    Imports System.Collections
    Public Class Form1
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Shell("cmd.exe /c zimplopt RMh.txt", AppWinStyle.NormalFocus)  ' to generate RMh.lp file in the same folder
            Dim modelname As String = "C:\Backup old PC Jalil\MJalil\Data\Visual Studio 2008\Projects\CPLEXIMPORT\CPLEXIMPORT\bin\Debug\RMh.lp"  ' assign filename to string
            Dim CModel As New Cplex()
            CModel.ImportModel(modelname)  ' to load file
        End Sub
    End Class
    -------

    Any help is highly appreciated...
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Problem calling Cplex dll library through VB.Net

    Posted Fri March 06, 2009 07:02 PM

    Originally posted by: SystemAdmin


    [MaryFenelon said:]

    The "Unable to load cplex110.dll" sounds like the cplex110.dll is not visible to your program.  This dll must be in the directory from which you are executing or its location must be declared in the PATH variable.  cplex110.dll is not .NET assembly and so is treated differently than ILOG.CPLEX.dll and ILOG.Concert.dll, which are .NET assemblies.
    #CPLEXOptimizers
    #DecisionOptimization