Coder Social home page Coder Social logo

missiondesignsolutions / mpopt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mpopt/mpopt

0.0 0.0 0.0 2.17 MB

A pseudo-spectral collocation based multi-phase Optimal control problem solver

Home Page: https://mpopt.readthedocs.io/

License: GNU Lesser General Public License v3.0

Makefile 0.11% Python 15.11% Jupyter Notebook 84.79%

mpopt's Introduction

pypi pacakge Build Status Coverage Status Documentation Status

MPOPT

MPOPT is a collection of modules to solve multi-stage optimal control problems(OCPs) using pseudo-spectral collocation method. This module creates Nonlinear programming problem (NLP) from the given OCP description, which is then solved by CasADi nlpsolver using various available plugins such as ipopt, snopt etc.

Main features of the solver are :

  • Customizable collocation approximation, compatable with Legendre-Gauss-Radau, Legendre-Gauss-Lobatto, Chebyshev-Gauss-Lobatto roots.
  • Intuitive definition of OCP/multi-phase OCP
  • Single-phase as well as multi-phase OCP solving capability using user defined collocation approximation
  • Adaptive grid refinement schemes for robust solutions
  • NLP solution using algorithmic differentiation capability offered by CasADi, multiple NLP solver compatibility 'ipopt', 'snopt', 'sqpmethod' etc.
  • Sophisticated post-processing module for interactive data visualization

Getting started

A brief overview of the package and capabilities are demonstrated with simple moon-lander OCP example in Jupyter notebook.

Installation

Install and try the package using

$ pip install mpopt
$ wget https://raw.githubusercontent.com/mpopt/mpopt/master/examples/moon_lander.py
$ python3 moon_lander.py

If you want to downloaded it from source, you may do so either by:

  • Downloading it from GitHub page

    • Unzip the folder and you are ready to go
  • Or cloning it to a desired directory using git:

    • $ git clone https://github.com/mpopt/mpopt.git --branch master
  • Move to the cloned directory

    • $ cd mpopt
  • Install package using

    • $ make install
  • Test installation using

    • $ make test
  • Try moon-lander example using

    • $ make run

Documentation

A sample code to solve moon-lander OCP (2D)

# Moon lander OCP direct collocation/multi-segment collocation
from mpopt import mp

# Define OCP
ocp = mp.OCP(n_states=2, n_controls=1)
ocp.dynamics[0] = lambda x, u, t: [x[1], u[0] - 1.5]
ocp.running_costs[0] = lambda x, u, t: u[0]
ocp.terminal_constraints[0] = lambda xf, tf, x0, t0: [xf[0], xf[1]]
ocp.x00[0] = [10.0, -2.0]
ocp.lbu[0], ocp.ubu[0] = 0, 3

# Create optimizer(mpo), solve and post process(post) the solution
mpo, post = mp.solve(ocp, n_segments=20, poly_orders=3, scheme="LGR", plot=True)

Authors

  • Devakumar THAMMISETTY
  • Prof. Colin Jones (Co-author)

License

This project is licensed under the GNU LGPL v3 - see the LICENSE file for details

Acknowledgements

  • Petr Listov

mpopt's People

Contributors

devakumar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.