Package: opty
Introductionoptyutilizes symbolic descriptions of differential algebraic equations
expressed withSymPyto form the constraints needed to solve optimal control
and parameter identification problems using the direct collocation method and
non-linear programming. In general, if one can express the continuous first
order differential algebraic equations of the system as symbolic expressionsoptywill automatically generate a function to efficiently evaluate the
dynamical constraints and a function that evaluates the sparse Jacobian of the
constraints, which have been optimized for speed and memory consumption. The
translation of the dynamical system description to the NLP form, primarily the
formation of the constraints and the Jacobian of the constraints, manually is a
time consuming and error prone process.optyeliminates both of those
issues.FeaturesBoth implicit and explicit forms of the first order ordinary differential
equations and differential algebraic equations are supported, i.e. there is
no need to solve for the derivatives of the dependent variables.Backward Euler or Midpoint integration methods.Supports both trajectory optimization and parameter identification.Easy specification of bounds on free variables.Easily specify additional “instance” constraints.Automatic parallel execution using openmp if installed.Built with support of sympy.physics.mechanics and PyDy in mind.InstallationThe required dependencies are as follows:python 3.8-3.11sympy >= 1.6.0ipopt >= 3.11 (Linux & OSX), >= 3.13 (Windows)numpy >= 1.19.0scipy >= 1.5.0cython >= 0.29.19cyipopt >= 1.1.0To run all of the examples the following additional dependencies are required:matplotlib >= 3.2.0openmppandaspydy >= 0.5.0pytablesyeadonThe easiest way to install opty is to first installAnaconda(orMiniconda)
and use the conda package manager to install opty and any desired optional
dependencies from the Conda Forge channel, e.g. opty:$ conda install --channel conda-forge optyand the optional dependencies:$ conda install --channel conda-forge matplotlib openmp pandas pydy pytables yeadonIf you want a custom installation of any of the dependencies, e.g. Ipopt, you
must first install Ipopt along with it’s headers.  For example, on Debian based
systems you can use the package manager:$ sudo apt-get install coinor-libipopt1v5 coinor-libipopt-devor prebuilt binaries can be downloaded fromhttps://www.coin-or.org/download/binary/Ipopt/.For customized installation (usually desired for performance) follow the
instructions on the IPOPT documentation to compile the library. If you install
to a location other than/usr/localon Unix systems you will likely have to
set theLD_LIBRARY_PATHso that you can link to IPOPT when installingcyipopt.Once Ipopt is installed and accessible, install conda then create an environment:$ conda create -n opty-custom -c conda-forge cython numpy pip scipy sympy
$ source activate opty-custom
(opty-custom)$ pip install cyipopt  # this will compile cyipopt against the available ipopt
(opty-custom)$ pip install optyIf you want to develop opty, create a conda environment with all of the
dependencies installed:$ conda config --add channels conda-forge
$ conda create -n opty-dev python sympy numpy scipy cython ipopt cyipopt matplotlib pytables pydy pandas pytest sphinx numpydoc
$ source activate opty-devNext download the opty source files and install with:(opty-dev)$ cd /path/to/opty
(opty-dev)$ python setup.py developUsageThere are several examples available in theexamplesdirectory. For
example, the optimal torque to swing up a pendulum with minimal energy can be
run with:$ python examples/pendulum_swing_up.pyFundingThe work was partially funded by the State of Ohio Third Frontier Commission
through the Wright Center for Sensor Systems Engineering (WCSSE), by the USA
National Science Foundation under Grant No. 1344954, and by National Center of
Simulation in Rehabilitation Research 2014 Visiting Scholarship at Stanford
University, and the CZI grant CZIF2021-006198 and grant DOIhttps://doi.org/10.37921/240361looxojfrom the Chan Zuckerberg Initiative
Foundation (funder DOI 10.13039/100014989).