Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab CPLEX&x2B;雅尔米普--”;未找到解算器";?_Matlab_Ubuntu_Mathematical Optimization_Linear Programming_Cplex - Fatal编程技术网

Matlab CPLEX&x2B;雅尔米普--”;未找到解算器";?

Matlab CPLEX&x2B;雅尔米普--”;未找到解算器";?,matlab,ubuntu,mathematical-optimization,linear-programming,cplex,Matlab,Ubuntu,Mathematical Optimization,Linear Programming,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' 在上述代码中,sol

我正在尝试开始,这是一个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
打印警告:未找到解算器。包含
obj
cons
.m
和对Yalmip的调用在我朋友的计算机上工作,我们很困惑为什么它在我的计算机上不工作


以下是我在我的Ubuntu 12.04机器上使用Matlab R2012b对CPLEX和Yalmip的设置步骤:

  • 在此处安装IBM CPLEX:
    /home/user/IBM/ILOG/CPLEX_Studio125/CPLEX
  • 在此处安装Yalmip:
    home/user/Yalmip
  • 将CPLEX和Yalmip添加到我的Matlab路径(并确认所有目录都存在):

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

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

    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
        ...
    
    为了验证Matlab确实可以找到CPLEX,我运行了
    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.
    ...
    

    我还环顾了IBM论坛,寻找这方面的答案。一位朋友向我指出了诊断CPLEX/Yalmip的问题,但这篇文章更关注Windows,并没有真正解决我的问题


    更多详情:

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

    在深入研究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 | notfound |
    行意味着没有找到CPLEX 12.0、12.1、12.2和12.3

    solver(i) = lpsolver;
    solver(i).tag     = 'CPLEX';
    solver(i).version = 'IBM';
    solver(i).subversion = '12.4';
    solver(i).checkfor = {'cplexlp.m','cplexlink124'};
    ...
    
    >> 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|
    ...