Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/build_real.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ fi
mv ~/.config/pip/constraints.txt ~/.config/pip/constraints.txt.bkup
touch ~/.config/pip/constraints.txt

# set $PKG_CONFIG_PATH so pkg-config can find ipopt
# only necessary if IPOPT is installed outside of conda
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$IPOPT_DIR/lib/pkgconfig

pip install .[optview,testing] -v

# move pip constraints file back
Expand Down
2 changes: 1 addition & 1 deletion .github/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ dependencies:
# build
- python >=3.9
- numpy >=2.0
- ipopt
- swig
- meson >=1.3.2
- compilers
Expand All @@ -17,6 +16,7 @@ dependencies:
- mdolab-baseclasses >=1.3.1
- scipy >=1.7
- sqlitedict >=1.6
- cyipopt
# testing
- parameterized
- testflo
1 change: 0 additions & 1 deletion .github/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
displayName: Install mamba and update environment

- script: |
set IPOPT_DIR=%CONDA_PREFIX%\Library
set CC=cl
set FC=flang
set CC_LD=link
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
numpy_version: ["1.21.6", "1.25.2"]
numpy_version: ["1.21.6", "1.25.2", "2.1.3"]
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
Expand All @@ -39,8 +39,6 @@ jobs:
:: set fortran compiler, flang 5 activation doesn't seem to do it
set FC=flang.exe

set MESON_ARGS=-Dipopt_dir=%CONDA_PREFIX%\Library\

python -m build -n -x .

pip install --no-deps --no-index --find-links dist pyoptsparse
Expand Down
13 changes: 0 additions & 13 deletions doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,6 @@ An ``environment.yml`` file is provided in the ``pyoptsparse`` repo:
conda config --env --set channel_priority strict

conda env update -f .github\environment.yml
conda install libpgmath

Next, we need to tell the compiler where to find IPOPT:

.. tabs::

.. code-tab:: bash Linux/OSX

export IPOPT_DIR="$CONDA_PREFIX"

.. code-tab:: powershell Windows

set IPOPT_DIR=%CONDA_PREFIX%\Library

Finally, build the wheel and install it using pip:

Expand Down
67 changes: 5 additions & 62 deletions doc/optimizers/IPOPT.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,14 @@ IPOPT
=====
IPOPT (Interior Point OPTimizer) is an open source interior point optimizer, designed for large-scale nonlinear optimization.
The source code can be found `here <https://www.coin-or.org/download/source/Ipopt/>`_.
The latest version we support is 3.13.2.
The latest version we support is 3.14.17.

Installation
------------
IPOPT must be installed separately, then linked to pyOptSparse when building.
For the full installation instructions, please see `their documentation <https://coin-or.github.io/Ipopt/INSTALL.html>`_.
OpenMDAO also has a very helpful `script <https://github.com/OpenMDAO/build_pyoptsparse/>`_ which can be used to install IPOPT with other linear solvers.
Here we explain a basic setup using MUMPS as the linear solver, together with METIS adapted from the OpenMDAO script.

#. Download the tarball and extract it to ``$IPOPT_DIR`` which could be set to for example ``$HOME/packages/Ipopt``.

#. Install METIS, which can be used to improve the performance of the MUMPS linear solver.

.. code-block:: bash

# build METIS
cd $IPOPT_DIR
git clone https://github.com/coin-or-tools/ThirdParty-Metis.git
cd ThirdParty-Metis
./get.Metis
./configure --prefix=$IPOPT_DIR
make
make install

#. Install MUMPS

.. code-block:: bash

# build MUMPS
cd $IPOPT_DIR
git clone https://github.com/coin-or-tools/ThirdParty-Mumps.git
cd ThirdParty-Mumps
./get.Mumps
./configure --with-metis --with-metis-lflags="-L${IPOPT_DIR}/lib -lcoinmetis" \
--with-metis-cflags="-I${IPOPT_DIR}/include -I${IPOPT_DIR}/include/coin-or -I${IPOPT_DIR}/include/coin-or/metis" \
--prefix=$IPOPT_DIR CFLAGS="-I${IPOPT_DIR}/include -I${IPOPT_DIR}/include/coin-or -I${IPOPT_DIR}/include/coin-or/metis" \
FCFLAGS="-I${IPOPT_DIR}/include -I${IPOPT_DIR}/include/coin-or -I${IPOPT_DIR}/include/coin-or/metis"
make
make install

#. Build IPOPT

.. code-block:: bash

# build IPOPT
cd $IPOPT_DIR
mkdir build
cd build
../configure --prefix=${IPOPT_DIR} --disable-java --with-mumps --with-mumps-lflags="-L${IPOPT_DIR}/lib -lcoinmumps" \
--with-mumps-cflags="-I${IPOPT_DIR}/include/coin-or/mumps"
make
make install

#. You must add the IPOPT library path to the ``LD_LIBRARY_PATH`` variable for things to work right.
This could be done for example by adding the following to your ``.bashrc``:

.. code-block:: bash

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$IPOPT_DIR/lib

Furthermore, the environment variable ``$IPOPT_DIR`` must be set correctly in order to link to pyOptSparse.
Alternatively, you can manually define the variables ``$IPOPT_LIB`` and ``$IPOPT_INC`` for the lib and include paths separately.


#. Now clean build pyOptSparse. Verify that IPOPT works by running the relevant tests.
IPOPT and its Python interface `cyipopt <https://github.com/mechmotum/cyipopt>` must be installed separately.
Follow the instructions `here <https://cyipopt.readthedocs.io/en/stable/install.html>`_.
OpenMDAO also has a very helpful `script <https://github.com/OpenMDAO/build_pyoptsparse/>`_ which can be used to install IPOPT with other linear solvers,
but it does not install ``cyipopt`` for you.

Options
-------
Expand Down
3 changes: 0 additions & 3 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
option('ipopt_dir', type: 'string', value: '',
description: 'Top-level dir for ipopt')

option('incdir_numpy', type: 'string', value: '',
description: 'Include directory for numpy. If left empty Meson will try to find it on its own.')

Expand Down
1 change: 0 additions & 1 deletion pyoptsparse/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ inc_f2py = include_directories(incdir_f2py)
#)

subdir('pySNOPT')
subdir('pyIPOPT')
subdir('pySLSQP')
subdir('pyCONMIN')
subdir('pyNLPQLP')
Expand Down
60 changes: 5 additions & 55 deletions pyoptsparse/pyIPOPT/meson.build
Original file line number Diff line number Diff line change
@@ -1,60 +1,10 @@
fs = import('fs')

if get_option('ipopt_dir') != '' or fs.is_dir('Ipopt')

ipopt_dir = ''

if get_option('ipopt_dir') != ''
ipopt_dir = get_option('ipopt_dir')
elif fs.is_dir('Ipopt')
ipopt_dir = fs.is_dir('Ipopt')
endif

ipopt_lib = []
ipopt_idir = ''

# Ipopt installs differently on some systems (i.e. Fedora)
if fs.is_dir(ipopt_dir / 'lib')
ipopt_lib = [ipopt_dir / 'lib']
elif fs.is_dir(ipopt_dir / 'lib64')
ipopt_lib = [ipopt_dir / 'lib64']
endif


if fs.is_dir(ipopt_dir / 'include' / 'coin-or')
ipopt_idir = ipopt_dir / 'include' / 'coin-or'
elif fs.is_dir(ipopt_dir / 'include' / 'coin')
ipopt_idir = ipopt_dir / 'include' / 'coin'
endif

ipopt_dep = cc.find_library('ipopt-3', required: false, dirs: ipopt_lib) # only relevant on windows
if not ipopt_dep.found()
ipopt_dep = cc.find_library('ipopt', required: true, dirs: ipopt_lib)
endif

if fs.is_dir(ipopt_idir)
ipopt_inc = include_directories(ipopt_idir)
else
error('IPOPT include directory not found: ', ipopt_dir)
endif

py3_target.extension_module('pyipoptcore',
'src/callback.c',
'src/pyipoptcoremodule.c',
include_directories: [inc_np, 'src', ipopt_inc],
dependencies : [py3_dep, ipopt_dep],
subdir: 'pyoptsparse/pyIPOPT',
link_language: 'c',
install : false)
endif

#python_sources = [
# python_sources = [
# '__init__.py',
# 'pyIPOPT.py',
#]
#
#py3_target.install_sources(
# ]

# py3_target.install_sources(
# python_sources,
# pure: false,
# subdir: 'pyoptsparse/pyIPOPT'
#)
# )
Loading