Skip to main content

A general Python-based successive convexification implementation which uses a JAX backend.

Project description

License: Apache 2.0


What is OpenSCvx

OpenSCvx is a general python-based successive convexification implementation which uses a JAX backend. It is designed to be easy to use for anyone and fast enough for everyone, all while being open and modular for contributors.

OpenSCvx provides a clean symbolic interface for problem definition which should be intuitive to users of NumPy, JAX, and CVXPY. This allows us to hide a lot of the under-the-hood magic away from the user while also providing a modular architecture, enabling contributors to focus on the algorithms without worrying about interface design.

OpenSCvx makes heavy use of JAX to efficiently perform calculations in the successive convex programming loop through automatic differentiation, ahead-of-time (AOT) compilation, vectorization, and GPU acceleration. Behind this is a CVXPY-based backend to solve the convex subproblems.

This is an open project and is under active development. Try it out, give us feedback, and help contribute.

import openscvx as ox

g = 9.81

# Define states
position = ox.State("position", shape=(2,))
position.min = [0.0, 0.0]
position.max = [10.0, 10.0]
position.initial = [0.0, 10.0]
position.final = [10.0, 5.0]

velocity = ox.State("velocity", shape=(1,))
velocity.min = [0.0]
velocity.max = [10.0]
velocity.initial = [0.0]
velocity.final = [ox.Free(10.0)]

# Define control (angle from vertical)
theta = ox.Control("theta", shape=(1,))
theta.min = [0.0]
theta.max = [1.755]
theta.guess = [[0.09], [1.755]]

# Define dynamics
dynamics = {
    "position": ox.Concat(
        velocity * ox.Sin(theta),
        -velocity * ox.Cos(theta),
    ),
    "velocity": g * ox.Cos(theta),
}

constraints = []
for state in [position, velocity]:
    constraints.append(ox.ctcs(state <= state.max))
    constraints.append(ox.ctcs(state.min <= state))

# Build and solve
problem = ox.Problem(
    dynamics=dynamics,
    constraints=constraints,
    states=[position, velocity],
    controls=[theta],
    time=ox.Time(initial=0.0, final=ox.Minimize(2.0), min=0.0, max=2.0),
    N=2,
)


problem.initialize()
results = problem.solve()
results = problem.post_process()

Installation

OpenSCvx is available on PyPI and can be trivially installed with pip.

It is recommended to install OpenSCvx inside a virtual environment (venv, conda, uv, etc.). If you don't already have one set up:

python3 -m venv .venv
source .venv/bin/activate

Using pip

pip install openscvx

Using uv

If you have uv installed you can prefix the commands with uv for faster installation:

uv pip install openscvx

[!TIP] Optional dependencies

For CVXPYGen code generation:

pip install openscvx[cvxpygen]

[!TIP] Nightly Builds

To install the latest development version (nightly), use the --pre flag:

pip install --pre openscvx

Installing From Source

Using pip

git clone https://github.com/OpenSCvx/OpenSCvx.git
cd OpenSCvx

python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Using uv

git clone https://github.com/OpenSCvx/OpenSCvx.git
cd OpenSCvx

uv venv
source .venv/bin/activate
uv pip install -e .

[!NOTE] MuJoCo Menagerie (optional submodule)

Core OpenSCvx installs fine from a plain clone—you do not need the submodule unless you want bundled MuJoCo Menagerie assets. To fetch it in one step, clone with --recurse-submodules, or add it later to third_party/mujoco_menagerie so openscvx.integrations.menagerie can load those MuJoCo XML/models/meshes without a separate checkout:

git clone --recurse-submodules https://github.com/OpenSCvx/OpenSCvx.git

After a clone without submodules, initialize Menagerie whenever you need it:

git submodule update --init third_party/mujoco_menagerie

Documentation

Check out the OpenSCvx documentation:

Running the Examples

We also have a selection of problems in the examples/ folder as well as on the Examples page of the documentation. The example trajectory optimization problems are grouped by application and represent some of the problem types that can be solved by OpenSCvx.

[!Note] To run the examples, you'll need to clone this repository and install OpenSCvx in editable mode (pip install -e .). See the Installing From Source section above for detailed installation instructions.

To run a problem simply run any of the examples directly, for example:

python3 examples/abstract/brachistochrone.py

and adjust the plotting as needed.

Check out the problem definitions inside examples/ to see how to define your own problems.

Code Structure

What is implemented

This repo has the following features:

  1. Free Final Time
  2. Fully adaptive time dilation (s is appended to the control vector)
  3. Continuous-Time Constraint Satisfaction
  4. FOH and ZOH exact discretization (t is a state so you can bring your own scheme)
  5. Vectorized and Ahead-of-Time (AOT) Compiled Multishooting Discretization
  6. JAX Autodiff for Jacobians

(back to top)

Acknowledgements

This work was supported by a NASA Space Technology Graduate Research Opportunity and the Office of Naval Research under grant N00014-17-1-2433. The authors would like to acknowledge Natalia Pavlasek, Fabio Spada, Samuel Buckner, Abhi Kamath, Govind Chari, and Purnanand Elango as well as the other Autonomous Controls Laboratory members, for their many helpful discussions and support throughout this work.

Citation

Please cite the following works if you use the repository,

@ARTICLE{hayner2025los,
        author={Hayner, Christopher R. and Carson III, John M. and Açıkmeşe, Behçet and Leung, Karen},
        journal={IEEE Robotics and Automation Letters}, 
        title={Continuous-Time Line-of-Sight Constrained Trajectory Planning for 6-Degree of Freedom Systems}, 
        year={2025},
        volume={},
        number={},
        pages={1-8},
        keywords={Robot sensing systems;Vectors;Vehicle dynamics;Line-of-sight propagation;Trajectory planning;Trajectory optimization;Quadrotors;Nonlinear dynamical systems;Heuristic algorithms;Convergence;Constrained Motion Planning;Optimization and Optimal Control;Aerial Systems: Perception and Autonomy},
        doi={10.1109/LRA.2025.3545299}}
@misc{elango2024ctscvx,
      title={Successive Convexification for Trajectory Optimization with Continuous-Time Constraint Satisfaction}, 
      author={Purnanand Elango and Dayou Luo and Abhinav G. Kamath and Samet Uzun and Taewan Kim and Behçet Açıkmeşe},
      year={2024},
      eprint={2404.16826},
      archivePrefix={arXiv},
      primaryClass={math.OC},
      url={https://arxiv.org/abs/2404.16826}, 
}
@article{chari2026qoco,
  title = {QOCO: a quadratic objective conic optimizer with custom solver generation},
  author = {Chari, Govind M. and A\c{c}ıkmeşe, Beh\c{c}et},
  journal = {Mathematical Programming Computation},
  issn = {1867-2957},
  url = {http://dx.doi.org/10.1007/s12532-026-00311-8},
  doi = {10.1007/s12532-026-00311-8},
  publisher = {Springer Science and Business Media LLC},
  year = {2026},
  month = mar,
}

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openscvx-0.5.2.dev12.tar.gz (38.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openscvx-0.5.2.dev12-py3-none-any.whl (421.8 kB view details)

Uploaded Python 3

File details

Details for the file openscvx-0.5.2.dev12.tar.gz.

File metadata

  • Download URL: openscvx-0.5.2.dev12.tar.gz
  • Upload date:
  • Size: 38.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for openscvx-0.5.2.dev12.tar.gz
Algorithm Hash digest
SHA256 7cb2fdbc93f3393d63c472084f045e8328045e05a00921a2aa51fd0aa16f911c
MD5 130a69daec0652c71289d954d5606822
BLAKE2b-256 cc3b4524cb3d179a8edc937f73265b11c6bf2e64d312b492fd4a2b22b17da4b0

See more details on using hashes here.

File details

Details for the file openscvx-0.5.2.dev12-py3-none-any.whl.

File metadata

  • Download URL: openscvx-0.5.2.dev12-py3-none-any.whl
  • Upload date:
  • Size: 421.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for openscvx-0.5.2.dev12-py3-none-any.whl
Algorithm Hash digest
SHA256 b97f09346dab12d48d19d51c7e81c3966a83734cbd1f7612cff9492b2bf02289
MD5 14ec9aa1f1380ce345a0f98c475fc764
BLAKE2b-256 02dbabc16e0bffe32c1306750f5d199ce69f8ed7d9a03207ce54958f35dcf4a0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page