Skip to content

Commit 04285c6

Browse files
authored
Fix: update the toy example in README.md (#74)
1 parent 488e725 commit 04285c6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ from scipy import sparse
118118

119119
import diffcp
120120

121+
def random_cone_prog(m, n, cone_dict):
122+
"""Returns the problem data of a random cone program."""
123+
cone_list = diffcp.cones.parse_cone_dict(cone_dict)
124+
z = np.random.randn(m)
125+
s_star = diffcp.cones.pi(z, cone_list, dual=False)
126+
y_star = s_star - z
127+
A = sparse.csc_matrix(np.random.randn(m, n))
128+
x_star = np.random.randn(n)
129+
b = A @ x_star + s_star
130+
c = -A.T @ y_star
131+
return A, b, c
132+
121133
cone_dict = {
122134
diffcp.ZERO: 3,
123135
diffcp.POS: 3,
@@ -127,7 +139,7 @@ cone_dict = {
127139
m = 3 + 3 + 5
128140
n = 5
129141

130-
A, b, c = diffcp.utils.random_cone_prog(m, n, cone_dict)
142+
A, b, c = random_cone_prog(m, n, cone_dict)
131143
x, y, s, D, DT = diffcp.solve_and_derivative(A, b, c, cone_dict)
132144

133145
# evaluate the derivative

0 commit comments

Comments
 (0)