CPLEX + YALMIP -- "Solver not found"?

solvingPuzzles picture solvingPuzzles · Nov 25, 2012 · Viewed 8.1k times · Source

I'm trying to get started with YALMIP, which is a Matlab interface to optimization solvers such as CPLEX. I have an objective function obj and constraints cons, and I've plugged them into 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'

In the above code, solvesdp prints Warning: Solver not found. The .m containing obj, cons, and the calls to Yalmip works on my friend's computer, and we're stumped about why it's not working on my computer.


Here are the setup steps for CPLEX and Yalmip that I did on my Ubuntu 12.04 machine with Matlab R2012b:

  1. Installed IBM CPLEX here: /home/user/ibm/ILOG/CPLEX_Studio125/cplex
  2. Installed Yalmip here: home/user/yalmip
  3. Added CPLEX and Yalmip to my Matlab path (and confirmed that all directories exist):

    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'))

Below, I explain how I've tried to diagnose the problem. It's apparent that Matlab can see CPLEX, Matlab can see Yalmip, but Yalmip can't see CPLEX.

Confirmed that Yalmip and CPLEX are in my matlab path:

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
    ...

To verify that Matlab can indeed find CPLEX, I ran help cplexlp. It gave valid output:

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.
...

Also, which cplex gives this output: /home/user/ibm/ILOG/CPLEX_Studio125/cplex/matlab/@Cplex/Cplex.p

And which yalmip gives this output: /home/user/yalmip/extras/yalmip.m

I ran yalmiptest on the Matlab command prompt. The output verifies that Matlab can find Yalmip, but Yalmip can't find CPLEX:

MATLAB> yalmiptest
+++++++++++++++++++++++++++++++++++++++++++++++
|       Searching for installed solvers       |
+++++++++++++++++++++++++++++++++++++++++++++++
|        Solver|   Version/module|      Status|
+++++++++++++++++++++++++++++++++++++++++++++++
|       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|              IBM|   not found|
|         CPLEX|              IBM|   not found|
|         CPLEX|         CPLEXINT|   not found|
|           CBC|                 |   not found|
|          GLPK|       GLPKMEX-CC|   not found|

I also looked around the IBM forums for answers to this. A friend pointed me to this post in the IBM forums about diagnosing CPLEX/Yalmip, but the post is more Windows-focused and it didn't really solve my problem.


More details:

  • Yalmip version 2012-09-26
  • CPLEX version 12.5

Answer

solvingPuzzles picture solvingPuzzles · Nov 26, 2012

After digging into the Yalmip source code, I eventually found the problem.

In the Yalmip source code, there's a file called yalmip/solvers/definesolvers.m. In definesolvers.m, there are a bunch of statements like this:

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

These statements exist for CPLEX 12.0, 12.1, 12.2, 12.3, and 12.4. But, I'm using CPLEX 12.5, and there's no statement like this for CPLEX 12.5.

I replaced all instances of 12.4 with 12.5 and replaced instances of cplexlink124 with cplexlink125. My optimization code works now!

Here's the new output of 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|
...

I'm guessing that the remaining CPLEX| IBM| not found| lines mean that CPLEX 12.0, 12.1, 12.2, and 12.3 aren't found.