# Installing Dymos

## Basic installation

Dymos can be installed from pip using

~~~bash
python -m pip install dymos
~~~

The cutting-edge development version of Dymos may be installed with

~~~bash
python -m pip install git+https://github.com/OpenMDAO/dymos.git
~~~

## Installation (developer mode)

If you intend to modify Dymos, build the documentation, or run the tests locally, you should add `[all]` to the PIP installation to include some documentation and testing-specific installation dependencies.

After cloning out Dymos to a local directory, installing using the `-e` flag installs Dymos in "developer mode."
This removes the need to reinstall Dymos after changes are made.

~~~bash
git clone https://github.com/OpenMDAO/dymos.git ./dymos.git
python -m pip install -e dymos.git[all]
~~~

## Installing Advanced Dependencies

Many of the simple dependencies for Dymos are installed via pip, however a few more dependencies are required in some more advanced use-cases.

### pyoptsparse (recommended)

Dymos will work "out-of-the-box" using OpenMDAO's `ScipyOptimizeDriver` for many of the more simple problems.
For more complex problems, the implicit optimization techniques used by Dymos can easily generate problems with hundreds or even thousands of design variables and constraints.
When the nonlinear optimization problems generated by Dymos become that complicated, the free optimizers available via `ScipyOptimizeDriver` can struggle to converge.

For this reason, the authors tend to use the open-source [IPOPT](https://coin-or.github.io/Ipopt/) optimizer or the proprietary [SNOPT](https://ccom.ucsd.edu/~optimizers/solvers/snopt/) optimizer.
Both of these optimizers are able to capitalize on the _sparse_ nature of the optimal control problems generated by Dymos, significantly reducing the time and memory required to solve problems.

For uniform access to a variety of optimizers, including `SLSQP`, `IPOPT`, and `SNOPT`, Dymos uses OpenMDAO's `pyOptSparseDriver`, which interfaces to these external optimizers via [pyoptsparse](https://github.com/mdolab/pyoptsparse), produced by MDOLab at the University of Michigan.

Users on OS X and Linux systems can use our script, available at [(https://github.com/OpenMDAO/build_pyoptsparse)](https://github.com/OpenMDAO/build_pyoptsparse) to build and install pyoptsparse with support for IPOPT.
The script will also handle support for SNOPT if the user has access to the SNOPT source code.

Installing these dependencies on Windows-based systems requires [Intel Fortran](https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/fortran-compiler.html).
Free Fortran compilers on Windows, at the time of this writing, are not compatible with the Microsoft ABI used by Python on Windows.

### mpi4py and petsc4py

Together, `mpi4py` and `petsc4py` enable parallel processing in Dymos via MPI.
The easiest way to install `mpi4py` is to use the [anaconda](https://www.anaconda.com/products/individual) python environment.

```
    conda create -n py38 python=3.8;
    conda activate py38;
    conda config --add channels conda-forge;
    conda install mpi4py
    conda install petsc4py
```

MPI capability is generally only necessary in some very niche use-cases.
