If you require one of ASL, pyadolc, pycppad, MUMPS, qr_mumps or SuiteSparse, installing NLP.py will be much easier if you use Homebrew.
Follow the instructions to install Homebrew and import the science formulas:
brew tap homebrew/scienceInstall numpy and PyKrylov:
pip install -q numpy
pip install -q git+https://github.com/PythonOptimizers/pykrylov.git@developpip install -q git+https://github.com/PythonOptimizers/cysparse.gitpip install -q git+https://github.com/optimizers/pysparse.gitpip install -q scipyThe ASL will allow AMPL models to be loaded in NLP.py after they have been decoded to a .nl file.
Creating the .nl file for anything else than small models requires an AMPL license.
A few sample .nl files are included with NLP.py.
The ASL will compute sparse first and second derivatives.
The ASL may be installed from Homebrew:
brew install aslSpecify the location of the ASL in setup.cfg:
echo "[ASL]" > site.cfg
echo "asl_dir = $(brew --prefix asl)" >> site.cfgADOL-C will allow models to be coded up directly in Python and sparse first and second derivatives to be computed via automatic differentiation. This is the preferred way to model large-scale problems in Python. First install ADOL-C:
brew install adol-c # will also install Colpack
brew install boost-pythonThen install pyadolc:
cd $HOME # or another local
git clone https://github.com/b45ch1/pyadolc.git && cd pyadolc
python setup.py install # press [Enter] when promptedCppAD will allow models to be coded up directly in Python and dense first and second derivatives to be computed via automatic differentiation.
First install CppAD:
brew install cppad [--with-adol-c] --with-openmpThen install pycppad:
pip install -q git+https://github.com/b45ch1/pycppad.gitAlgoPy will allow models to be coded up directly in Python and dense first and second derivatives to be computed via automatic differentiation.
pip install -q algopyFollow instructions at https://github.com/PythonOptimizers/HSL.py
Follow instructions at https://github.com/PythonOptimizers/MUMPS.py
Follow instructions at https://github.com/PythonOptimizers/qr_mumps.py
Follow instructions at https://github.com/PythonOptimizers/SuiteSparse.py
If you encounter build errors while installing pyadolc, edit and change setup.py as follows:
diff --git a/setup.py b/setup.py
index 5e6e695..68f5c68 100644
--- a/setup.py
+++ b/setup.py
@@ -36,7 +36,7 @@ colpack_lib_path1 = os.path.join(COLPACK_DIR, 'lib')
colpack_lib_path2 = os.path.join(COLPACK_DIR, 'lib64')
# ADAPT THIS TO FIT YOUR SYSTEM
-extra_compile_args = ['-std=c++11 -ftemplate-depth-100 -DBOOST_PYTHON_DYNAMIC_LIB']
+extra_compile_args = ['-std=c++11 -stdlib=libc++ -mmacosx-version-min=10.9 -ftemplate-depth-100 -DBOOST_PYTHON_DYNAMIC_LIB']
include_dirs = [get_numpy_include_dirs()[0], boost_include_path, adolc_include_path, colpack_include_path]
library_dirs = [boost_library_path1, boost_library_path2, adolc_library_path1, adolc_library_path2, colpack_lib_path1, colpack_lib_path2]
libraries = ['boost_python','adolc', 'ColPack']