dymos

dymos: A Python package for optimal control of multidisciplinary systems - Published in JOSS (2021)

https://github.com/openmdao/dymos

Science Score: 95.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 8 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org
  • Committers with academic emails
    10 of 24 committers (41.7%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

co-design nasa openmdao optimal-control pseudospectral trajectory-optimization

Scientific Fields

Materials Science Physical Sciences - 40% confidence
Last synced: 4 months ago · JSON representation

Repository

Open Source Optimization of Dynamic Multidisciplinary Systems

Basic Info
  • Host: GitHub
  • Owner: OpenMDAO
  • License: apache-2.0
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 753 MB
Statistics
  • Stars: 257
  • Watchers: 11
  • Forks: 69
  • Open Issues: 28
  • Releases: 30
Topics
co-design nasa openmdao optimal-control pseudospectral trajectory-optimization
Created almost 8 years ago · Last pushed 5 months ago
Metadata Files
Readme License

readme.md

Dymos: Open Source Optimization of Dynamic Multidisciplinary Systems

Dymos Tests Coverage Status

DOI

Dymos is a framework for the simulation and optimization of dynamical systems within the OpenMDAO Multidisciplinary Analysis and Optimization environment. Dymos leverages implicit and explicit simulation techniques to simulate generic dynamic systems of arbitary complexity.

The software has two primary objectives: - Provide a generic ODE integration interface that allows for the analysis of dynamical systems. - Allow the user to solve optimal control problems involving dynamical multidisciplinary systems.

Installation

The default installation of the developmental version of Dymos will install the minimum number of prerequisites:

python -m pip install dymos

More advanced installation instructions are available here.

Citation

See our overview paper in the Journal of Open Source Software

If you use Dymos in your work, please cite: @article{Falck2021, doi = {10.21105/joss.02809}, url = {https://doi.org/10.21105/joss.02809}, year = {2021}, publisher = {The Open Journal}, volume = {6}, number = {59}, pages = {2809}, author = {Robert Falck and Justin S. Gray and Kaushik Ponnapalli and Ted Wright}, title = {dymos: A Python package for optimal control of multidisciplinary systems}, journal = {Journal of Open Source Software} }

Documentation

Documentation for the current development version of Dymos is available at https://openmdao.github.io/dymos/ as well as on the OpenMDAO web site: https://openmdao.org/dymos/docs/latest/. Archived versions for recent releases will also be found here: https://openmdao.org/dymos-documentation/

Defining Ordinary Differential Equations

The first step in simulating or optimizing a dynamical system is to define the ordinary differential equations to be integrated. The user first builds an OpenMDAO model which has outputs that provide the rates of the state variables. This model can be an OpenMDAO model of arbitrary complexity, including nested groups and components, layers of nonlinear solvers, etc.

Dymos solutions are constructed of one or more Phases. When setting up a phase, we add state variables, dynamic controls, and parameters, tell Dymos how the value of each should be connected to the ODE system, and tell Dymos the variable paths in the system that contain the rates of our state variables that are to be integrated.

Integrating Ordinary Differential Equations

Dymos's solver-based pseudspectral transcriptions provide the ability to numerically integrate the ODE system it is given. Used in an optimal control context, these provide a shooting method in which each iteration provides a physically viable trajectory.

Pseudospectral Methods

Dymos currently supports the Radau Pseudospectral Method and high-order Gauss-Lobatto transcriptions. These implicit techniques rely on the optimizer to impose "defect" constraints which enforce the physical accuracy of the resulting trajectories. To verify the physical accuracy of the solutions, Dymos can explicitly integrate them using variable-step methods.

Solving Optimal Control Problems

Dymos uses the concept of Phases to support optimal control of dynamical systems. Users connect one or more Phases to construct trajectories. Each Phase can have its own:

  • Optimal Control Transcription (Gauss-Lobatto or Radau Pseudospectral)
  • Equations of motion
  • Boundary and path constraints

Dymos Phases and Trajectories are ultimately just OpenMDAO Groups that can exist in a problem along with numerous other models, allowing for the simultaneous optimization of systems and dynamics.

```python import numpy as np import openmdao.api as om import dymos as dm import matplotlib.pyplot as plt

First define a system which computes the equations of motion

class BrachistochroneEOM(om.ExplicitComponent): def initialize(self): self.options.declare('num_nodes', types=int)

def setup(self):
    nn = self.options['num_nodes']

    # Inputs
    self.add_input('v', val=np.zeros(nn), units='m/s', desc='velocity')
    self.add_input('theta', val=np.zeros(nn), units='rad', desc='angle of wire')
    self.add_output('xdot', val=np.zeros(nn), units='m/s', desc='x rate of change')
    self.add_output('ydot', val=np.zeros(nn), units='m/s', desc='y rate of change')
    self.add_output('vdot', val=np.zeros(nn), units='m/s**2', desc='v rate of change')

    # Ask OpenMDAO to compute the partial derivatives using complex-step
    # with a partial coloring algorithm for improved performance
    self.declare_partials(of='*', wrt='*', method='cs')
    self.declare_coloring(wrt='*', method='cs', show_summary=True)

def compute(self, inputs, outputs):
    v, theta = inputs.values()
    outputs['vdot'] = 9.80665 * np.cos(theta)
    outputs['xdot'] = v * np.sin(theta)
    outputs['ydot'] = -v * np.cos(theta)

p = om.Problem()

Define a Trajectory object

traj = p.model.add_subsystem('traj', dm.Trajectory())

Define a Dymos Phase object with GaussLobatto Transcription

tx = dm.GaussLobatto(numsegments=10, order=3) phase = dm.Phase(odeclass=BrachistochroneEOM, transcription=tx)

traj.add_phase(name='phase0', phase=phase)

Set the time options

phase.settimeoptions(fixinitial=True, durationbounds=(0.5, 10.0))

Set the state options

phase.setstateoptions('x', ratesource='xdot', fixinitial=True, fixfinal=True) phase.setstateoptions('y', ratesource='ydot', fixinitial=True, fixfinal=True) phase.setstateoptions('v', ratesource='vdot', fixinitial=True, fix_final=False)

Define theta as a control.

phase.add_control(name='theta', units='rad', lower=0, upper=np.pi)

Minimize final time.

phase.add_objective('time', loc='final')

Set the driver.

p.driver = om.ScipyOptimizeDriver()

Allow OpenMDAO to automatically determine total

derivative sparsity pattern.

This works in conjunction with partial derivative

coloring to give a large speedup

p.driver.declare_coloring()

Setup the problem

p.setup()

Now that the OpenMDAO problem is setup, we can guess the

values of time, states, and controls.

phase.settimeval(initial=0.0, duration=2.0)

States and controls here use a linearly interpolated

initial guess along the trajectory.

phase.setstateval('x', [0, 10], units='m') phase.setstateval('y', [10, 5], units='m') phase.setstateval('v', [0, 5], units='m/s')

constant initial guess for control

phase.setcontrolval('theta', 90, units='deg')

Run the driver to solve the problem and generate default plots of

state and control values vs time

dm.runproblem(p, makeplots=True, simulate=True) ```

When using the make_plots=True option above, the output directory generated within the run directory will contain a file named reports/traj_results_report.html that should look similar to this:

Brachistochrone Solution

Owner

  • Name: OpenMDAO
  • Login: OpenMDAO
  • Kind: organization
  • Email: openmdao@openmdao.org

JOSS Publication

dymos: A Python package for optimal control of multidisciplinary systems
Published
March 31, 2021
Volume 6, Issue 59, Page 2809
Authors
Robert Falck ORCID
NASA Glenn Research Center
Justin S. Gray ORCID
NASA Glenn Research Center
Kaushik Ponnapalli
HX5 LLC
Ted Wright
NASA Glenn Research Center
Editor
David P. Sanders ORCID
Tags
OpenMDAO optimal control trajectory optimization multidisciplinary optimization NASA

GitHub Events

Total
  • Create event: 4
  • Release event: 3
  • Issues event: 40
  • Watch event: 43
  • Issue comment event: 72
  • Push event: 76
  • Pull request review comment event: 22
  • Pull request review event: 70
  • Pull request event: 92
  • Fork event: 6
Last Year
  • Create event: 4
  • Release event: 3
  • Issues event: 40
  • Watch event: 43
  • Issue comment event: 72
  • Push event: 76
  • Pull request review comment event: 22
  • Pull request review event: 70
  • Pull request event: 92
  • Fork event: 6

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 778
  • Total Committers: 24
  • Avg Commits per committer: 32.417
  • Development Distribution Score (DDS): 0.438
Past Year
  • Commits: 66
  • Committers: 6
  • Avg Commits per committer: 11.0
  • Development Distribution Score (DDS): 0.424
Top Committers
Name Email Commits
Rob Falck r****k@n****v 437
Kaushik Ponnapalli k****i@n****v 62
swryan 8****n 50
John T. Hwang h****t@u****u 47
DKilkenny d****8@g****m 36
kmarsteller k****r@n****v 27
Kenneth Moore k****1@n****v 26
Ted Wright t****t@n****v 22
Bret Naylor n****b@g****m 18
Justin Gray j****y@g****m 16
hschilling h****g@n****v 13
John Jasa j****1@g****m 7
Tad Kollar t****r@n****v 5
Eliot Aretskin-Hariton e****n@n****v 2
David P. Sanders d****s@g****m 1
Shugo Kaneko 4****h 1
ale5000 s****x@g****m 1
bbahiam b****a@u****u 1
cashmesh 3****h 1
joel-martin 3****n 1
nsteffen 1****n 1
Martin West m****n@m****k 1
Philippe Kirschen p****e@v****m 1
andrewellis55 a****8@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 148
  • Total pull requests: 248
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 6 days
  • Total issue authors: 23
  • Total pull request authors: 12
  • Average comments per issue: 0.34
  • Average comments per pull request: 1.13
  • Merged pull requests: 223
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 22
  • Pull requests: 100
  • Average time to close issues: 27 days
  • Average time to close pull requests: 5 days
  • Issue authors: 10
  • Pull request authors: 5
  • Average comments per issue: 0.27
  • Average comments per pull request: 1.15
  • Merged pull requests: 83
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • robfalck (91)
  • swryan (16)
  • kaushikponnapalli (9)
  • Kenneth-T-Moore (6)
  • andrewellis55 (4)
  • johnjasa (2)
  • TidoHoutepen (2)
  • ilaudo (2)
  • caksland (2)
  • Nealks (1)
  • JustinSGray (1)
  • jkirk5 (1)
  • jdgratz10 (1)
  • SoundsSerious (1)
  • xjjiang (1)
Pull Request Authors
  • robfalck (180)
  • swryan (61)
  • kaushikponnapalli (21)
  • johnjasa (10)
  • Kenneth-T-Moore (9)
  • naylor-b (8)
  • joel-martin (2)
  • tadkollar (2)
  • nsteffen (1)
  • andrewellis55 (1)
  • kanekosh (1)
  • hschilling (1)
Top Labels
Issue Labels
bug (72) testing (5) docs (3) backwards incompatible (2) visualization (2) deprecation (1) help (1) enhancement (1)
Pull Request Labels
backwards incompatible (6) bug (3) testing (1) deprecation (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 4,974 last-month
  • Total dependent packages: 1
  • Total dependent repositories: 4
  • Total versions: 22
  • Total maintainers: 1
pypi.org: dymos

Open-Source Optimization of Dynamic Multidisciplinary Systems

  • Versions: 22
  • Dependent Packages: 1
  • Dependent Repositories: 4
  • Downloads: 4,974 Last month
Rankings
Stargazers count: 5.4%
Forks count: 5.9%
Dependent repos count: 7.5%
Average: 8.8%
Dependent packages count: 10.1%
Downloads: 15.1%
Maintainers (1)
Last synced: 4 months ago

Dependencies

.github/workflows/dymos_docs_workflow.yml actions
  • actions/checkout v2 composite
  • conda-incubator/setup-miniconda v2 composite
.github/workflows/dymos_tests_workflow.yml actions
  • actions/checkout v2 composite
  • conda-incubator/setup-miniconda v2 composite
  • coverallsapp/github-action master composite
docs/dymos_book/requirements.txt pypi
  • jupyter-book *
  • matplotlib *
  • numpy *
setup.py pypi
  • numpy *
  • openmdao >=3.17.0
  • scipy *