Skip to content

Commit ebbc14b

Browse files
authored
Merge pull request #30 from Transurgeon/main
scale benchmarks so they are a bit more stable
2 parents 92a7bd4 + 5a9283f commit ebbc14b

12 files changed

Lines changed: 45 additions & 38 deletions

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ jobs:
2222
tests:
2323
runs-on: ubuntu-latest
2424
steps:
25-
- uses: actions/checkout@v2
26-
- uses: actions/setup-python@v2
25+
- uses: actions/checkout@v4
26+
- uses: actions/setup-python@v4
2727
with:
28-
python-version: 3.8
28+
python-version: "3.12"
2929
- name: install and test
3030
run: |
3131
pip install .

backends/dpp_canonicalization.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@
4242
from dataclasses import dataclass, field
4343
from typing import Callable
4444

45-
import numpy as np
46-
4745
import cvxpy as cp
46+
import numpy as np
4847

4948
# Optional imports
5049
try:
@@ -1184,8 +1183,12 @@ def main():
11841183
profile_problems = {
11851184
"dpp_lasso_small": ("DPP LASSO (50x100)", make_dpp_lasso(50, 100)),
11861185
"dpp_lasso_medium": ("DPP LASSO (200x500)", make_dpp_lasso(200, 500)),
1187-
"dpp_constraint_medium": ("DPP Constraint (500x200)", make_dpp_constraint_matrix(200, 500)),
1188-
"dpp_constraint_large": ("DPP Constraint (1000x500)", make_dpp_constraint_matrix(500, 1000)),
1186+
"dpp_constraint_medium": (
1187+
"DPP Constraint (500x200)", make_dpp_constraint_matrix(200, 500)
1188+
),
1189+
"dpp_constraint_large": (
1190+
"DPP Constraint (1000x500)", make_dpp_constraint_matrix(500, 1000)
1191+
),
11891192
}
11901193
if args.profile in profile_problems:
11911194
name, factory = profile_problems[args.profile]

benchmark/finance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def time_compile_problem(self):
8484

8585
class FactorCovarianceModel:
8686
def setup(self):
87-
n = 14500
87+
n = 25000
8888
m = 250
8989
np.random.seed(1)
9090
mu = np.abs(np.random.randn(n, 1))

benchmark/gini_portfolio.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Yitzhaki:
2020
def setup(self):
2121
rs = np.random.RandomState(123)
2222
N = 50
23-
T = 150
23+
T = 300
2424
cov = rs.rand(N, N) * 1.5 - 0.5
2525
cov = cov @ cov.T/1000 + np.diag(rs.rand(N) * 0.7 + 0.3)/1000
2626
mean = np.zeros(N) + 1/1000
@@ -51,7 +51,7 @@ class Murray:
5151
def setup(self):
5252
rs = np.random.RandomState(123)
5353
N = 50
54-
T = 350
54+
T = 700
5555
cov = rs.rand(N, N) * 1.5 - 0.5
5656
cov = cov @ cov.T/1000 + np.diag(rs.rand(N) * 0.7 + 0.3)/1000
5757
mean = np.zeros(N) + 1/1000
@@ -95,7 +95,7 @@ class Cajas:
9595
def setup(self):
9696
rs = np.random.RandomState(123)
9797
N = 50
98-
T = 350
98+
T = 800
9999
cov = rs.rand(N,N) * 1.5 - 0.5
100100
cov = cov @ cov.T/1000 + np.diag(rs.rand(N) * 0.7 + 0.3)/1000
101101
mean = np.zeros(N) + 1/1000

benchmark/high_dim_convex_plasticity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def criterion(sig: cp.Variable, p: cp.Variable):
6262
)
6363
deps_dummy = np.full((4000, 4), particular_deps)
6464

65-
N = 500
65+
N = 3000
6666
deps_local_values = deps_dummy[:N]
6767

6868
deps = cp.Parameter((4, N), name="deps")

benchmark/matrix_stuffing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
class ConeMatrixStuffingBench:
2020

2121
def setup(self):
22-
m = 2000
23-
n = 2000
22+
m = 5000
23+
n = 5000
2424
A = np.random.randn(m, n)
2525
C = np.random.rand(m // 2)
2626
b = np.random.randn(m)
@@ -68,8 +68,8 @@ def time_compile_problem(self):
6868
class SmallMatrixStuffing:
6969

7070
def setup(self):
71-
m = 200
72-
n = 200
71+
m = 4000
72+
n = 4000
7373
A = np.random.randn(m, n)
7474
C = np.random.rand(m // 2)
7575
b = np.random.randn(m)
@@ -91,8 +91,8 @@ def time_compile_problem(self):
9191
class ParamSmallMatrixStuffing:
9292

9393
def setup(self):
94-
m = 100
95-
n = 100
94+
m = 300
95+
n = 300
9696
A = cp.Parameter((m, n))
9797
C = cp.Parameter(m // 2)
9898
b = cp.Parameter(m)

benchmark/semidefinite_programming.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class SemidefiniteProgramming:
2222

2323
def setup(self):
2424
# Generate a random SDP.
25-
n = 125
26-
p = 75
25+
n = 200
26+
p = 120
2727
np.random.seed(1)
2828
C = np.random.randn(n, n)
2929
A = []

benchmark/simple_LP_benchmarks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def time_compile_problem(self):
3131

3232
class SimpleFullyParametrizedLPBenchmark:
3333
def setup(self):
34-
n = int(1e4)
34+
n = int(1e6)
3535
p = cp.Parameter(n)
3636
x = cp.Variable(n)
3737
objective = cp.Minimize(p @ x)
@@ -45,7 +45,7 @@ def time_compile_problem(self):
4545

4646
class SimpleScalarParametrizedLPBenchmark:
4747
def setup(self):
48-
n = int(1e6)
48+
n = int(2e6)
4949
p = cp.Parameter()
5050
c = np.arange(n)
5151
x = cp.Variable(n)

benchmark/simple_QP_benchmarks.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
class SimpleQPBenchmark:
2020
def setup(self):
21-
m = 2000
22-
n = 400
23-
p = 5
21+
m = 8000
22+
n = 1600
23+
p = 20
2424
np.random.seed(1)
2525
P = np.random.randn(n, n)
2626
P = np.matmul(P.T, P)
@@ -43,8 +43,8 @@ def time_compile_problem(self):
4343

4444
class ParametrizedQPBenchmark:
4545
def setup(self):
46-
m = 250
47-
n = 100
46+
m = 6000
47+
n = 2400
4848
np.random.seed(1)
4949
A = cp.Parameter((m, n))
5050
b = cp.Parameter((m,))
@@ -61,8 +61,8 @@ def time_compile_problem(self):
6161

6262
class LeastSquares:
6363
def setup(self):
64-
m = 5000
65-
n = 1000
64+
m = 7000
65+
n = 2000
6666
np.random.seed(1)
6767
A = np.random.randn(m, n)
6868
b = np.random.randn(m)
@@ -81,9 +81,9 @@ class UnconstrainedQP:
8181
Related issue: https://github.com/cvxpy/cvxpy/issues/2205
8282
"""
8383
def setup(self):
84-
N_r = 16
84+
N_r = 18
8585
N_t = 2
86-
N_s = 6
86+
N_s = 7
8787

8888
x = np.random.randint(2, size=N_s * N_r * N_t)
8989

benchmark/slow_pruning_1668_benchmark.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ def setup(self):
2222
2323
Pruning matrices caused order-of-magnitude slow downs in compilation times.
2424
"""
25-
s = 2000
26-
t = 10
25+
s = 4000
26+
t = 20
2727
x = np.linspace(-100.0, 100.0, s)
28-
rows = 50
28+
rows = 100
2929
var = cp.Variable(shape=(rows, t))
3030

3131
cost = cp.sum_squares(

0 commit comments

Comments
 (0)