[Ipopt] Pb Ipopt-Matlab

Tony Kelman kelman at berkeley.edu
Tue May 6 17:19:19 EDT 2014


Yes I am pretty much the authority on this topic, but it’s always good to email the Ipopt mailing list - I (and other knowledgeable subscribers) respond to any messages there that I know how to answer, and other people who run into the same problem can look up the discussion in the future by searching the archives.

What is most likely the case is that Matlab’s included copies of the runtime libraries for libgfortran, libstdc++, libblas, and/or liblapack are not compatible with the runtime libraries of the default compilers and system libraries - in Ubuntu 14.04 it looks like the default compiler version is GCC 4.8.x. For Matlab 2012a, Mathworks recommends using gcc/g++ 4.4, and strangely gfortran 4.3 (I’ve seen 4.4 has worked okay for people in the past though), see http://www.mathworks.com/support/compilers/R2012a/glnxa64.html .

You should be able to install the 4.4 compiler versions in Ubuntu with `sudo apt-get install g++-4.4 gfortran-4.4`. Then you tell Ipopt configure to use these with “CC=gcc-4.4 CXX=g++-4.4 F77=gfortran-4.4”. It is possible to use newer compiler versions if you statically link the runtime libraries into the mex file (that’s what I did for the binary download mex file here http://www.coin-or.org/download/binary/Ipopt/Ipopt-3.11.0-linux64mac64win32win64-matlabmexfiles.zip , did you try that?), but you have to compile GCC itself using --with-pic which isn’t the default setting. Not worth the time unless you’re trying to create a single mex file that can be used across a variety of different Linux distributions and Matlab versions.

If your system has libblas and liblapack installed, then you’ll also need to tell Ipopt to instead build static versions of the reference libraries with “--disable-shared --with-pic --with-blas=BUILD --with-lapack=BUILD”.

-Tony


From: Edouard Oudet 
Sent: Tuesday, May 06, 2014 8:03 AM
To: kelman at berkeley.edu 
Subject: Pb Ipopt-Matlab

Dear Tony,

I am trying to link matlab and the Ipopt library and I understood from Internet that you are an expert in such a game... I am sure that you have a lot of more interesting things to do but some comments/recommendations would be great !

I am under ubuntu 14.04 linux 64b and matlab 2012a.

I succeeded in compiling Ipopt. See the output of the example below and here my configure options 

./configure --prefix=${IPOPTDIR} ADD_CXXFLAGS="-fPIC -fexceptions" ADD_CFLAGS="-fPIC -fexceptions" ADD_FFLAGS="-fPIC -fexceptions" --with-matlab-home=${MATLAB_HOME}

Then I tried to compile the Matlab interface based on the web page

https://projects.coin-or.org/Ipopt/wiki/MatlabInterface

I went to the /contrib/MatlabInterface/src and run make and obtained an ipopt.mexa64  file (I encountered the warning  below on the -largeArrayDims option).

Finally I tried to call Ipopt by the provided example 

>> examplehs051

******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************

This is Ipopt version 3.11.8, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).

Number of nonzeros in equality constraint Jacobian...:        7
Number of nonzeros in inequality constraint Jacobian.:        0
Number of nonzeros in Lagrangian Hessian.............:        0


------------------------------------------------------------------------
       Segmentation violation detected at Tue May  6 16:54:20 2014
------------------------------------------------------------------------

....

Which is not completely satisfactory.
Do you have any idea of what could be the source of the problem ?
Thanks a lot for the time you spent reading my email,

all the best,

Edouard Oudet.






//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
**************************************************************************
  Warning: Neither -compatibleArrayDims nor -largeArrayDims is selected. 
           Using -compatibleArrayDims. In the future, MATLAB will require
           the use of -largeArrayDims and remove the -compatibleArrayDims
           option. For more information, see:
           http://www.mathworks.com/help/techdoc/matlab_external/bsflnue-1.html
**************************************************************************

-> mexopts.sh sourced from directory (DIR = $MATLAB/bin)
   FILE = /usr/local/matlab2012a/bin/mexopts.sh
----------------------------------------------------------------
->    MATLAB                = /usr/local/matlab2012a
->    CC                    = g++ 
->    CC flags:
         CFLAGS             = -ansi -D_GNU_SOURCE  -fexceptions -fPIC -fno-omit-frame-pointer -pthread
         CDEBUGFLAGS        = -g
         COPTIMFLAGS        = -O3 -fPIC -fexceptions -pipe -DNDEBUG -pedantic-errors -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-long-long -fPIC -fexceptions  -DIPOPT_BUILD -DMATLAB_MEXFILE 
         CLIBS              = -Wl,-rpath-link,/usr/local/matlab2012a/bin/glnxa64 -L/usr/local/matlab2012a/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++
         arguments          = 
->    CXX                   = g++ 
->    CXX flags:
         CXXFLAGS           = -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread
         CXXDEBUGFLAGS      = -g
         CXXOPTIMFLAGS      = -O3 -fPIC -fexceptions -pipe -DNDEBUG -pedantic-errors -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-long-long -fPIC -fexceptions  -DIPOPT_BUILD -DMATLAB_MEXFILE 
         CXXLIBS            = -Wl,-rpath-link,/usr/local/matlab2012a/bin/glnxa64 -L/usr/local/matlab2012a/bin/glnxa64 -lmx -lmex -lmat -lm
         arguments          = 
->    FC                    = gfortran
->    FC flags:
         FFLAGS             = -fexceptions -fbackslash -fPIC -fno-omit-frame-pointer
         FDEBUGFLAGS        = -g
         FOPTIMFLAGS        = -O
         FLIBS              = -Wl,-rpath-link,/usr/local/matlab2012a/bin/glnxa64 -L/usr/local/matlab2012a/bin/glnxa64 -lmx -lmex -lmat -lm
         arguments          = 
->    LD                    = g++
->    Link flags:
         LDFLAGS            = -pthread -shared -Wl,--version-script,/usr/local/matlab2012a/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined
         LDDEBUGFLAGS       = -g
         LDOPTIMFLAGS       = -O3 -fPIC -fexceptions -pipe -DNDEBUG -pedantic-errors -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-long-long -fPIC -fexceptions  -DIPOPT_BUILD -DMATLAB_MEXFILE   -Wl,--rpath -Wl,/home/oudet/C++/Ipopt-3.11.8/lib  
         LDEXTENSION        = .mexa64
         arguments          =  -L/home/oudet/C++/Ipopt-3.11.8/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -lipopt -llapack -ldl -lcoinmumps -lblas -lgfortran -lm -lquadmath -lcoinmetis
->    LDCXX                 = 
->    Link flags:
         LDCXXFLAGS         = 
         LDCXXDEBUGFLAGS    = 
         LDCXXOPTIMFLAGS    = 
         LDCXXEXTENSION     = 
         arguments          =  -L/home/oudet/C++/Ipopt-3.11.8/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -lipopt -llapack -ldl -lcoinmumps -lblas -lgfortran -lm -lquadmath -lcoinmetis
----------------------------------------------------------------






/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
./hs071_c 

******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************

This is Ipopt version 3.11.8, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).

Number of nonzeros in equality constraint Jacobian...:        4
Number of nonzeros in inequality constraint Jacobian.:        4
Number of nonzeros in Lagrangian Hessian.............:       10

Total number of variables............................:        4
                     variables with only lower bounds:        0
                variables with lower and upper bounds:        4
                     variables with only upper bounds:        0
Total number of equality constraints.................:        1
Total number of inequality constraints...............:        1
        inequality constraints with only lower bounds:        1
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  1.6109693e+01 1.12e+01 5.28e-01   0.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  1.7410406e+01 7.49e-01 2.25e+01  -0.3 7.97e-01    -  3.19e-01 1.00e+00f  1
   2  1.8001613e+01 7.52e-03 4.96e+00  -0.3 5.60e-02   2.0 9.97e-01 1.00e+00h  1
   3  1.7199482e+01 4.00e-02 4.24e-01  -1.0 9.91e-01    -  9.98e-01 1.00e+00f  1
   4  1.6940955e+01 1.59e-01 4.58e-02  -1.4 2.88e-01    -  9.66e-01 1.00e+00h  1
   5  1.7003411e+01 2.16e-02 8.42e-03  -2.9 7.03e-02    -  9.68e-01 1.00e+00h  1
   6  1.7013974e+01 2.03e-04 8.65e-05  -4.5 6.22e-03    -  1.00e+00 1.00e+00h  1
   7  1.7014017e+01 2.76e-07 2.18e-07 -10.3 1.43e-04    -  9.99e-01 1.00e+00h  1
   8  1.7014017e+01 3.55e-14 2.23e-14 -11.0 1.04e-07    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 8

                                   (scaled)                 (unscaled)
Objective...............:   1.7014017140224134e+01    1.7014017140224134e+01
Dual infeasibility......:   2.2261967499857942e-14    2.2261967499857942e-14
Constraint violation....:   3.5527136788005009e-14    3.5527136788005009e-14
Complementarity.........:   1.0023967333275307e-11    1.0023967333275307e-11
Overall NLP error.......:   1.0023967333275307e-11    1.0023967333275307e-11


Number of objective function evaluations             = 9
Number of objective gradient evaluations             = 9
Number of equality constraint evaluations            = 9
Number of inequality constraint evaluations          = 9
Number of equality constraint Jacobian evaluations   = 9
Number of inequality constraint Jacobian evaluations = 9
Number of Lagrangian Hessian evaluations             = 8
Total CPU secs in IPOPT (w/o function evaluations)   =      0.005
Total CPU secs in NLP function evaluations           =      0.000

EXIT: Optimal Solution Found.


Solution of the primal variables, x
x[0] = 1.000000e+00
x[1] = 4.743000e+00
x[2] = 3.821150e+00
x[3] = 1.379408e+00


Solution of the ccnstraint multipliers, lambda
lambda[0] = -5.522937e-01
lambda[1] = 1.614686e-01


Solution of the bound multipliers, z_L and z_U
z_L[0] = 1.087871e+00
z_L[1] = 2.671608e-12
z_L[2] = 3.544911e-12
z_L[3] = 2.635449e-11
z_U[0] = 2.499943e-12
z_U[1] = 3.896984e-11
z_U[2] = 8.482036e-12
z_U[3] = 2.762163e-12


Objective value
f(x*) = 1.701402e+01
This is Ipopt version 3.11.8, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).

Number of nonzeros in equality constraint Jacobian...:        4
Number of nonzeros in inequality constraint Jacobian.:        4
Number of nonzeros in Lagrangian Hessian.............:       10

Total number of variables............................:        4
                     variables with only lower bounds:        0
                variables with lower and upper bounds:        4
                     variables with only upper bounds:        0
Total number of equality constraints.................:        1
Total number of inequality constraints...............:        1
        inequality constraints with only lower bounds:        1
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:        0

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  1.7014163e+01 2.00e-05 1.03e-03   0.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  1.6904734e+01 1.84e-04 1.25e-04  -3.9 2.00e-01    -  1.00e+00 9.92e-01f  1
   2  1.6903619e+01 3.03e-07 2.65e-07  -9.7 2.00e-03    -  9.99e-01 9.99e-01h  1
   3  1.6903618e+01 2.98e-13 3.15e-13 -11.0 2.21e-06    -  1.00e+00 1.00e+00h  1

Number of Iterations....: 3

                                   (scaled)                 (unscaled)
Objective...............:   1.6903617923661113e+01    1.6903617923661113e+01
Dual infeasibility......:   3.1514426168633523e-13    3.1514426168633523e-13
Constraint violation....:   2.9842794901924208e-13    2.9842794901924208e-13
Complementarity.........:   1.0321836080683101e-11    1.0321836080683101e-11
Overall NLP error.......:   1.0321836080683101e-11    1.0321836080683101e-11


Number of objective function evaluations             = 4
Number of objective gradient evaluations             = 4
Number of equality constraint evaluations            = 4
Number of inequality constraint evaluations          = 5
Number of equality constraint Jacobian evaluations   = 4
Number of inequality constraint Jacobian evaluations = 4
Number of Lagrangian Hessian evaluations             = 3
Total CPU secs in IPOPT (w/o function evaluations)   =      0.002
Total CPU secs in NLP function evaluations           =      0.000

EXIT: Optimal Solution Found.


Solution of the primal variables, x
x[0] = 1.000000e+00
x[1] = 4.749269e+00
x[2] = 3.817510e+00
x[3] = 1.367870e+00


Solution of the ccnstraint multipliers, lambda
lambda[0] = -5.517016e-01
lambda[1] = 1.592915e-01


Solution of the bound multipliers, z_L and z_U
z_L[0] = 1.090362e+00
z_L[1] = 2.664877e-12
z_L[2] = 3.556758e-12
z_L[3] = 2.693832e-11
z_U[0] = 2.498100e-12
z_U[1] = 4.074104e-11
z_U[2] = 8.423997e-12
z_U[3] = 2.755724e-12


Objective value
f(x*) = 1.690362e+01





-- 
Edouard Oudet : http://www-ljk.imag.fr/membres/Edouard.Oudet/
Bureau 51
LJK, UMR 5224, Université Joseph Fourier
Tour IRMA, BP 53
51, rue des Mathématiques
F-38041 Grenoble Cedex 9
+33 (0)4 76 51 46 75  (office LJK)
+33 (0)4 76 51 40 30  (office UFR)
+33 (0)4 79 75 87 65  (office LAMA)
+33 (0)4 79 68 82 06  (home)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/ipopt/attachments/20140506/fb9050ee/attachment-0001.html>


More information about the Ipopt mailing list