From a9acec30743687fdaf1df291b51b346bca7cf5a7 Mon Sep 17 00:00:00 2001 From: jeanpouget-abadie Date: Tue, 3 Feb 2015 20:24:40 -0500 Subject: fix bug --- src/convex_optimization.py | 17 +++++++++-------- src/make_plots.py | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/convex_optimization.py b/src/convex_optimization.py index 39f7ee7..5942c70 100644 --- a/src/convex_optimization.py +++ b/src/convex_optimization.py @@ -90,7 +90,7 @@ def diff_and_opt(M_val, w_val, f_x, f_xz): def F(x=None, z=None): if x is None: - return 0, cvxopt.matrix(-.0000001, (n,1)) + return 0, cvxopt.matrix(-.001, (n,1)) elif z is None: y, y_diff = f_x(x, M_val, w_val) return cvxopt.matrix(float(y), (1, 1)),\ @@ -107,8 +107,8 @@ def diff_and_opt(M_val, w_val, f_x, f_xz): #Relaxing precision constraints cvxopt.solvers.options['feastol'] = 2e-5 cvxopt.solvers.options['abstol'] = 2e-5 - cvxopt.solvers.options['maxiters'] = 50 - cvxopt.solvers.options['show_progress'] = False + # cvxopt.solvers.options['maxiters'] = 50 + cvxopt.solvers.options['show_progress'] = True try: theta = cvxopt.solvers.cp(F, G, h)['x'] except ArithmeticError: @@ -128,11 +128,12 @@ def test(): """ unit test """ - lbda = .001 + lbda = .0001 G = cascade_creation.InfluenceGraph(max_proba=.9) G.erdos_init(n=20, p = .3) - A = cascade_creation.generate_cascades(G, .1, 1000) + A = cascade_creation.generate_cascades(G, .1, 500) M_val, w_val = cascade_creation.icc_matrixvector_for_node(A, 2) + print(len(M_val)) #Type lasso if 0: @@ -142,9 +143,9 @@ def test(): #Sparse recovery if 1: - p_vec, theta = sparse_recovery(lbda, 1000) - print(p_vec) - print(G.mat) + f_x, f_xz = sparse_recovery(lbda, 500) + p_vec, _ = diff_and_opt(M_val, w_val, f_x, f_xz) + print(G.mat[2]) if __name__=="__main__": test() diff --git a/src/make_plots.py b/src/make_plots.py index d92b008..201e375 100644 --- a/src/make_plots.py +++ b/src/make_plots.py @@ -58,5 +58,6 @@ def watts_strogatz(n_cascades, lbda, passed_function): if __name__=="__main__": - watts_strogatz(n_cascades=500, lbda=.001, passed_function= + watts_strogatz(n_cascades=3000, lbda=.002, passed_function= convex_optimization.sparse_recovery) + #algorithms.greedy_prediction) \ No newline at end of file -- cgit v1.2.3-70-g09d2