You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: doc/advancedFeatures.rst
+13-1
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,21 @@ Advanced Features
6
6
.. Parallel Execution
7
7
.. ------------------
8
8
9
+
MPI handling
10
+
------------
11
+
pyOptSparse can optionally run in parallel if a suitable ``mpi4py`` installation exists.
12
+
This will be automatically detected and imported at run-time.
13
+
14
+
If you only want to run in parallel, you can force pyOptSparse to do so by setting the environment variable
15
+
``PYOPTSPARSE_REQUIRE_MPI`` to any one of these values: ``['always', '1', 'true', 'yes']``
16
+
If a suitable ``mpi4py`` is not available, an exception will be raised and the run terminated.
17
+
18
+
If you explicitly do not wish to use ``mpi4py``, set the environment variable ``PYOPTSPARSE_REQUIRE_MPI`` to anything other than those values.
19
+
This can come in handy, for example, if your ``MPI`` installation is not functioning properly, but you still need to run serial code.
20
+
9
21
Storing Optimization History
10
22
----------------------------
11
-
pyOptSparse includes an:ref:`history` class that stores all the relevant optimization information an SQL database.
23
+
pyOptSparse includes a:ref:`history` class that stores all the relevant optimization information an SQL database.
12
24
This database is updated at every optimization iteration, and can be accessed via both the API described in the linked section, and via :ref:`optview`.
13
25
By default, the history file is NOT written.
14
26
To turn the history recording on, use the ``storeHistory`` attribute when invoking the optimization run, e.g.:
Copy file name to clipboardexpand all lines: doc/install.rst
+83-20
Original file line number
Diff line number
Diff line change
@@ -34,10 +34,12 @@ Python dependencies are automatically handled by ``pip``, so they do not need to
34
34
The only exception is ``numpy``, which is required as part of the build process and therefore must be present before installing.
35
35
36
36
.. note::
37
-
* In Linux, the python header files (python-dev) are also required.
37
+
* In Linux, the python header files (``python-dev``) are also required.
38
38
* **We do not support operating systems other than Linux.**
39
39
For macOS users, the conda package may work out of the box if you do not need any non-default optimizers.
40
-
For Windows users, `this thread <https://github.com/mdolab/pyoptsparse/issues/273>`_ may be helpful.
40
+
For Windows users, a conda package is on the way, if it's not already in the repos.
41
+
This comes with the same disclaimer as the macOS conda package.
42
+
Alternatively, follow the :ref:`conda build instructions<conda build instruction>` below as this will work on any platform.
41
43
42
44
Installation
43
45
~~~~~~~~~~~~
@@ -57,13 +59,18 @@ For those not using virtual environments, a user install may be needed
57
59
58
60
If you plan to modify pyOptSparse, installing with the developer option, i.e. with ``-e``, will save you from re-installing each time you modify the Python code.
59
61
60
-
It is also possible to install pyOptSparse by calling ``python setup.py install``, but this is not recommended.
61
-
62
62
.. note::
63
-
Some optimizers are proprietary and their sources are not distributed with pyOptSparse.
63
+
Some optimizers are proprietary, and their sources are not distributed with pyOptSparse.
64
64
To use them, please follow the instructions on specific optimizer pages.
65
-
66
-
For those who intend to use pyOptSparse with IPOPT, OpenMDAO developers provide a `bash script <https://github.com/OpenMDAO/build_pyoptsparse>`_ that simplifies the installation of the optimizer with different linear solvers.
65
+
66
+
Specifying compilers
67
+
~~~~~~~~~~~~~~~~~~~~
68
+
To specify a non-default compiler (e.g. something other than ``/usr/bin/gcc``), meson recognizes certain `special environment variables <https://mesonbuild.com/Reference-tables.html#compiler-and-linker-selection-variables>`__.
69
+
For example, to specify the Intel compilers, simply run
70
+
71
+
.. prompt:: bash
72
+
73
+
FC=$(which ifort) CC=$(which icc) pip install .
67
74
68
75
.. _install_optview:
69
76
@@ -96,7 +103,7 @@ to run all tests.
96
103
97
104
Update or Uninstall
98
105
-------------------
99
-
To update pyOptSparse, first delete the ``build`` directory, then update the package using ``git``.
106
+
To update pyOptSparse, first delete the ``meson_build`` directory, then update the package using ``git``.
100
107
For stability, users are encouraged to stick to tagged releases.
101
108
Install the package normally via ``pip``.
102
109
@@ -106,18 +113,74 @@ To uninstall the package, type
106
113
107
114
pip uninstall pyoptsparse
108
115
109
-
.. note::
110
-
pyOptSparse can optionally run in parallel if a suitable ``mpi4py``
111
-
installation exists. This will be automatically detected and
112
-
imported at run-time.
116
+
.. _conda build instruction:
117
+
118
+
Conda Build Instructions
119
+
------------------------
120
+
The following instructions explain how to build and install pyOptSparse in a conda environment.
121
+
This has the advantage that ``conda`` can be used to install all the necessary dependencies in an isolated and reproducible environment.
122
+
Considering how finicky Windows can be with ABI compatibility among various compilers, this is the recommended approach.
123
+
The guide will work on any platform, however.
124
+
125
+
The only build requirement for the build is a working ``conda`` installation as all compilers and dependencies are pulled from the ``conda-forge`` repos, with the exception of a Windows build, which requires Visual Studio 2017 C++ Build Tools.
126
+
127
+
First, we need to create the ``conda`` environment.
128
+
An ``environment.yml`` file is provided in the ``pyoptsparse`` repo:
129
+
130
+
.. tabs::
131
+
132
+
.. code-tab:: bash Linux/OSX
133
+
134
+
conda create -y -n pyos-build
135
+
conda activate pyos-build
136
+
conda config --env --add channels conda-forge
137
+
conda config --env --set channel_priority strict
138
+
139
+
conda env update -f .github/environment.yml
140
+
141
+
.. code-tab:: powershell Windows
142
+
143
+
conda create -y -n pyos-build
144
+
conda activate pyos-build
145
+
conda config --env --add channels conda-forge
146
+
conda config --env --set channel_priority strict
147
+
148
+
conda env update -f .github\environment.yml
149
+
conda install libpgmath
150
+
151
+
Next, we need to tell the compiler where to find IPOPT:
152
+
153
+
.. tabs::
154
+
155
+
.. code-tab:: bash Linux/OSX
156
+
157
+
export IPOPT_DIR="$CONDA_PREFIX"
158
+
159
+
.. code-tab:: powershell Windows
160
+
161
+
set IPOPT_DIR=%CONDA_PREFIX%\Library
162
+
163
+
Finally, build the wheel and install it using pip:
0 commit comments