Unable to get CBT to see IBM CPLEX

349 views
Skip to first unread message

Jake Martin

unread,
Jan 22, 2021, 1:36:56 PM1/22/21
to COBRA Toolbox
Hi all,

I just recently installed IBM ILOG CPLEX 12.8 (the new 20.10 doesn't seem to have MATLAB support?) and I cannot seem to get Cobra Toolbox to see that the solver is installed. I believe I have the most recent Cobra Toolbox version. I'm on Windows 10, and my Windows Path includes "C:\Program Files\IBM\ILOG\CPLEX_Studio128\cplex\bin\x64_win64", and my MATLAB path includes ''C:\Program Files\IBM\ILOG\CPLEX_Studio128\cplex\matlab\x64_win64". I also went ahead and added `setenv('ILOG_CPLEX_PATH', 'C:\Program Files\IBM\ILOG\CPLEX_Studio128\cplex\matlab\x64_win64')` to startup.m. 

Running initCobraToolbox() gives

Checking if git is installed ...  Done (version: 2.29.2).
 > Checking if the repository is tracked using git ...  Done.
 > Checking if curl is installed ...  Done.
 > Checking if remote can be reached ...  Done.
 > Initializing and updating submodules (this may take a while)... Done.
 > Adding all the files of The COBRA Toolbox ...  Done.
 > Define CB map output... set to svg.
 > TranslateSBML is installed and working properly.
 > Configuring solver environment variables ...
   - [*---] ILOG_CPLEX_PATH: C:\Program Files\ibm\ILOG\CPLEX_Studio128\cplex\matlab\x64_win64
   - [*---] GUROBI_PATH: C:\gurobi910\win64\matlab
   - [----] TOMLAB_PATH: --> set this path manually after installing the solver ( see instructions )
   - [----] MOSEK_PATH: --> set this path manually after installing the solver ( see instructions )
   Done.
 > Checking available solvers and solver interfaces ... Done.
 > Setting default solvers ... Done.
 > Saving the MATLAB path ... Done.
   - The MATLAB path was saved in the default location.

 > Summary of available solvers and solver interfaces

Support           LP MILP    QP MIQP   NLP
----------------------------------------------------------------------
gurobi        active            1     1     1     1     -
ibm_cplex    active            0     0     0     0     -
tomlab_cplex active            0     0     0     0     -
glpk          active            1     1     -     -     -
mosek        active            0     -     0     -     -
matlab        active            1     -     -     -     1
pdco          active            1     -     1     -     -
quadMinos    active            0     -     -     -     -
dqqMinos      active            0     -     0     -     -
cplex_direct active            0     0     0     -     -
cplexlp      active            0     -     -     -     -
qpng          passive            -     -     1     -     -
tomlab_snopt passive            -     -     -     -     0
lp_solve      legacy            1     -     -     -     -
----------------------------------------------------------------------
Total        -                  5     2     3     1     1

 + Legend: - = not applicable, 0 = solver not compatible or not installed, 1 = solver installed.


 > You can solve LP problems using: 'glpk' - 'pdco' 
 > You can solve MILP problems using: 'glpk' 
 > You can solve QP problems using: 'pdco' 
 > You can solve MIQP problems using: 
 > You can solve NLP problems using: 

 > Checking for available updates ...
 > gitBash is installed (version: 2.13.3).
 > gitBash is up-to-date (version: 2.13.3).
.
 > currentBranch = master.
 > The COBRA Toolbox is up-to-date.

And running

solverName = 'ibm_cplex';
solverType = 'all';
printLevel = 1;
validationLevel = 2;
[solverOK, solverInstalled] = changeCobraSolver(solverName, solverType, printLevel, validationLevel)

Gives 
solverOK =
  logical
   0
solverInstalled =
  logical
   0


Please let me know if there are any other things I might try for this issue.

Thanks,
Jake

Jake Martin

unread,
Jan 22, 2021, 1:37:51 PM1/22/21
to COBRA Toolbox
Attached is the config report.
COBRAconfigReport.log

Thomas Millat

unread,
Feb 16, 2021, 1:33:47 PM2/16/21
to COBRA Toolbox
Hi Jake,

I have installed CBT alongside CPLEX 12.8 two weeks ago and run into the same problem.
It is caused by an erroneous statement in function setCplexParametersForProblem.m that prevents the validation of the CPLEX installation.

Replacing the statement (Line 26)

cplexProblem.Param.paramdisplay.Cur = cobraParams.printLevel~=0;

with

cplexProblem.Param.paramdisplay.Cur = cobraParams.printLevel;

solved the problem.


Hope that helps

Thomas

Ronan M.T. Fleming

unread,
Feb 16, 2021, 9:11:35 PM2/16/21
to COBRA Toolbox
Hi Thomas and Jake,
can you check if

cplexProblem.Param.paramdisplay.Cur = 0+cobraParams.printLevel~=0;
or
cplexProblem.Param.paramdisplay.Cur = double(cobraParams.printLevel~=0);

works instead?

cobraParams.printLevel can be 0,1,2,3 etc

One would have thought from this documentation that it is expecting a
logical argument but maybe not.

https://www.ibm.com/support/knowledgecenter/SSSA5P_20.1.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/ParamDisplay.html

Regards
Ronan
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "COBRA Toolbox" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to cobra-toolbo...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/cobra-toolbox/c20185a5-1bbe-4833-9959-939057b4b6fan%40googlegroups.com.



--
--
Mr. Ronan MT Fleming B.V.M.S. Dip. Math. Ph.D.
----------------------------------------------------------------------------
Assistant Professor,
Division of Systems Biomedicine and Pharmacology,
Leiden Academic Centre for Drug Research,
Faculty of Science,
Leiden University.
https://www.universiteitleiden.nl/en/staffmembers/ronan-fleming
&
H2020 Project Coordinator,
Systems Medicine of Mitochondrial Parkinson’s Disease,
http://sysmedpd.eu
&
Senior Lecturer,
School of Medicine,
National University of Ireland, Galway.
----------------------------------------------------------------------------
Peer-reviewed publications: https://goo.gl/FZPG23
Mobile: +353 852 109 806
Skype: ronan.fleming
----------------------------------------------------------------------------
(This message is confidential and may contain privileged information.
It is intended for the named recipient only. If you receive it in
error please notify me and permanently delete the original message and
any copies.)

Thomas Millat

unread,
Feb 17, 2021, 9:51:46 AM2/17/21
to cobra-...@googlegroups.com

Hi Ronan,

 

Only the second statement

               cplexProblem.Param.paramdisplay.Cur = double(cobraParams.printLevel~=0);

works.

 

Interestingly, my suggested correction works for all allowed values of printLevel. I think this is because of the convention that an 'if statement' is true for a non-zero numerical.

It seems that IBM CPLEX does not like logical variables as generated by the original statement and the first suggested in the below message 😲 Both cause CPLEX Error 1003: Bad argument to Callable Library routine. At least, it does not work in Matlab 2019a.

 

Regards

Thomas

 

-----Ursprüngliche Nachricht-----
Von: cobra-...@googlegroups.com <cobra-...@googlegroups.com> Im Auftrag von Ronan M.T. Fleming
Gesendet: Mittwoch, 17. Februar 2021 02:11
An: COBRA Toolbox <cobra-...@googlegroups.com>
Betreff: Re: Unable to get CBT to see IBM CPLEX

You received this message because you are subscribed to a topic in the Google Groups "COBRA Toolbox" group.

To unsubscribe from this topic, visit https://groups.google.com/d/topic/cobra-toolbox/O0Cp_mLjURc/unsubscribe.

To unsubscribe from this group and all its topics, send an email to cobra-toolbo...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/cobra-toolbox/CAOivGYtGreD1hP1n_bcycPNqywYRr3rngHHNJu%3DzaRGTbRmeWA%40mail.gmail.com.

Ronan M.T. Fleming

unread,
Feb 17, 2021, 1:34:16 PM2/17/21
to COBRA Toolbox
Hi Thomas,
thanks, the cobra toolbox is now updated to reflect this change. Also, the default solver is now gurobi.
Regards,
Ronan

Thomas Millat

unread,
Feb 19, 2021, 11:45:45 AM2/19/21
to cobra-...@googlegroups.com

Hi Ronan,

 

We actually prefer Gurobi over CPLEX but lso do some studies that require CPLEX. Thus, I have installed both Gurobi and CPLEX.

 

We are running the toolbox on an application server hosting several Matlab versions. The behaviour to write a pathdef.m into the home directory has caused some confusion with my colleagues as it renders other Matlab versions non-functional. A simple solution is to move this pathdef.m into dedicated directory and start Matlab from there every time the CobraToolbox shall be used. Could one add the CobraToolbox paths to startup.m and load them during the Matlab start?

 

Kind regards

Thomas

Ronan M.T. Fleming

unread,
Feb 19, 2021, 2:17:01 PM2/19/21
to COBRA Toolbox
Hi Thomas,

in initCobraToolbox it looks for a file called pathdef in the existing paths and it only saves the paths to the home directory if the existing pathdef does not have write privileges.

        [~, values] = fileattrib(which('pathdef.m'));
        if values.UserWrite
            savepath
        else
            savepath(defaultSavePathLocation);
        end

Can your application server copy the existing pathdef to somewhere specific to a dedicated directory, add that to the matlab path and then initCobraToolbox?

This might also help...

Regards,

Ronan

Thomas Millat

unread,
Feb 19, 2021, 3:57:54 PM2/19/21
to cobra-...@googlegroups.com

Hi Ronan,

 

Interestingly, Matlab advices against saving the search path in a personal pathdef.m. The reason beeing that the Matlab default paths have changed between different versions and a personal pathdef.m overwrites it (with a wrong path with a wrong path depending on the version). Thus, I do not deploy pathdef.m individually for every user due to the different Matlab version in use. Personal additions to the search path can be defined in a variable MATLABPATH, in .bashrc or .profile whatever is suitable, and are added to the default path during the start. Alternatively, a personal startup.m could be used to add folders to the Matlab path.

 

Then, multi-user access works perfectly fine. First, the version specific default path is loaded, and personal folders are added on top.

 

Thus, my current strategy is to have a dedicated folder for GSM work which contains a pathdef.m and Matlab should be started in this folder only when CobraToolbox is used. I leave it to those guys who use CoraToolbox to create the folder structure. I guess they can save the pathdef.m in that folder before they run initCobraToolbox.

 

Having it in startup.m would avoid having a pathdef.m lying around with the potential to mess with Matlab. What I do not know is if one can edit startup.m via script, but at the end of the day it is a text file. Just an idea

 

Have a nice weekend

Ronan M.T. Fleming

unread,
Feb 24, 2021, 11:17:26 AM2/24/21
to COBRA Toolbox
Hi Thomas,

can you test a new approach to save the cobra toolbox paths to a cobraToolboxPaths.m file in the same folder as
which('startup.m')
then edit startup.m to call cobraToolboxPaths.m?

Note that there are also some other lines that change the paths in initCobraToolbox
% set up the COBRA System path
addCOBRABinaryPathToSystemPath();

Also in line 178-179 of updateCobraToolbox.m there is a change to the paths if one has forked out other cobra repositories for editing.

Also, you would have to check for references to addpath or rmpath in the rest of the cobra toolbox.

If cobraToolboxPaths.m could robustly be made identical to the current appendage to pathdef.m, this new approach would then replace the current approach.

Regards,

Ronan

Thomas Millat

unread,
Feb 24, 2021, 1:54:08 PM2/24/21
to cobra-...@googlegroups.com

Hi Ronan,

 

Yes, I give it a try.

 

Regards

Nina Valenbreder

unread,
May 5, 2021, 7:50:55 AM5/5/21
to COBRA Toolbox
Hi all,

I am having the same issue as Jacob, whereby I have managed to successfully download the 12.8 IBM ILOG CPLEX solver but it is not being recognised by the CBT (config report attached). I have tried to troubleshoot using the instructions on the CBT website and by following what you have discussed here, unfortunately I'm still having troubles with it. Has anyone managed to figure out how to get around this issue? 

Kind regards,
Nina Valenbreder
COBRAconfigReport.log

Thomas Millat

unread,
May 5, 2021, 11:13:57 AM5/5/21
to cobra-...@googlegroups.com

Hi Nina,

 

According to the configuration report you are using MATLAB 2020b. As far as I am aware IBM CPLEX 12.8 is not compatible with this MATLAB version. To my knowledge, the latest supported MATLAB version is MATLAB 2019a. That is the one I am using with Cobra Toolbox. I think I have tried MATLAB 2019b once and it failed with IBM CPLEX 12.8. Newer MATLAB version should be compatible with IBM CPLEX 12.10, but I think this is not supported by Cobra Toolbox. Thus, you may have to downgrade your MATLAB version to at least 2019a. However, you can have multiple MATLAB versions installed alongside each other. In the latter case, copy the created pathdef.m into a dedicated folder you start your session from when using Cobra Toolbox and a supported MATLAB version.

 

Should you still experience the problem that the solver is not recognised, run the following command:

               changeCobraSolver(‘ibm_cplex’,’LP’,1,-1)

Likely, it throws an error somewhen during execution which helps to trace the origin of the problem. Basically, I followed the trail of error messages to its point of origin. I think the very first message in the list indicates the function and the line therein which causes the trouble. The subsequent messages deal with the function(s) calling the troubled function. Send me a screenshot if you need help to pinpoint the origin of the error. Then, I can try to help with that.

 

In my case back in March, the error occurred in function setCplexParametersForProblem in line 26, but I think that should be resolved in the latest branch of Cobra Toolbox.

 

Hope that helps

Ronan M.T. Fleming

unread,
May 5, 2021, 2:50:48 PM5/5/21
to COBRA Toolbox
Hi All,

I have generated a new compatibility matrix
https://github.com/opencobra/cobratoolbox/blob/develop/docs/source/installation/compatMatrix.rst
The only issues I am aware of are that
1) CPLEX 20.10 is incompatible with matlab, because they removed
support (hopefully temporarily) for the matlab interface.
2) quad precision LP solver needs to be updated to support libgfortran.so.5

We need to transition to providing support for just the newer versions
of matlab and newer versions of solvers. It is unsustainable
otherwise. There have been big improvements in matlabs support for
live scripts in recent versions so I'd advise updating to the latest b
version of matlab.

On ubuntu 20.04, with matlab 2021a and with ibm cplex 12.10 it runs
fine. This is what one should get if one runs the devel version:
>> [solverOK, solverInstalled] = changeCobraSolver('ibm_cplex','LP',1,2)

> changeCobraSolver: IBM ILOG CPLEX interface added to MATLAB path.
> ibm_cplex (version 1210) is compatible and fully tested with MATLAB
R2021a on your operating system.

solverOK = 1
solverInstalled = 1

The message about compatibility might be different if you are still
using the master version of compatMatrix.rst but the essential
compatibility is the same.

If you still cannot see the solver, try debugging it (*using the
command above*) and reporting here the exact error.

Regards,

Ronan

On Wed, 5 May 2021 at 16:13, 'Thomas Millat' via COBRA Toolbox
> To view this discussion on the web visit https://groups.google.com/d/msgid/cobra-toolbox/007101d741c1%2442111bb0%24c6335310%24%40googlemail.com.

Nina Valenbreder

unread,
May 6, 2021, 6:03:23 AM5/6/21
to COBRA Toolbox

Hi Thomas,

Thanks for the suggestions! I'll give downgrading Matlab and/or running the command a try.

Kind regards,
Nina
Reply all
Reply to author
Forward
0 new messages