A CVXPY extension for disciplined biconvex programming.
Project description
DBCP: Disciplined Biconvex Programming
DBCP is an extension of CVXPY for (approximately) solving biconvex optimization problems in the form
$$ \begin{array}{ll} \text{minimize} & f_0(x, y)\ \text{subject to} & f_i(x, y) \leq 0,\quad i = 1, \ldots, m\ & h_i(x, y) = 0,\quad i = 1, \ldots, p, \end{array} $$
where $x \in X$, $y \in Y$ are the optimization variables. The functions $f_0, \ldots, f_m$ are biconvex, meaning that for fixed $y$, the functions $f_i(\cdot, y)$ are convex, and for fixed $x$, the functions $f_i(x, \cdot)$ are convex. The functions $h_1, \ldots, h_p$ are biaffine in a similar sense. In the most general case, biconvex optimization problems are very hard to solve, but heuristic methods such as alternating convex search (ACS) can often find good solutions in practice.
More theoretical and technical aspects about biconvex optimization problems can be found in our accompanying paper.
Installation
DBCP has the following dependencies:
Using pip
You can install the package using pip:
pip install dbcp
Development setup
We manage dependencies through uv. Once you have installed uv you can perform the following commands to set up a development environment:
-
Clone the repository:
git clone https://github.com/nrgrp/dbcp.git cd dbcp
-
Create a virtual environment and install dependencies:
make install
This will:
- Create a Python 3.12 virtual environment.
- Install all dependencies from pyproject.toml.
Usage
Here we provide a basic overview of how to use DBCP; for more details, please refer to our paper and the examples.
DBCP syntax rule for multiplications
DBCP is based on CVXPY and inherits its syntax rules, with the following extension for variable multiplications:
-
A valid DBCP convex product expression between variables should be one of the form:
- affine * affine
- affine-nonneg * convex
- affine-nonpos * concave
- convex-nonneg * convex-nonneg
- concave-nonpos * concave-nonpos
-
There exists no loop in the variable interaction graph of the overall expression, where the edge between two variables indicates that they appear in different sides in a product expression as described in the above rule.
Specifying biconvex problems
DBCP provides the BiconvexProblem and BiconvexRelaxProblem
classes to specify biconvex problems.
Roughly speaking, the difference between these two classes is that
BiconvexProblem implements a solver for directly solving
the original biconvex problem, while
BiconvexRelaxProblem is used for solving a relaxed version
of the problem with additional slack variables added to the constraints,
so the latter allows solving with infeasible starting points.
As an example, to create a BiconvexProblem instance,
one can use the following syntax:
prob = BiconvexProblem(obj, [x_var, y_var], constraints)
The argument obj is a DBCP-compliant biconvex expression
representing the objective function, x_var and y_var
are lists of the biconvex optimization variables,
and constraints is a list of DBCP-compliant biconvex constraints.
The arguments x_var and y_var define the variable partition
for the biconvex problem, such that each group will be fixed
when optimizing over the other group during the ACS procedure.
Verification of biconvexity
After creating a BiconvexProblem or BiconvexRelaxProblem instance,
one can call its is_dbcp method to verify whether the problem
is DBCP-compliant:
prob.is_dbcp()
which returns True if the problem is DBCP-compliant, and False otherwise.
Solving a biconvex problem
After creating a BiconvexProblem instance,
one can call its solve method to solve the problem:
prob.solve()
The most important optional arguments of the
BiconvexProblem.solve method are as follows:
lbd: The regularization parameter of the proximal term.max_iters: The maximum number of ACS iterations.gap_tolerance: The tolerance for the gap between the subproblems when stopping the ACS procedure.
The BiconvexRelaxProblem.solve method has an additional
optional argument nu to specify the penalty parameter
for the total slack, i.e.,
violation of the biconvex constraints.
Problem status
After solving a biconvex problem using the solve method,
one can check the problem status using the status attribute.
The possible status values for BiconvexProblem are as follows:
converge: The ACS procedure converged successfully, i.e., the final gap between the subproblems is within the specified tolerance.converge_inaccurate: The maximum number of iterations was reached, but the final gap between the subproblems is still larger than the specified tolerance.
In the second case, one may want to call the solve method again.
This will continue the ACS procedure from the last iteration, until
either convergence is achieved or the maximum number of iterations
is reached.
The possible status values for BiconvexRelaxProblem are as follows:
converge: The ACS procedure converged successfully with a feasible solution (i.e., the total slack is zero) to the original problem.converge_infeasible: The ACS procedure converged successfully, but the final solution is still infeasible with nonzero total slack.converge_inaccurate: The maximum number of iterations was reached with a feasible final point, but the final gap between the subproblems is still larger than the specified tolerance.converge_inaccurate_infeasible: The maximum number of iterations was reached, but the final gap between the subproblems is still larger than the specified tolerance, and the final solution is still infeasible with nonzero total slack.
When 'infeasible' appears in the status,
one may want to increase the penalty parameter nu
and call the solve method again.
Examples
Basic example
Suppose we are given a matrix $A \in \mathbf{R}^{m \times n}$. Consider the following nonnegative matrix factorization problem:
$$ \begin{array}{ll} \text{minimize} & {|XY + Z - A|}F\ \text{subject to} & X{ij} \geq 0,\quad i = 1, \ldots, m, \quad j = 1, \ldots, k\ & Y_{ij} \geq 0,\quad i = 1, \ldots, k,\quad j = 1, \ldots, n\ & {|Z|}_F \leq 1, \end{array} $$
with variables $X \in \mathbf{R}^{m \times k}$, $Y \in \mathbf{R}^{k \times n}$, and $Z \in \mathbf{R}^{m \times n}$.
To specify and solve this problem using DBCP, one may use the following code:
import cvxpy as cp
import dbcp
X = cp.Variable((m, k), nonneg=True)
Y = cp.Variable((k, n), nonneg=True)
Z = cp.Variable((m, n))
obj = cp.Minimize(cp.norm(X @ Y + Z - A, 'fro'))
constraints = [cp.norm(Z, 'fro') <= 1]
prob = dbcp.BiconvexProblem(obj, [[X], [Y]], constraints)
prob.solve()
Other examples
We provide several other examples in the examples directory. To view and reproduce the examples, executing
make marimo
in the repository folder will install and start the marimo environment.
Citation
If you find DBCP useful in your research, please consider citing our paper:
@article{zhu2025dbcp,
title={Disciplined Biconvex Programming},
author={Zhu, H. and Boedecker, J.},
journal={arXiv Preprint arXiv:2511.01813},
year={2025},
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbcp-0.2.1.tar.gz.
File metadata
- Download URL: dbcp-0.2.1.tar.gz
- Upload date:
- Size: 51.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b11f10b94103e8b8b74ac741d09092af2b854afb6f5df9b082ee5a9043a512de
|
|
| MD5 |
c29ae487ff5f166944ca693c8ba6ca3d
|
|
| BLAKE2b-256 |
ae150d7a59a867c10b4e6f6fb12738adffa2e07d40a153a4e0d5eee0c8664514
|
Provenance
The following attestation bundles were made for dbcp-0.2.1.tar.gz:
Publisher:
release.yml on nrgrp/dbcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbcp-0.2.1.tar.gz -
Subject digest:
b11f10b94103e8b8b74ac741d09092af2b854afb6f5df9b082ee5a9043a512de - Sigstore transparency entry: 938308145
- Sigstore integration time:
-
Permalink:
nrgrp/dbcp@4d2f181444074e68630d2af39361af9e5d89dcfa -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nrgrp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4d2f181444074e68630d2af39361af9e5d89dcfa -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file dbcp-0.2.1-py3-none-any.whl.
File metadata
- Download URL: dbcp-0.2.1-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a2fe9e90cef1e61ed07ab9b0107fb8454e1a7891f5fc4f9c11b0d07f600b42f
|
|
| MD5 |
f53458d616c0f933b1ce2b79ae8ad2dd
|
|
| BLAKE2b-256 |
772413c61615041c107c8fe12497ed91faea1cee6c8e80334de0915d5446aabd
|
Provenance
The following attestation bundles were made for dbcp-0.2.1-py3-none-any.whl:
Publisher:
release.yml on nrgrp/dbcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbcp-0.2.1-py3-none-any.whl -
Subject digest:
8a2fe9e90cef1e61ed07ab9b0107fb8454e1a7891f5fc4f9c11b0d07f600b42f - Sigstore transparency entry: 938308158
- Sigstore integration time:
-
Permalink:
nrgrp/dbcp@4d2f181444074e68630d2af39361af9e5d89dcfa -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nrgrp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4d2f181444074e68630d2af39361af9e5d89dcfa -
Trigger Event:
workflow_dispatch
-
Statement type: