Ipopt gives MPI errors

IPOPT installed via homebrew (on a macOS GitHub Actions container) fails with MPI errors. It appears the ipopt.rb formula builds IPOPT with the MPI version of MUMPS, which I don’t believe is compatible with IPOPT.

I use Octave with IPOPT for continuous integration testing of some of my code via GitHub Actions, using both Linux and macOS containers. On the Linux containers everything works as expected, but on the macOS container the Homebrew installed ipopt package results in the MPI errors described below, so at the moment I have to re-build IPOPT from source.

I use Homebrew to install IPOPT and Octave in the macOS container …

brew update
brew install pkg-config
brew install ipopt
brew install octave

… then grab the corresponding source from the coin-or.org site, and build the Octave MEX interface using the Makefile below, as follows:

export IPOPT_VER=3.11.9
mkdir $HOME/build
curl -SL https://www.coin-or.org/download/source/Ipopt/Ipopt-${IPOPT_VER}.tgz | tar -xzC $HOME/build
mv $HOME/build/Ipopt-${IPOPT_VER}/Ipopt/contrib/MatlabInterface $HOME/build/ipopt
mv $GITHUB_WORKSPACE/Makefile $HOME/build/ipopt/src
make -C $HOME/build/ipopt/src

It builds fine, but at runtime, when attempting to call the MEX file from Octave, I get the following error:

*** The MPI_Comm_f2c() function was called before MPI_INIT was invoked.
*** This is disallowed by the MPI standard.
*** Your MPI job will now abort.

If, instead of installing IPOPT via Homebrew, I build IPOPT from source using the following:

git clone https://www.github.com/coin-or/coinbrew
cd coinbrew
./coinbrew fetch Ipopt --no-prompt
./coinbrew build Ipopt --prefix=$HOME/install --test --no-prompt
./coinbrew install Ipopt

… then build the MEX interface, it works just fine.

I think the solution is a simple matter of modifying the ipopt.rb formula to use a non-MPI MUMPS, but I’m not sure how to do that.


Makefile contents:

# Copyright 2017 Richard Lincoln. All rights reserved.

OBJS = callbackfunctions.o \
       ipoptoptions.o \
       ipopt.o \
       iterate.o \
       matlabexception.o \
       matlabfunctionhandle.o \
       matlabinfo.o \
       matlabjournal.o \
       matlabprogram.o \
       options.o \


INCL = `pkg-config --cflags ipopt` -I`mkoctfile -p OCTINCLUDEDIR`
LIBS = `pkg-config --libs ipopt`

all: ipopt.mex

%.o: %.cpp
    g++ $(CXXFLAGS) $(INCL) -o $@ -c $^

ipopt.mex: $(OBJS)
    mkoctfile $(LIBS) -v --mex --output $@ $^

    rm -f $(OBJS) ipopt.mex

    octave-cli --no-gui -p `pwd`/examples --eval "examplehs038;examplehs051;examplehs071;examplelasso"

Do you know if there’s documentation supporting this? Mailing list posts, etc. would be good to look at as well, thanks!

It looks like removing -lmpiseq is sufficient: https://github.com/Homebrew/homebrew-science/blob/e5d38cf4996e7ea985944edfca89a484f071708c/ipopt.rb#L20-L29, but I think someone who is more familiar with these packages should probably take a look.

Not sure if this helps, but here is a response from Ted Ralphs to my post on the Ipopt mailing list about this issue. It includes a link to yet another Ipopt recipe that might be helpful.