ecvxcone (embedded CVX for cone programming) is a lightweight solver tailored for embedded system use, which supports general conic optimization problems.
cvxopt [1] is a Python-based optimization library that leverages C-based high-performance computation backends such as LAPACK and BLAS. In contrast, ecvxcone removes the Python API layer and re-implements the solver logic entirely in pure C, making it better suited for embedded and real-time applications. Its core conic solver is an implementation of the Interior-Point Method [2]. It further optimizes the canonicalization process for problem families to enhance real-time performance.
Note
Currently this library supports the constraints in the linear form. The support for quadratic form of constraints may be added in the future version.
The mathematical formulation of a generalized cone linear program can be written as:
with
Figure. Overview of Conic Optimization
The typical workflow for solving an optimization problem consists of:
-
Canonicalization: Using domain-specific languages (DSLs) to transform a problem formulated under disciplined convex programming (DCP) rules into a canonical (standardized mathematical) form
-
Solver Execution: Applying an appropriate solver to the canonical problem (e.g., LP, QP, SOCP, SDP).
Figure. A Typical Workflow for Solving a Convex Optimization Problem
In a problem family, the optimization problem’s structure remains fixed, with only certain parameters changing. Most DSLs (e.g., CVXPY) recompile the problem into a canonical form for each solve, which can be unnecessary and costly—especially for embedded systems with hard real-time constraints. CVXPYgen addresses this by precompiling the Python-based canonicalization into C code, enabling faster execution for repeated solves.
Figure. Precompilation for a Problem Family with CVXPYgen
The table below compares popular solvers based on their features. DPP indicates whether the solver supports precompilation of a problem family for embedded deployment.
| Solver | Open Source |
Problem Type Support | Language Support |
DPP | Stability | License | |||
|---|---|---|---|---|---|---|---|---|---|
| LP | QP | SOCP | SDP | ||||||
| CLP | Yes | ✅ | ❌ | ❌ | ❌ | C++, Python | ❌ | 🟢 High | EPL-2.0 |
| OSQP | Yes | ❌ | ✅ | ❌ | ❌ | C, Python, MATLAB | ✅ | 🟢 High | Apache-2.0 |
| qpOASES | Yes | ❌ | ✅ | ❌ | ❌ | C++, Python | ✅ | 🟢 High | LGPL-2.1 |
| HiGHS | Yes | ✅ | ✅ | ❌ | ❌ | C++, Python | ❌ | 🟢 High | MIT |
| SDPA | Yes | ❌ | ❌ | ❌ | ✅ | C++, MATLAB | ❌ | 🟡 Medium | BSD |
| ECOS | Yes | ✅ | ✅ | ✅ | ❌ | C, Python | ✅ | 🟡 Medium | GPLv3 |
| SCS | Yes | ✅ | ✅ | ✅ | ✅ | C, Python, MATLAB | ✅ | 🔴 Low | MIT |
| MOSEK | No | ✅ | ✅ | ✅ | ✅ | C, Java, Python, R, MATLAB | ❌ | 🟢 High | Commercial (Academic Free) |
| CVXOPT | Yes | ✅ | ✅ | ✅ | ✅ | Python | ❌ | 🟢 High | GPLv3 |
| ecvxcone | Yes | ✅ | ⏳ | ✅ | ✅ | C, C++ | ✅ | 🟢 High | Apache-2.0 |
- LAPACK (Linear Algebra PACKage)
- BLAS (Basic Linear Algebra Subprograms)
- Clone this repository:
git clone https://github.com/Charlescai123/ecvxcone.git- Create and activate a Conda environment:
conda create --name ecvxcone python==3.10.6
conda activate ecvxcone- Install Python dependencies:
pip install cvxpy cvxopt- Install CVXPYgen:
cd ecvxcone/third_party/cvxpygen
pip install -e .-
Write your DDP-compliant python code in
ecvxcone/third_party/cvxpygen/ecvxcone_cpg.py -
Generate the embedded C code:
cd ecvxcone/third_party/cvxpygen && python ecvxcone_cpg.py- Write your real-time parameter update logic in C code, an example is provided in
ecvxcone/examples/lmi.c.
graph LR
subgraph PY["In DDP-compliant (Python)"]
A1["A_param"]
A2["B_param"]
A3["zz_param"]
end
subgraph CC["In generated C code"]
B1["cpg_update_A()"]
B2["cpg_update_B()"]
B3["cpg_update_zz()"]
end
A1 --> B1
A2 --> B2
A3 --> B3
style A1 fill:#4A90E2,stroke:#2C3E50,stroke-width:2px,color:#fff,rx:10,ry:10
style A2 fill:#4A90E2,stroke:#2C3E50,stroke-width:2px,color:#fff,rx:10,ry:10
style A3 fill:#4A90E2,stroke:#2C3E50,stroke-width:2px,color:#fff,rx:10,ry:10
style B1 fill:#1e1e1e,stroke:#ffffff,color
style B2 fill:#1e1e1e,stroke:#ffffff,color
style B3 fill:#1e1e1e,stroke:#ffffff,color
-
Add configuration to
ecvxcone/CMakeLists.txtor use the examplelmi.c -
Build the project:
cd ecvxcone && mkdir build && cd build
cmake .. && make -j$(nproc)Tips: Enable unit tests for the solver with cmake command
cmake -DBUILD_TESTS=ON ..
- Run the example with
taskset:
taskset -c 1 ./lmiNote
A practical ROS 2 implementation for robotics use—featuring a physical model-based safety controller design, is available in phy_teacher_ros2.
The table below presents results for running the example Linear Matrix Inequalities on different embedded platforms, comparing execution time and memory usage between the original Python solver and the C-based ecvxcone implementation.
| Hardware Platforms | CPU | Runtime Memory Usage | Solve Time | ||||
|---|---|---|---|---|---|---|---|
| Arch | Core | Frequency | Python | C | Python | C | |
| Dell XPS 8960 Desktop | x86/64 | 32 | 5.4 GHz | 485 MB | 9.87 MB | 49.15 ms | 13.81 ms |
| Intel GEEKOM XT13 Pro Mini | x86/64 | 20 | 4.7 GHz | 443 MB | 7.32 MB | 61.76 ms | 33.26 ms |
| NVIDIA Jetson AGX Orin | ARM64 | 12 | 2.2 GHz | 423 MB | 8.16 MB | 137.54 ms | 35.73 ms |
| Raspberry Pi 4 Model B | ARM64 | 4 | 1.5 GHz | 436 MB | 8.21 MB | 509.41 ms | 149.87 ms |
With the growing adoption of machine learning and optimization at the edge, we envision an optimization toolchain that can run efficiently on devices with limited computational resources, delivering real-time performance in those resource-constrained environments.
In addition, there remains a gap between academic research and industrial deployment. Many optimization algorithms stay confined to theory, limited by hardware constraints and the lack of practical, open-source implementations. This repository aspires to bridge that gap—empowering both academic exploration and real-world deployment, while fostering closer collaboration between research and industry.
- Control Theory: Safety Controller Design [4], Decentralized Control and Optimization [5]
- Trustworthy AI: Robustness Certification [6], Neural Network Verification [7], Fairness-Aware ML [8]
- Robotics Systems: Obstacle Avoidance [9], Pose Estimation [10], Grasping & Force Optimization [11]
We welcome contributions from developers to add new optimization algorithms and expand hardware validation for demanding real-time embedded applications.
[1] Lieven Vandenberghe. Conic Programming. Department of Electrical and Computer Engineering, UCLA. Available at: https://www.seas.ucla.edu/~vandenbe/publications/coneprog.pdf
[2] Martin S. Andersen and Lieven Vandenberghe. Introduction to Mathematical Optimization. Unpublished manuscript. Available at: https://www.seas.ucla.edu/~vandenbe/publications/mlbook.pdf
[3] J. Nocedal and S. J. Wright, Numerical Optimization, 2nd ed. New York, NY, USA: Springer, 2006.
[4] Cai, Yihao, Yanbing Mao, Lui Sha, Hongpeng Cao, and Marco Caccamo. "Runtime Learning Machine." ACM Transactions on Cyber-Physical Systems.
[5] Falsone, Alessandro, Kostas Margellos, and Maria Prandini. "A decentralized approach to multi-agent MILPs: finite-time feasibility and performance guarantees." Automatica 103 (2019): 141-150.
[6] Li, Linyi, Tao Xie, and Bo Li. "Sok: Certified robustness for deep neural networks." 2023 IEEE symposium on security and privacy (SP). IEEE, 2023.
[7] Dathathri, Sumanth, et al. "Enabling certification of verification-agnostic networks via memory-efficient semidefinite programming." Advances in Neural Information Processing Systems 33 (2020): 5318-5331.
[8] Cotter, Andrew, et al. "Optimization with non-differentiable constraints with applications to fairness, recall, churn, and other goals." Journal of Machine Learning Research 20.172 (2019): 1-59.
[9] Deits, Robin & Tedrake, Russ. (2015). Computing Large Convex Regions of Obstacle-Free Space Through Semidefinite Programming. Springer Tracts in Advanced Robotics. 107. 109-124. 10.1007/978-3-319-16595-0_7
[10] Rosen, David M., et al. "SE-Sync: A certifiably correct algorithm for synchronization over the special Euclidean group." The International Journal of Robotics Research 38.2-3 (2019): 95-125.
[11] Dai, Hongkai & Majumdar, Anirudha & Tedrake, Russ. (2015). Synthesis and Optimization of Force Closure Grasps via Sequential Semidefinite Programming.
Please cite the paper below or star this repo if you find it helpful 🙏
@inproceedings{
anonymous2025realdrl,
title={Real-{DRL}: Teach and Learn at Runtime},
author={Mao, Yanbing and Cai, Yihao and Sha, Lui},
booktitle={The Thirty-ninth Annual Conference on Neural Information Processing Systems},
year={2025},
url={https://openreview.net/forum?id=gXZlZAeqay}



