Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Matlab interface for ILOG Cplex 12

  • 1.  Matlab interface for ILOG Cplex 12

    Posted Thu April 22, 2010 05:02 AM

    Originally posted by: SystemAdmin


    I found out that there is a Matlab interface for CPLEX 12.

    Where can I download it?
    How can I install it?

    Thank you
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Matlab interface for ILOG Cplex 12

    Posted Thu April 22, 2010 10:29 AM

    Originally posted by: John Cui


    Hi Feanor,

    Glad to hear you are looking for matlab interface of CPLEX.
    In fact, after you downloaded and installed the CPLEX12, the matlab interface will be installed like other interfaces(c/c++/.net/JAVA...).
    So, you don't need to download and install matlab interface separately.

    To use the matlab interface is very easy too, you just need to add the path of matlab interface into your matlab path, then you can use CPLEX in MATLAB.

    Here is a brief introduction about our MATLAB interface:
    Provided in IBM ILOG CPLEX for MATLAB is both a toolbox of functions and a class API. The toolbox contains functions for solving optimization problems, where the input matrices are provided to the function and results returned. With the class API, objects can be created, and those objects carry a state.

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Matlab interface for ILOG Cplex 12

    Posted Fri May 28, 2010 11:02 AM

    Originally posted by: LizBai


    Hi,I have the same problem.
    Do you mean addpath by add "\ILOG\CPLEX121\examples\src\matlab" to matlab path?
    It still doesn't work after I set the search path in matlab. I dot not know why.
    Liz
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Matlab interface for ILOG Cplex 12

    Posted Fri May 28, 2010 11:26 AM

    Originally posted by: John Cui


    You need add the path of CPLEX-MATLAB to MATLAB's path:
    >>addpath('c:\ILOG\CPLEX121\matlab\x86_win32\')

    After above addpath, you can new Cplex object on matlab, to solve your problem; and also, you can call our toolbox functions to solve your problem. Such as:
    >> cplex=Cplex()
         
    ans=
         
       Cplex handle
         
       Properties:
          Model: [1x1 struct]
          Param: [1x1 struct]
          DisplayFunc: @disp
         
       Methods, Events, Superclasses
    >> cplex.addCols(1)
         
    ans=
         
       Cplex handle
         
       Properties:
          Model: [1x1 struct]
          Param: [1x1 struct]
          DisplayFunc: @disp
         
       Methods, Events, Superclasses
    >> cplex.solve
    Tried aggregator 1 time.
    LP Presolve eliminated 0 rows and 1 columns.
    All rows and columns eliminated.
    Presolve time =    0.00 sec.
     
    ans = 
     
              status: 1
        statusstring: 'optimal'
                time: 0
              objval: 0
                   x: 0
              method: 2
         reducedcost: 1
               basis: [1x1 struct]
    


    If you want to run CPLEX examples in MATLAB at any directory, you need to add the path of CPLEX-MATLAB examples to MATLAB's path:

    >>addpath('c:\ILOG\CPLEX121\examples\src\matlab')

    then you can run our examples, such as

    >> cplexlpex
    Tried aggregator 1 time.
    No LP presolve or aggregator reductions.
    Presolve time =    0.00 sec.
     
    Iteration log . . .
    Iteration:     1   Dual infeasibility =             0.000000
    Iteration:     2   Dual objective     =          -202.500000
     
    Solution status = optimal
    Solution value = -202.500000
    Values =
       40.0000
       17.5000
       42.5000
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Matlab interface for ILOG Cplex 12

    Posted Sat April 30, 2011 07:27 AM

    Originally posted by: sjayaswal


    I have added the path ('c:\ILOG\CPLEX121\matlab\x86_win32\')
    I still get the following error on running cplexlpex:

    "Undefined function or variable 'm'.
    Error in ==> cplexlpex at 43
    catch m"

    I get the same error on calling any cplex function within matlab.
    Please help .

    Regards,
    Sachin
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Matlab interface for ILOG Cplex 12

    Posted Sat April 30, 2011 09:20 AM

    Originally posted by: sjayaswal


    Further calling any cplex function like cplexmilp throws the following error:
    Corrupt P-file "C:\ILOG\CPLEX121\matlab\x86_win32\cplexmilp.p"

    Regards,
    Sachin
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Matlab interface for ILOG Cplex 12

    Posted Sat April 30, 2011 09:25 PM

    Originally posted by: John Cui


    1. I guess your matlab is older than matlab 2007b, right? Our connector support maltab version >= 2007b
    2. If you are an academic user, I recommend you try the latest CPLEX 12.2.0.2, we improved a lot for matlab connector in this version.

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Matlab interface for ILOG Cplex 12.4

    Posted Tue May 15, 2012 09:50 PM

    Originally posted by: SystemAdmin


    Hii All,

    I am trying to run Cplex 12.4 with Matlab version 7.12.0(R2011a). But when I run the code it gives me a warning - solver not found. I have tried adding paths like -C:\Users\Nikunj\Documents\IBM\ILOG\CPLEX_Studio_Preview124\cplex\examples\src\matlab but it didn't help. Any help or suggestion in this regard is welcome.

    Wishes,
    Nikunj
    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Matlab interface for ILOG Cplex 12.4

    Posted Tue May 15, 2012 10:48 PM

    Originally posted by: John Cui


    No, you need to add D:\Program Files\IBM\ILOG\CPLEX_Studio124\cplex\matlab\x64_win64 kind folder to your matlab path.

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: Matlab interface for ILOG Cplex 12.4

    Posted Sat May 19, 2012 04:10 PM

    Originally posted by: SystemAdmin


    Hii John,

    Thanks for the reply. This solved my previous problem.
    Now , can anyone suggest me the best non- linear solver that can be interfaced with Matlab because in my problem I am getting terms like product of variables which makes the problem out of Cplex's domain.

    Wishes,
    Nkunj
    #CPLEXOptimizers
    #DecisionOptimization


  • 11.  Re: Matlab interface for ILOG Cplex 12.4

    Posted Wed May 23, 2012 12:28 AM

    Originally posted by: John Cui


    I suggest you to try yalmip package in MATLAB, which can connect non-linear solvers.

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 12.  Re: Matlab interface for ILOG Cplex 12.4

    Posted Wed May 23, 2012 03:02 PM

    Originally posted by: SystemAdmin


    Hello John,

    I have already been using Yalmip toolbox in Matlab and with that I was calling Cplex as a solver till now. Now, I need to connect Yalmip with some non linear solver to address my problem but I need your help to find out which solver shall I use that can be easily integrated with Matlab.

    I mean what shall be the substitute of Cplex considering non-linear domain.

    Wishes,
    Nikunj
    #CPLEXOptimizers
    #DecisionOptimization


  • 13.  Re: Matlab interface for ILOG Cplex 12.4

    Posted Wed May 23, 2012 04:09 PM

    Originally posted by: Eumpfenbach


    First of all, I am assuming you are not willing to pay for a solver and the built in fmincon function in Matlab will not suffice (it is for continuous problems only).

    You might want to check out the NEOS server:

    http://www.neos-server.org/neos/solvers/index.html

    If your problem is formulated in ILOG OPL then you can reasonably easily transform it into AMPL. I transformed a problem with hundreds of lines from AMPL to OPL recently and it took a couple hours. Then you can solve it on the NEOS server for free. I have used Bonmin for convex problems and Couenne for nonconvex.

    You mentioned product variables in your formulation. There may be an opportunity to reformulate your problem into a linear one. You can google "Reformulation-Linearization Techniques" and try and determine if this is an option. If you can clearly state your problem I might be able to give you some ideas. There is a cost to this, however. It usually introduces a lot of extra variables and can quickly explode for big problems.

    As far as a Matlab solver that offers the ease of use of the built-in API of Cplex for Matlab and handles NMILP problems, I don't think one exists. If you HAVE to work in Matlab, you might have to get an ampl license and call Couenne through ampl, write the solution to a file, and read it into Matlab through scripts.
    #CPLEXOptimizers
    #DecisionOptimization


  • 14.  Re: Matlab interface for ILOG Cplex 12.4

    Posted Wed May 23, 2012 06:29 PM

    Originally posted by: SystemAdmin


    Hello John,

    First of all thanks for your reply. Secondly, I would like to mention that you are correct in assuming that currently I am looking for free solvers available online for academic purposes. Thirdly, in the problem that I need to solve the equations goes something like this -

    reliability =
    where,
    prob_switch_survival == constant,

    reliability_bus ==variable real number vector(each element is a fraction). This is computed as another constraint of the problem depending upon other decision variables.

    BL= decision variable binary matrix.

    Now since I am getting a product of many variables the problem becomes non-linear. Yalmip along with Cplex cannot solve this problem, Cplex being a linear solver. Is it possible to integrate it with some other solver that can handle this problem ? If yes please suggest me the name of such solver that is compatible with Matlab and Yalmip. Also, is there a way by which we can linearize this non-linear equation?

    Expecting to hear from you soon.

    Wishes,
    Nikunj
    #CPLEXOptimizers
    #DecisionOptimization


  • 15.  Re: Matlab interface for ILOG Cplex 12.4

    Posted Wed May 23, 2012 06:29 PM

    Originally posted by: SystemAdmin


    I am sorry I meant -

    reliability =
    #CPLEXOptimizers
    #DecisionOptimization


  • 16.  Re: Matlab interface for ILOG Cplex 12.4

    Posted Wed May 23, 2012 06:30 PM

    Originally posted by: SystemAdmin


    I am sorry I meant -

    reliability =
    #CPLEXOptimizers
    #DecisionOptimization


  • 17.  Re: Matlab interface for ILOG Cplex 12.4

    Posted Wed May 23, 2012 06:31 PM

    Originally posted by: SystemAdmin


    I am sorry. I meant-

    Reliability = 1-prod(1-prob_switch_survival*(reliability_bus)'.*BL(:,1))
    #CPLEXOptimizers
    #DecisionOptimization


  • 18.  Re: Matlab interface for ILOG Cplex 12.4

    Posted Thu May 24, 2012 01:34 AM

    Originally posted by: SystemAdmin


    Standard nonlinear solvers accesible via YALMIP are the fmincon family, snopt and ipopt (via the OPTI Toolbox binaries)

    The tractability of your problem depends on the context, e.g., how reliability_bus etc is defined, and how you actually use the variable Reliability. Mail me and we can discuss matters in detail.

    /johan (Developer of YALMIP)
    #CPLEXOptimizers
    #DecisionOptimization


  • 19.  Re: Matlab interface for ILOG Cplex 12.4

    Posted Thu May 24, 2012 01:45 AM

    Originally posted by: SystemAdmin


    forgot to list bonmin in the list (also via OPTI Toolbox binaries)
    #CPLEXOptimizers
    #DecisionOptimization


  • 20.  Re: Matlab interface for ILOG Cplex 12.4

    Posted Thu May 24, 2012 02:24 AM

    Originally posted by: John Cui


    Thanks Johan.

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 21.  Re: Matlab interface for ILOG Cplex 12.4

    Posted Mon March 18, 2013 12:03 PM

    Originally posted by: MLJ


    I have installed ILOG Studio 12.4 on a Windows 64-bit machine.
    I am trying to solve the basic linear programming problem with Matlab and cplexlp. The code is given below.
    The issue is that I keep getting the following error message:

    "
    ??? Error using ==> cplexlp at 254
    Undefined function or method 'cplexlink124' for input arguments of type 'struct'.
    "

    Can you tell me how to resolve this issue?
    f = -1; -2; -3';
    Aineq = 1 -1 1; 1 -3 1;
    bineq = 20 30;
    lb = 0 0 0';
    ub=40 inf inf';

    x= cplexlp(f,Aineq,bineq,],[,lb,ub)
    #CPLEXOptimizers
    #DecisionOptimization


  • 22.  Re: Matlab interface for ILOG Cplex 12

    Posted Wed May 23, 2012 10:44 AM

    Originally posted by: C2XY_Xavier_Wallet


    Hi,
    I use Matlab 2009 (R2009b) and IBM ILOG CPLEX Optimization Studio 4.12
    I try to use the simple command that you suggest above, but it appears the following error:

    >> addpath('C:\Program Files\IBM\ILOG\CPLEX_Studio_Preview124\cplex\matlab\x64_win64')
    >> cplex=Cplex();
    ??? Undefined function or method 'cplexlink124' for input arguments of type 'double'.

    It would be great if you can help me
    Thank you in advance
    Xavier
    #CPLEXOptimizers
    #DecisionOptimization


  • 23.  Re: Matlab interface for ILOG Cplex 12

    Posted Wed May 23, 2012 11:15 PM

    Originally posted by: John Cui


    Could you please run which cplexlink124 in your maltab, and paste the output here?

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 24.  Re: Matlab interface for ILOG Cplex 12

    Posted Thu May 24, 2012 06:27 AM

    Originally posted by: C2XY_Xavier_Wallet


    Thank you for the reply,
    What command should I use? Because I don't quite understand "run which" (I'm French)
    Thank you
    Xavier
    #CPLEXOptimizers
    #DecisionOptimization


  • 25.  Re: Matlab interface for ILOG Cplex 12

    Posted Thu May 24, 2012 07:37 AM

    Originally posted by: Eumpfenbach


    I believe you have a very nasty, nonconvex function that will not optimize well. The product of 2 different decision variables is nonconvex. You seem to have the product of n decision variables. Even if you can linearize it, you will likely need at least n^2 linear variables to do it (ie, the variable count quickly explodes to the point where even solving a linear problem takes forever). Here is a first reference for you if you want to explore more:

    http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.60.7755

    Bonmin is for convex problems (mostly). It will give an answer to your problem, but it very likely be a local optimum. The documentation gives some ideas about using it for approximate solutions to nonconvex problems. My personal experience is that it was not very close (I have experience with trying to optimize a function similar to yours).

    You might be better off trying to approximate your function or use some kind of metaheuristic.
    #CPLEXOptimizers
    #DecisionOptimization


  • 26.  Re: Matlab interface for ILOG Cplex 12

    Posted Thu May 24, 2012 01:39 PM

    Originally posted by: C2XY_Xavier_Wallet


    I think I found the problem. You think this may be because I use a matlab 32-bit with a file. Mexw64? I think the problem comes from there. If you could confirm this?
    thank you
    Xavier
    #CPLEXOptimizers
    #DecisionOptimization


  • 27.  Re: Matlab interface for ILOG Cplex 12

    Posted Fri May 25, 2012 12:48 AM

    Originally posted by: John Cui


    Yes, you can not use 32bits matlab with 64bits cplex in our matlab connector.

    If your OS is 64bits, then please install 64bits matlab.
    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 28.  Re: Matlab interface for ILOG Cplex 12

    Posted Wed March 26, 2014 04:14 PM

    Originally posted by: patelzs


    Hi John,

    1. Is it ok to use 32bits cplex with 64bits matlab on Windows 7 OS of 64bits?

     

    Thank You


    #CPLEXOptimizers
    #DecisionOptimization


  • 29.  Re: Matlab interface for ILOG Cplex 12

    Posted Fri March 28, 2014 03:17 AM

    This will most likely not work since 64bit matlab cannot load the 32bit CPLEX library. Any reason not to use 64bit CPLEX?


    #CPLEXOptimizers
    #DecisionOptimization