Skip to content

Commit

Permalink
changed examples generation to create good rho plots
Browse files Browse the repository at this point in the history
  • Loading branch information
bstellato committed Mar 22, 2017
1 parent 463afbb commit 01f3e8f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ out/
# Data Files
# -------------------------------------------------------------------
interfaces/python/tests/qp_problems/results/
interfaces/python/tests/qp_problems/results_bak
interfaces/python/tests/qp_problems/figures/
tests/**/*data.h
interfaces/python/tests/codegen/**/*.so
Expand Down
2 changes: 1 addition & 1 deletion interfaces/python/tests/qp_problems/qp_examples/lasso.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def create_dims(self, n_vec, m_vec):
np.array([[n], [m]])))
return dims_mat

def gen_problem(self, m, n, dens_lvl=0.5, version='dense'):
def gen_problem(self, m, n, dens_lvl=0.5, version='sparse'):
"""
Lasso problem is defined as
minimize || Ax - b ||^2 + gamma * || x ||_1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def perform_tests(self, **kwargs):
for _ in range(self.nm_num_prob): # Generate some random problems

# Get current seed
current_seed = np.random.randint(0, sys.maxsize)
current_seed = np.random.randint(0, 2**32 - 1)
np.random.seed(current_seed)

# generate problem and store statistics
Expand Down
2 changes: 1 addition & 1 deletion interfaces/python/tests/qp_problems/qp_examples/svm.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def create_dims(self, n_vec, m_vec):
np.array([[n], [m]])))
return dims_mat

def gen_problem(self, m, n, dens_lvl=1.0):
def gen_problem(self, m, n, dens_lvl=.8):
"""
Support vector machine problem is defined as
minimize || x ||^2 + gamma * 1.T * max(0, diag(b) A x + 1)
Expand Down
27 changes: 14 additions & 13 deletions interfaces/python/tests/qp_problems/run_qpexamples.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@



dim_vecs_len = 10
dim_vecs_len = 20
# n_vec = np.array([20])
# m_vec = np.array([30])
n_max = 50
m_max = 50
n_vec = np.arange(10, n_max, int(n_max/dim_vecs_len))
m_vec = np.arange(10, m_max, int(m_max/dim_vecs_len))
n_max = 50
m_max = 50
n_vec = np.arange(10, n_max, int(n_max/dim_vecs_len))
m_vec = np.arange(10, m_max, int(m_max/dim_vecs_len))



Expand All @@ -63,13 +63,14 @@
'polish': False,
'scaling_norm': 2,
'scaling_iter': 3,
'early_terminate_interval': 1,
'max_iter': 2500}

# Test types
# test_types = ['basis_pursuit', 'huber_fit', 'lasso', 'nonneg_l2', 'lp',
# 'portfolio', 'svm']

test_types = ['svm', 'lasso', 'portfolio']
test_types = ['lasso', 'svm']

def run_examples(test_type, n_vec, m_vec, rho_vec, sigma_vec,
alpha_vec, nm_num_prob, **kwargs):
Expand Down Expand Up @@ -112,13 +113,13 @@ def run_examples(test_type, n_vec, m_vec, rho_vec, sigma_vec,
results_full = [x[1] for x in res]


# # Execute problems in series
# results = []
# results_full = []
# for i in range(len(test_types)):
# res, res_full = partial_tests(test_types[i])
# results.append(res)
# results_full.append(res_full)
# Execute problems in series
# results = []
# results_full = []
# for i in range(len(test_types)):
# res, res_full = partial_tests(test_types[i])
# results.append(res)
# results_full.append(res_full)

cputime = time() - t
print("total cputime = %.4f sec" % cputime)
Expand Down

0 comments on commit 01f3e8f

Please sign in to comment.