Skip to content

Commit 9aed63f

Browse files
committed
update README.md
1 parent 66b6747 commit 9aed63f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,39 @@ This will:
6969

7070
## Basic example
7171

72+
Suppose we are given a matrix $A \in \mathbf{R}^{m \times n}$.
73+
Consider the following nonnegative matrix factorization problem:
74+
75+
$$
76+
\begin{array}{ll}
77+
\text{minimize} & {\|XY + Z - A\|}_F\\
78+
\text{subject to} & X_{ij} \geq 0,\quad i = 1, \ldots, m,
79+
\quad j = 1, \ldots, k\\
80+
& Y_{ij} \geq 0,\quad i = 1, \ldots, k,\quad j = 1, \ldots, n\\
81+
& {\|Z\|}_F \leq 1,
82+
\end{array}
83+
$$
84+
85+
with variables $X \in \mathbf{R}^{m \times k}$,
86+
$Y \in \mathbf{R}^{k \times n}$,
87+
and $Z \in \mathbf{R}^{m \times n}$.
88+
89+
To specify and solve this problem using `dbcp`,
90+
one may use the following code:
91+
92+
```python
93+
import cvxpy as cp
94+
import dbcp
95+
96+
X = cp.Variable((m, k), nonneg=True)
97+
Y = cp.Variable((k, n), nonneg=True)
98+
Z = cp.Variable((m, n))
99+
100+
obj = cp.Minimize(cp.norm(X @ Y + Z - A, 'fro'))
101+
constraints = [cp.norm(Z, 'fro') <= 1]
102+
prob = dbcp.BiconvexProblem(obj, [[X], [Y]], constraints)
103+
104+
prob.solve()
105+
```
106+
72107
## Citation

0 commit comments

Comments
 (0)