cvxRiskOpt: A package for risk-based optimization using CVXPY and CVXPYgen

Sleiman SafaouiTyler H Summers

Keywords: Computational methods, uncertain systems, optimization, code generation, risk-based optimization

Overview

Optimization modeling tools and parser solvers, such as CVXPY, make solving deterministic optimization problems a lot easier: they allow users to encode optimization problems in high-level mathematical expressions thereby reducing the need for tedious reformulations or fitting problems into canonical forms.

Many optimization problems often include uncertain terms which are modeled as random variables. Examples of such random variables include stock returns, sensor readings, or the state of a system (e.g. localization of a robot which is uncertain). This gives rise to Risk-Based Optimization problems.

Risk-based optimization problems can be hard to code and they may require tedious reformulations or digging up equivalent forms to eventually encode the problem as an equivalent deterministic risk-tightened optimization problems. To encourage risk-based optimization problems and help speed up the development cycle, we created cvxRiskOpt: a risk-based optimization tool built on top of CVXPY.

There are a few tools for encoding risk-based optimization problems, such as Pyomo, RSOME, and PICOS. While they may support a wider range of stochastic, robust, and distributionally robust optimization problems than our cvxRiskOpt, they have their limitations. Some require complex reformulations of uncertainty sets, some have limited support for problem instances, and all are limited to solving the problem without being able to generate embeddable code for the risk-based optimization problem, a nice feature for embedded system applications or to speed up solve times.

On the other hand, our cvxRiskOpt package builds on CVXPY and provides users with tools to automatically generate risk-based optimization problems and risk-based constraints (e.g. worst case expectation with a Wasserstein-based ambiguity set, chance constraint with a moment-based ambiguity set, etc). Furthermore, because cvxRiskOpt integrates with CVXPY directly and results in CVXPY Problems and constraints, users can utilize CVXPYgen to automatically generate C-code which can be used on embedded systems or utilized with the python-wrapper to speed up solving the optimization problems.

cvxRiskOpt is on PyPI and GitHub.

For more details about cvxRiskOpt and how to use it, please check out the package documentation!