Using matlab NLP solver

171 views
Skip to first unread message

Sowmya Manojna

unread,
May 28, 2020, 3:16:04 PM5/28/20
to COBRA Toolbox

Hi.


I have been trying to solve an NLP problem using the matlab solver.

When initCobraToolbox is executed, the matlab NLP solver is reported to be active and installed.


Output of initCobraToolbox:

       Support            LP    MILP      QP      MIQP   NLP

    --------------------------------------------------------------------------------------

    gurobi           active                1         1         1         1         -

    ibm_cplex        active                1         1         1         1         -

    tomlab_cplex     active                1         1         1         1         -

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

    cplexlp          active                1         -         -         -         -

    qpng             passive               -         -         1         -         -

    tomlab_snopt     passive               -         -         -         -         1

    lp_solve         legacy                1         -         -         -         -

    --------------------------------------------------------------------------------------

    Total            -                     9         5         6         3         2


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


 > You can solve LP problems using: 'gurobi' - 'ibm_cplex' - 'glpk' - 'pdco' - 'cplexlp'

 > You can solve MILP problems using: 'gurobi' - 'ibm_cplex' - 'glpk'

 > You can solve QP problems using: 'gurobi' - 'ibm_cplex' - 'pdco'

 > You can solve MIQP problems using: 'gurobi' - 'ibm_cplex'

 > You can solve NLP problems using:


 > Checking for available updates ...

 > The COBRA Toolbox is up-to-date.


However the matlab solver is not recognised. I tried to change the cobra solver to matlab using changeCobrasolver to confirm if it was a function problem or an output rendering issue. The result is as follows:

>> changeCobraSolver('matlab', 'NLP')

 > changeCobraSolver: Solver matlab is installed but not working properly.

ans =

  logical

   0


I checked if the fmincon function was working using a few sample functions and found it to be working perfectly.


I tried searching for a solution to this issue but couldn’t find any. Any help in this regard would be greatly appreciated.


Thanks and regards,

Sowmya

Ronan M.T. Fleming

unread,
May 30, 2020, 5:06:41 PM5/30/20
to COBRA Toolbox
Hi Sowmya,
try
changeCobraSolver('matlab', 'NLP',1,2)
then see what you get and debug from there.
Regards,
Ronan
[solverOK, solverInstalled] = changeCobraSolver(solverName,
solverType, printLevel, validationLevel)
https://opencobra.github.io/cobratoolbox/stable/modules/base/solvers/index.html?highlight=changecobrasolver#src.base.solvers.changeCobraSolver
> --
>
> ---
> 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/812c7464-092e-4feb-b79c-8c5de4b0ff18%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
&
Adjunct Lecturer,
School of Medicine,
National University of Ireland, Galway.
----------------------------------------------------------------------------
Peer-reviewed publications: https://goo.gl/FZPG23
Mobile: +353 873 413 072
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.)

Sowmya Manojna

unread,
Jun 3, 2020, 7:56:25 AM6/3/20
to cobra-...@googlegroups.com

Dear Sir,

Thank you for the guidance. I tried debugging it using the verbose option and it worked. 


The changes made in order to fix the problem (in COBRA v3 and MATLAB 2020a) are as follows: 

Program Name

Line number

Changes made

initCobraToolbox

339

From: SOLVERS.matlab.type = {‘LP’, 'NLP'};
To: SOLVERS.matlab.type = {'NLP'};

Explanation:
optimoptions doesn’t support code generation for linprog and also as in line 1017 of solveCobraLP, matlab is not a reliable LP solver

solveCobraNLP

157

From: options = optimoptions('fmincon','maxIter',cobraParams.iterationLimit,'maxFunEvals',cobraParams.iterationLimit, 'Display',fminconPrintLevel);


To: options = optimoptions('fmincon','maxIter',cobraParams.iterationLimit,'MaxFunctionEvaluations',cobraParams.iterationLimit, 'Display',fminconPrintLevel, 'Algorithm','sqp');

Explanation:
Unrecognized parameter name: 'maxFunEvals'. maxFunEvals is not a parameter in the optimoptions of fmincon. MaxFunctionEvaluations is. The Algorithm parameter should be specified and the available algorithms are: interior-point, SQP, active set, and trust-region-reflective


Thanks and regards,

Sowmya Manojna




--
Thanks and Regards,
N Sowmya Manojna

Ronan M.T. Fleming

unread,
Jun 7, 2020, 10:58:09 AM6/7/20
to COBRA Toolbox
Hi Sowmya,
please could you make a PR with those suggested changes?
Regards,

Reply all
Reply to author
Forward
0 new messages