Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ from scipy import sparse

import diffcp

def random_cone_prog(m, n, cone_dict):
"""Returns the problem data of a random cone program."""
cone_list = diffcp.cones.parse_cone_dict(cone_dict)
z = np.random.randn(m)
s_star = diffcp.cones.pi(z, cone_list, dual=False)
y_star = s_star - z
A = sparse.csc_matrix(np.random.randn(m, n))
x_star = np.random.randn(n)
b = A @ x_star + s_star
c = -A.T @ y_star
return A, b, c

cone_dict = {
diffcp.ZERO: 3,
diffcp.POS: 3,
Expand All @@ -127,7 +139,7 @@ cone_dict = {
m = 3 + 3 + 5
n = 5

A, b, c = diffcp.utils.random_cone_prog(m, n, cone_dict)
A, b, c = random_cone_prog(m, n, cone_dict)
x, y, s, D, DT = diffcp.solve_and_derivative(A, b, c, cone_dict)

# evaluate the derivative
Expand Down