diff options
| author | jeanpouget-abadie <jean.pougetabadie@gmail.com> | 2015-02-03 20:24:40 -0500 |
|---|---|---|
| committer | jeanpouget-abadie <jean.pougetabadie@gmail.com> | 2015-02-03 20:24:40 -0500 |
| commit | a9acec30743687fdaf1df291b51b346bca7cf5a7 (patch) | |
| tree | da2d5b395c94e8610a939c7402ac2100dcd0b7f9 /src | |
| parent | 933143e7d15834b99eac4f23d4090654664fd716 (diff) | |
| download | cascades-a9acec30743687fdaf1df291b51b346bca7cf5a7.tar.gz | |
fix bug
Diffstat (limited to 'src')
| -rw-r--r-- | src/convex_optimization.py | 17 | ||||
| -rw-r--r-- | 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 |
