#embedded #optimization #solver #MPC #NMPC


A pure Rust framework for embedded nonconvex optimization. Ideal for robotics!

13 unstable releases (6 breaking)

✓ Uses Rust 2018 edition

0.7.0 May 11, 2020
0.6.2 Oct 29, 2019
0.5.0 Jun 22, 2019
0.2.2 Mar 22, 2019

#8 in Embedded development

Download history 18/week @ 2020-03-15 91/week @ 2020-03-22 1/week @ 2020-03-29 48/week @ 2020-04-05 104/week @ 2020-04-12 7/week @ 2020-04-19 17/week @ 2020-04-26 28/week @ 2020-05-03 42/week @ 2020-05-10 18/week @ 2020-05-17 25/week @ 2020-05-24 56/week @ 2020-05-31 10/week @ 2020-06-07 21/week @ 2020-06-14 5/week @ 2020-06-21 20/week @ 2020-06-28

185 downloads per month


4.5K SLoC

OpEn logo

Tweet build status build status

MIT license Apache v2 license

Gitter Chat on Discord

Optimization Engine (OpEn) is a solver for embedded nonconvex optimization.

Documentation available at alphaville.github.io/optimization-engine


OpEn is the counterpart of CVXGen for nonconvex problems.

  • Fast nonconvex parametric optimization
  • Numerical algorithm written in Rust
  • Provably safe memory management
  • Ideal for nonlinear MPC applications (e.g., autonomous navigation)


Code generation

Code generation? Piece of cake!

OpEn generates parametric optimizer modules in Rust - it's blazingly fast - it's safe - it can run on embedded devices.

You can use the MATLAB or Python interface of OpEn to generate Rust code for your parametric optimizer.

This can then be called directly, using Rust, or, it can be consumed as a service over a socket.

Code generation

You can generate a parametric optimizer in just very few lines of code and in no time.

OpEn allows application developers and researchers to focus on the challenges of the application, rather than the tedious task of solving the associated parametric optimization problems (as in nonlinear model predictive control).

Embedded applications

OpEn can run on embedded devices; here we see it running on an intel Atom for the autonomous navigation of a lab-scale micro aerial vehicle - the controller runs at 20Hz using only 15% CPU!

Autonomous Aerial Vehicle

Parametric Problems

OpEn can solve nonconvex parametric optimization problems of the general form

where f is a smooth cost, U is a simple - possibly nonconvex - set, F1 and F2 are nonlinear smooth mappings and C is a convex set.

Code Generation Example

Code generation in Python in just a few lines of code (read the docs for details)

import opengen as og
import casadi.casadi as cs

# Define variables
# ------------------------------------
u = cs.SX.sym("u", 5)
p = cs.SX.sym("p", 2)

# Define cost function and constraints
# ------------------------------------
phi = og.functions.rosenbrock(u, p)
f2 = cs.vertcat(1.5 * u[0] - u[1],
                cs.fmax(0.0, u[2] - u[3] + 0.1))
bounds = og.constraints.Ball2(None, 1.5)
problem = og.builder.Problem(u, p, phi) \
    .with_penalty_constraints(f2)       \
# Configuration and code generation
# ------------------------------------
build_config = og.config.BuildConfiguration()  \
    .with_build_directory("python_test_build") \
meta = og.config.OptimizerMeta()
solver_config = og.config.SolverConfiguration()    \
    .with_tolerance(1e-5)                          \
builder = og.builder.OpEnOptimizerBuilder(problem, meta,
                                          build_config, solver_config)

Code generation in a few lines of MATLAB code (read the docs for details)

% Define variables
% ------------------------------------
u = casadi.SX.sym('u', 5);
p = casadi.SX.sym('p', 2);

% Define cost function and constraints
% ------------------------------------
phi = rosenbrock(u, p);
f2 = [1.5*u(1) - u(2);
      max(0, u(3)-u(4)+0.1)];

bounds = OpEnConstraints.make_ball_at_origin(5.0);

opEnBuilder = OpEnOptimizerBuilder()...
    .with_problem(u, p, phi, bounds)...

opEnOptimizer = opEnBuilder.build();

Getting started

Contact us

Do you like OpEn?

Show us with a star on github...



OpEn is a free open source project. You can use it under the terms of either Apache license v2.0 or MIT license.

Core Team

Pantelis Sopasakis

Emil Fresk


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Before you contribute to Optimization Engine, please read our contributing guidelines.

A list of contributors is automatically generated by github here.

Citing OpEn

Please, cite OpEn as follows:

  author="P. Sopasakis and E. Fresk and P. Patrinos",
  title="{OpEn}: Code Generation for Embedded Nonconvex Optimization",
  booktitle="IFAC World Congress",