Skip to content

Nonlinear optimal control via nonlinear programming

License

Notifications You must be signed in to change notification settings

senhorsolar/nopt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nopt

Nonlinear optimal control via nonlinear programming (NLP). This library relies upon jax to compute gradients, Jacobian-vector products, and Hessian-vector products through automatic differentiation (AD). Due to calculating gradients through AD as opposed to finite differences, the solution converges in a small number of iterations, but the runtime suffers. In the ideal case, we would find analytical expressions for the gradients, Jacobians, and Hessians (or approximate Hessians).

Usage

  1. First create an optimal control problem by subclassing from the template given in core.py. See cartpole.py for an example.
import jax.numpy as np
from nopt.problems import CartPole

cartpole = CartPole()
  1. Specify boundary conditions and number of grid points:
bcs = {'x0': jnp.array([0., 0., 0., 0.]),
       'xN': jnp.array([0., 0., jnp.pi, 0.])}
N = 100
  1. Create a NLP problem:
from nopt import NlpProblem

problem = NlpProblem(cartpole, boundary_conditions=bcs, N=N)
  1. Find the optimized solution:
from nopt import solve

zstar = solve(problem, max_iters=10)

You can visualize the optimized output by calling plot:

anim = problem.plot(zstar)

Example

See the example notebook.

About

Nonlinear optimal control via nonlinear programming

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published