opty


Nameopty JSON
Version 1.3.0 PyPI version JSON
download
home_pagehttp://github.com/csu-hmc/opty
SummaryTool for optimizing dynamic systems using direct collocation.
upload_time2024-08-05 08:21:24
maintainerNone
docs_urlNone
authorJason K. Moore
requires_pythonNone
licenseBSD-2-clause
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Introduction
============

.. list-table::

   * - PyPi
     - .. image:: https://img.shields.io/pypi/v/opty.svg
          :target: https://pypi.org/project/opty
       .. image:: https://pepy.tech/badge/opty
          :target: https://pypi.org/project/opty
   * - Anaconda
     - .. image:: https://anaconda.org/conda-forge/opty/badges/version.svg
          :target: https://anaconda.org/conda-forge/opty
       .. image:: https://anaconda.org/conda-forge/opty/badges/downloads.svg
          :target: https://anaconda.org/conda-forge/opty
   * - Documentation
     - .. image:: https://readthedocs.org/projects/opty/badge/?version=stable
          :target: http://opty.readthedocs.io
   * - JOSS Paper
     - .. image:: http://joss.theoj.org/papers/10.21105/joss.00300/status.svg
          :target: https://doi.org/10.21105/joss.00300
   * - Zenodo Archive
     - .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1162870.svg
          :target: https://doi.org/10.5281/zenodo.1162870
   * - Continous Integration
     - .. image:: https://github.com/csu-hmc/opty/actions/workflows/tests.yml/badge.svg

``opty`` utilizes symbolic descriptions of differential algebraic equations
expressed with SymPy_ to form the constraints needed to solve optimal control
and parameter identification problems using the direct collocation method and
non-linear programming (NLP). In general, if one can express the continuous
first order differential algebraic equations of the system as symbolic
expressions ``opty`` will 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. ``opty``
eliminates both of those issues.

.. _SymPy: http://www.sympy.org

Features
--------

- Both 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,
  independently or simultaneously.
- Solve fixed duration or variable duration problems.
- Easy specification of bounds on free variables.
- Easily specify additional "instance" constraints.
- Efficient numerical execution of large equations of motion.
- Automatic parallel execution using openmp if installed.
- Built with support of sympy.physics.mechanics and PyDy in mind.

Installation
============

The required dependencies are as follows:

- cyipopt >= 1.1.0 [with ipopt >= 3.11 (Linux & OSX), >= 3.13 (Windows)]
- cython >= 0.29.19 [with a C compiler]
- numpy >= 1.19.0
- python 3.8-3.12
- scipy >= 1.5.0
- sympy >= 1.6.0

The optional dependencies are as follows:

- matplotlib >= 3.2.0
- openmp

To run all of the examples the following additional dependencies may be needed:

- pandas
- pydy >= 0.5.0
- pytables
- yeadon

The easiest way to install opty is to first install Anaconda_ (or Miniconda_ or
Miniforge_) 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 opty

and the optional dependencies::

   $ conda install --channel conda-forge matplotlib openmp pandas pydy pytables yeadon

.. _Anaconda: https://www.continuum.io/downloads
.. _Miniconda: https://conda.io/miniconda.html
.. _Miniforge: https://conda-forge.org/miniforge/

Opty can be installed with pip, but this will require installing and compiling
cyipopt if it is not already installed::

   $ pip install opty

See the `cyipopt documentation`_ for information on installing that package.

.. _cyipopt documentation: https://cyipopt.readthedocs.io

Custom Ipopt
------------

If 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-dev

or prebuilt binaries can be downloaded from
https://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/local`` on Unix systems you will likely have to
set the ``LD_LIBRARY_PATH`` so that you can link to Ipopt when installing
``cyipopt``.

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 opty

If 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 sphinx-gallery numpydoc
   $ source activate opty-dev

Next download the opty source files and install with::

   (opty-dev)$ cd /path/to/opty
   (opty-dev)$ python setup.py develop

Usage
=====

There are several examples available in the ``examples`` and
``examples-gallery`` directories. The optimal torque to swing up a pendulum
with minimal energy can be run with::

   $ python examples-gallery/plot_pendulum_swing_up_fixed_duration.py

Failed Compilation
------------------

If compilation fails it may be helpful to manually compile the generated Cython
extension. To do so, provide a destination path to the ``tmp_dir`` kwarg when
you instantiate ``Problem()``, e.g.:

.. code:: python

   p = Problem(..., tmp_dir='opty_source')

You can then compile the files manually by navigating into the ``opty_source``
directory and running::

   $ cd /path/to/opty_source
   $ python ufuncify_matrix_X_setup.py build_ext --inplace

The highest integer value of ``X`` will be the most recently generated set of
source files.

Build Documentation
===================

Build the HTML documentation with::

   (opty-dev)$ cd /path/to/opty/docs
   (opty-dev)$ make html

and open the result with your web browser, for example::

   $ firefox _build/html/index.html

Funding
=======

The 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 DOI
https://doi.org/10.37921/240361looxoj from the Chan Zuckerberg Initiative
Foundation (funder DOI 10.13039/100014989).

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/csu-hmc/opty",
    "name": "opty",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Jason K. Moore",
    "author_email": "moorepants@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/98/ae/f3d9f6c87bac7f6558e3ba36bb093b0426d9e5194af6679f608ad4124478/opty-1.3.0.tar.gz",
    "platform": null,
    "description": "Introduction\n============\n\n.. list-table::\n\n   * - PyPi\n     - .. image:: https://img.shields.io/pypi/v/opty.svg\n          :target: https://pypi.org/project/opty\n       .. image:: https://pepy.tech/badge/opty\n          :target: https://pypi.org/project/opty\n   * - Anaconda\n     - .. image:: https://anaconda.org/conda-forge/opty/badges/version.svg\n          :target: https://anaconda.org/conda-forge/opty\n       .. image:: https://anaconda.org/conda-forge/opty/badges/downloads.svg\n          :target: https://anaconda.org/conda-forge/opty\n   * - Documentation\n     - .. image:: https://readthedocs.org/projects/opty/badge/?version=stable\n          :target: http://opty.readthedocs.io\n   * - JOSS Paper\n     - .. image:: http://joss.theoj.org/papers/10.21105/joss.00300/status.svg\n          :target: https://doi.org/10.21105/joss.00300\n   * - Zenodo Archive\n     - .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1162870.svg\n          :target: https://doi.org/10.5281/zenodo.1162870\n   * - Continous Integration\n     - .. image:: https://github.com/csu-hmc/opty/actions/workflows/tests.yml/badge.svg\n\n``opty`` utilizes symbolic descriptions of differential algebraic equations\nexpressed with SymPy_ to form the constraints needed to solve optimal control\nand parameter identification problems using the direct collocation method and\nnon-linear programming (NLP). In general, if one can express the continuous\nfirst order differential algebraic equations of the system as symbolic\nexpressions ``opty`` will automatically generate a function to efficiently\nevaluate the dynamical constraints and a function that evaluates the sparse\nJacobian of the constraints, which have been optimized for speed and memory\nconsumption. The translation of the dynamical system description to the NLP\nform, primarily the formation of the constraints and the Jacobian of the\nconstraints, manually is a time consuming and error prone process. ``opty``\neliminates both of those issues.\n\n.. _SymPy: http://www.sympy.org\n\nFeatures\n--------\n\n- Both implicit and explicit forms of the first order ordinary differential\n  equations and differential algebraic equations are supported, i.e. there is\n  no need to solve for the derivatives of the dependent variables.\n- Backward Euler or Midpoint integration methods.\n- Supports both trajectory optimization and parameter identification,\n  independently or simultaneously.\n- Solve fixed duration or variable duration problems.\n- Easy specification of bounds on free variables.\n- Easily specify additional \"instance\" constraints.\n- Efficient numerical execution of large equations of motion.\n- Automatic parallel execution using openmp if installed.\n- Built with support of sympy.physics.mechanics and PyDy in mind.\n\nInstallation\n============\n\nThe required dependencies are as follows:\n\n- cyipopt >= 1.1.0 [with ipopt >= 3.11 (Linux & OSX), >= 3.13 (Windows)]\n- cython >= 0.29.19 [with a C compiler]\n- numpy >= 1.19.0\n- python 3.8-3.12\n- scipy >= 1.5.0\n- sympy >= 1.6.0\n\nThe optional dependencies are as follows:\n\n- matplotlib >= 3.2.0\n- openmp\n\nTo run all of the examples the following additional dependencies may be needed:\n\n- pandas\n- pydy >= 0.5.0\n- pytables\n- yeadon\n\nThe easiest way to install opty is to first install Anaconda_ (or Miniconda_ or\nMiniforge_) and use the conda package manager to install opty and any desired\noptional dependencies from the Conda Forge channel, e.g. opty::\n\n   $ conda install --channel conda-forge opty\n\nand the optional dependencies::\n\n   $ conda install --channel conda-forge matplotlib openmp pandas pydy pytables yeadon\n\n.. _Anaconda: https://www.continuum.io/downloads\n.. _Miniconda: https://conda.io/miniconda.html\n.. _Miniforge: https://conda-forge.org/miniforge/\n\nOpty can be installed with pip, but this will require installing and compiling\ncyipopt if it is not already installed::\n\n   $ pip install opty\n\nSee the `cyipopt documentation`_ for information on installing that package.\n\n.. _cyipopt documentation: https://cyipopt.readthedocs.io\n\nCustom Ipopt\n------------\n\nIf you want a custom installation of any of the dependencies, e.g. Ipopt, you\nmust first install Ipopt along with it's headers.  For example, on Debian based\nsystems you can use the package manager::\n\n   $ sudo apt-get install coinor-libipopt1v5 coinor-libipopt-dev\n\nor prebuilt binaries can be downloaded from\nhttps://www.coin-or.org/download/binary/Ipopt/.\n\nFor customized installation (usually desired for performance) follow the\ninstructions on the Ipopt documentation to compile the library. If you install\nto a location other than ``/usr/local`` on Unix systems you will likely have to\nset the ``LD_LIBRARY_PATH`` so that you can link to Ipopt when installing\n``cyipopt``.\n\nOnce Ipopt is installed and accessible, install conda then create an environment::\n\n   $ conda create -n opty-custom -c conda-forge cython numpy pip scipy sympy\n   $ source activate opty-custom\n   (opty-custom)$ pip install cyipopt  # this will compile cyipopt against the available ipopt\n   (opty-custom)$ pip install opty\n\nIf you want to develop opty, create a conda environment with all of the\ndependencies installed::\n\n   $ conda config --add channels conda-forge\n   $ conda create -n opty-dev python sympy numpy scipy cython ipopt cyipopt matplotlib pytables pydy pandas pytest sphinx sphinx-gallery numpydoc\n   $ source activate opty-dev\n\nNext download the opty source files and install with::\n\n   (opty-dev)$ cd /path/to/opty\n   (opty-dev)$ python setup.py develop\n\nUsage\n=====\n\nThere are several examples available in the ``examples`` and\n``examples-gallery`` directories. The optimal torque to swing up a pendulum\nwith minimal energy can be run with::\n\n   $ python examples-gallery/plot_pendulum_swing_up_fixed_duration.py\n\nFailed Compilation\n------------------\n\nIf compilation fails it may be helpful to manually compile the generated Cython\nextension. To do so, provide a destination path to the ``tmp_dir`` kwarg when\nyou instantiate ``Problem()``, e.g.:\n\n.. code:: python\n\n   p = Problem(..., tmp_dir='opty_source')\n\nYou can then compile the files manually by navigating into the ``opty_source``\ndirectory and running::\n\n   $ cd /path/to/opty_source\n   $ python ufuncify_matrix_X_setup.py build_ext --inplace\n\nThe highest integer value of ``X`` will be the most recently generated set of\nsource files.\n\nBuild Documentation\n===================\n\nBuild the HTML documentation with::\n\n   (opty-dev)$ cd /path/to/opty/docs\n   (opty-dev)$ make html\n\nand open the result with your web browser, for example::\n\n   $ firefox _build/html/index.html\n\nFunding\n=======\n\nThe work was partially funded by the State of Ohio Third Frontier Commission\nthrough the Wright Center for Sensor Systems Engineering (WCSSE), by the USA\nNational Science Foundation under Grant No. 1344954, and by National Center of\nSimulation in Rehabilitation Research 2014 Visiting Scholarship at Stanford\nUniversity, and the CZI grant CZIF2021-006198 and grant DOI\nhttps://doi.org/10.37921/240361looxoj from the Chan Zuckerberg Initiative\nFoundation (funder DOI 10.13039/100014989).\n",
    "bugtrack_url": null,
    "license": "BSD-2-clause",
    "summary": "Tool for optimizing dynamic systems using direct collocation.",
    "version": "1.3.0",
    "project_urls": {
        "Homepage": "http://github.com/csu-hmc/opty"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "98aef3d9f6c87bac7f6558e3ba36bb093b0426d9e5194af6679f608ad4124478",
                "md5": "a2a5edfc08d21c515d7ecc11ae78ae7f",
                "sha256": "83081d4514264c4f3ab38ff877304422833d100bd0df7386f28696835fe78ee9"
            },
            "downloads": -1,
            "filename": "opty-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a2a5edfc08d21c515d7ecc11ae78ae7f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 62607,
            "upload_time": "2024-08-05T08:21:24",
            "upload_time_iso_8601": "2024-08-05T08:21:24.663932Z",
            "url": "https://files.pythonhosted.org/packages/98/ae/f3d9f6c87bac7f6558e3ba36bb093b0426d9e5194af6679f608ad4124478/opty-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-05 08:21:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "csu-hmc",
    "github_project": "opty",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "opty"
}
        
Elapsed time: 0.39811s