CPLEX + YALMIP - “未找到解算器”?

时间:2012-11-25 22:24:51

标签: matlab ubuntu mathematical-optimization linear-programming cplex

我正在尝试开始使用YALMIP,它是优化求解程序(如CPLEX)的Matlab接口。我有一个目标函数obj和约束cons,我已将它们插入Yalmip ......

options=sdpsettings('solver','Cplex'); %windows needs uppercase 'Cplex' and unix is ok with 'cplex' or 'Cplex'
solvesdp(cons,obj,options); %prints 'Warning: Solver not found'

在上面的代码中,solvesdp打印警告:未找到解算器。包含.mobj的{​​{1}}以及对Yalmip的调用在我朋友的计算机上运行,​​我们很难理解为什么它无法在我的计算机上运行。


以下是我在 Ubuntu 12.04 计算机上使用 Matlab R2012b 执行的CPLEX和Yalmip的设置步骤:

  1. 在此处安装IBM CPLEX:cons
  2. 在这里安装Yalmip:/home/user/ibm/ILOG/CPLEX_Studio125/cplex
  3. 将CPLEX和Yalmip添加到我的Matlab路径(并确认所有目录都存在):
  4. home/user/yalmip

    下面,我解释一下我是如何尝试诊断问题的。很明显,Matlab可以看到CPLEX,Matlab可以看到Yalmip,但Yalmip看不到CPLEX。

    确认Yalmip和CPLEX在我的matlab路径中:

        addpath(genpath('/home/user/yalmip'))
        addpath(genpath('/home/user/ibm/ILOG/CPLEX_Studio125/cplex/matlab'))
        addpath(genpath('/home/user/ibm/ILOG/CPLEX_Studio125/cplex/examples/src/matlab'))
    

    为了验证Matlab确实可以找到CPLEX,我运行了MATLAB> path /home/user/ibm/ILOG/CPLEX_Studio125/cplex/examples/src/matlab /home/user/ibm/ILOG/CPLEX_Studio125/cplex/matlab /home/forrest/ibm/ILOG/CPLEX_Studio125/cplex/matlab/help /home/forrest/ibm/ILOG/CPLEX_Studio125/cplex/matlab/help/helpsearch /home/forrest/ibm/ILOG/CPLEX_Studio125/cplex/matlab/help/topics /home/user/yalmip /home/user/yalmip/demos /home/user/yalmip/extras /home/user/yalmip/modules /home/user/yalmip/modules/bilevel /home/user/yalmip/modules/global /home/user/yalmip/modules/moment /home/user/yalmip/modules/parametric /home/user/yalmip/modules/robust /home/user/yalmip/modules/sos /home/user/yalmip/operators /home/user/yalmip/solvers ... 。它给出了有效的输出:

    help cplexlp

    此外,MATLAB> help cplexlp cplexlp Solve linear programming problems. x = cplexlp(f,Aineq,bineq) solves the linear programming problem min f*x such that Aineq*x <= bineq. ... 提供此输出:which cplex

    /home/user/ibm/ILOG/CPLEX_Studio125/cplex/matlab/@Cplex/Cplex.p提供此输出:which yalmip

    我在Matlab命令提示符下运行/home/user/yalmip/extras/yalmip.m。输出验证Matlab可以找到Yalmip,但是Yalmip找不到CPLEX:

    yalmiptest

    我也在IBM论坛上寻找答案。一位朋友向我指出this post in the IBM forums关于诊断CPLEX / Yalmip的问题,但该帖子更侧重于Windows,并没有真正解决我的问题。


    更多详情:

    • Yalmip版本2012-09-26
    • CPLEX 12.5版

1 个答案:

答案 0 :(得分:4)

在深入研究Yalmip源代码后,我终于找到了问题。

在Yalmip源代码中,有一个名为yalmip/solvers/definesolvers.m的文件。在definesolvers.m中,有很多这样的陈述:

solver(i) = lpsolver;
solver(i).tag     = 'CPLEX';
solver(i).version = 'IBM';
solver(i).subversion = '12.4';
solver(i).checkfor = {'cplexlp.m','cplexlink124'};
...

这些语句适用于CPLEX 12.0,12.1,12.2,12.3和12.4。但是,我正在使用CPLEX 12.5,对于CPLEX 12.5,没有这样的声明。

我将12.4的所有实例替换为12.5,并将cplexlink124的实例替换为cplexlink125。我的优化代码现在可以使用了!

以下是yalmiptest的新输出:

>> yalmiptest
+++++++++++++++++++++++++++++++++++++++++++++++
|       Searching for installed solvers       |
+++++++++++++++++++++++++++++++++++++++++++++++
|        Solver|   Version/module|      Status|
+++++++++++++++++++++++++++++++++++++++++++++++
|         CPLEX|              IBM|       found|
|         CPLEX|              IBM|       found|
|         CPLEX|              IBM|       found|
|       LINPROG|                 |       found|
|      QUADPROG|                 |       found|
|        LMILAB|                 |       found|
|       FMINCON|        geometric|       found|
|       FMINCON|         standard|       found|
|    FMINSEARCH|                 |       found|
|           BNB|                 |       found|
|      BINTPROG|                 |       found|
|        CUTSDP|                 |       found|
|        BMIBNB|                 |       found|
|         KKTQP|                 |       found|
|          NONE|                 |       found|
|     LSQNONNEG|                 |       found|
|        LSQLIN|                 |       found|
|        GUROBI|           GUROBI|   not found|
|        GUROBI|              MEX|   not found|
|         CPLEX|              IBM|   not found|
|         CPLEX|              IBM|   not found|
|         CPLEX|              IBM|   not found|
|         CPLEX|              IBM|   not found|
|         CPLEX|              IBM|   not found|
|         CPLEX|              IBM|   not found|
|         CPLEX|              IBM|   not found|
|         CPLEX|              IBM|   not found|
|         CPLEX|              IBM|   not found|
|         CPLEX|              IBM|   not found|
|         CPLEX|              IBM|   not found|
|         CPLEX|              IBM|   not found|
...

我猜测剩余的CPLEX| IBM| not found|行意味着找不到CPLEX 12.0,12.1,12.2和12.3。