Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

how from matlab call lpex1.c

  • 1.  how from matlab call lpex1.c

    Posted 02/28/12 06:08 PM

    Originally posted by: yhlvqz


     I have changed the lpex1.c to mexfile called lpex1_mex.c

    but when I used matlab call lpex1_mex.c

    mex -I/path/cplex/include/ilcplex -L/path/lib/x86-64-sles10_4.1/static_pic lpex1_mex.c

    it showed mex: link of ' "lp_cplex_mex.mexa64"' failed.

    if I changed to

    mex -I/path/cplex/include/ilcplex -L/path/lib/x86-64-sles10_4.1/static_pic -lcplex lpex1_mex.c
    It showed /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: cannot find -lcplex
    collect2: ld returned 1 exit status

    mex: link of ' "lp_cplex_mex.mexa64"' failed.
    I used linux system. I think I may miss something in mex. I appreciate if someone gives me some hint. Thanks
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: how from matlab call lpex1.c

    Posted 02/28/12 09:15 PM

    Originally posted by: yhlvqz


    I forgot to add .c to matlab path.
    After I add path, it works.
    :-)
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: how from matlab call lpex1.c

    Posted 02/28/12 09:18 PM

    Originally posted by: John Cui


    Good, but we provided matlab interface for matlab users, say cplexmilp, cplexlp, cplexqcp, etc. and Cplex class in MATLAB.

    Then why do you want to build by yourself? Or you don't know we have matlab interface already?
    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: how from matlab call lpex1.c

    Posted 02/28/12 10:04 PM

    Originally posted by: yhlvqz


    hi, John

    I need change different constrains for cplex and I want to use multi-core to run for-loop in c programming instead in matlab. Because matlab only allows to use maximum 8 cores.

    I can use matlab mex to transfer data with c. But when I run cplex programming from matlab, it showed error I mentioned before. I think I may miss some parameter I should add when I complied c using mex. Would you help me solve this problem? Thanks a lot!
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: how from matlab call lpex1.c

    Posted 02/28/12 10:42 PM

    Originally posted by: John Cui


    To fix your complile issue, you should link cplex lib into your build script.

    Do you mean in MATLAB, CPLEX only can use 8 cores to solve your problem?
    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: how from matlab call lpex1.c

    Posted 02/29/12 08:32 AM

    Originally posted by: yhlvqz


    hi, John

    How I build lib cplex script in matlab? I have added -L/path/cplex/lib

    I have additional for-loop in my code which can only use maximum 8 cores in matlab.
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: how from matlab call lpex1.c

    Posted 02/29/12 09:25 AM

    Originally posted by: John Cui


    Anyway, does your build script looks like this:

    mex -O -I"<CPLEXDIR>/include" "your_cplex_mex.c" -L"<CPLEXLIBDIR>/lib" -lcplex124 -lut -largeArrayDims
    


    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: how from matlab call lpex1.c

    Posted 02/29/12 05:49 PM

    Originally posted by: yhlvqz


    hi, John

    I tried your commend, but it still showed 'It showed /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: cannot find -lcplex
    collect2: ld returned 1 exit status'

    I cannot find -lcplex or -lcplex124. Would you tell me where it should be? Thanks
    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: how from matlab call lpex1.c

    Posted 02/29/12 08:01 PM

    Originally posted by: John Cui


    Did cplex bin folder is in your path?

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: how from matlab call lpex1.c

    Posted 02/29/12 08:33 PM

    Originally posted by: yhlvqz


    hi, John

    cplex/bin is in the matlab path.

    there are four things in ILOG/cplex/bin/x86-64_sles10_4.1 including convert, cplex, cplexamp and libcplex123.so
    #CPLEXOptimizers
    #DecisionOptimization


  • 11.  Re: how from matlab call lpex1.c

    Posted 02/29/12 08:38 PM

    Originally posted by: John Cui


    Then please try -lcplex123 in the build script.

    John Cui
    #CPLEXOptimizers
    #DecisionOptimization


  • 12.  Re: how from matlab call lpex1.c

    Posted 02/28/12 10:00 PM

    Originally posted by: yhlvqz


    I still have the problem for,

    data.o: In function `mexFunction':
    data.c:(.text+0xc4): undefined reference to `CPXopenCPLEX'
    data.c:(.text+0x104): undefined reference to `CPXgeterrorstring'
    data.c:(.text+0x127): undefined reference to `CPXsetintparam'
    data.c:(.text+0x164): undefined reference to `CPXcreateprob'
    data.c:(.text+0x208): undefined reference to `CPXcopylp'
    data.c:(.text+0x241): undefined reference to `CPXlpopt'
    data.c:(.text+0x29d): undefined reference to `CPXsolution'
    data.c:(.text+0x2b9): undefined reference to `mxCreatDoubleMatrix'
    data.c:(.text+0x2df): undefined reference to `CPXfreeprob'
    data.c:(.text+0x313): undefined reference to `CPXcloseCPLEX'
    data.c:(.text+0x351): undefined reference to `CPXgeterrorstring'
    collect2: ld returned 1 exit status
    #CPLEXOptimizers
    #DecisionOptimization


  • 13.  Re: how from matlab call lpex1.c

    Posted 02/28/12 10:00 PM

    Originally posted by: yhlvqz


    I still have the problem for,

    data.o: In function `mexFunction':
    data.c:(.text+0xc4): undefined reference to `CPXopenCPLEX'
    data.c:(.text+0x104): undefined reference to `CPXgeterrorstring'
    data.c:(.text+0x127): undefined reference to `CPXsetintparam'
    data.c:(.text+0x164): undefined reference to `CPXcreateprob'
    data.c:(.text+0x208): undefined reference to `CPXcopylp'
    data.c:(.text+0x241): undefined reference to `CPXlpopt'
    data.c:(.text+0x29d): undefined reference to `CPXsolution'
    data.c:(.text+0x2b9): undefined reference to `mxCreatDoubleMatrix'
    data.c:(.text+0x2df): undefined reference to `CPXfreeprob'
    data.c:(.text+0x313): undefined reference to `CPXcloseCPLEX'
    data.c:(.text+0x351): undefined reference to `CPXgeterrorstring'
    collect2: ld returned 1 exit status
    #CPLEXOptimizers
    #DecisionOptimization