aboutsummaryrefslogtreecommitdiffstats
path: root/jpa_test
diff options
context:
space:
mode:
Diffstat (limited to 'jpa_test')
-rw-r--r--jpa_test/cascade_creation.py3
-rw-r--r--jpa_test/make_plots.py12
-rw-r--r--jpa_test/rip_condition.py5
3 files changed, 12 insertions, 8 deletions
diff --git a/jpa_test/cascade_creation.py b/jpa_test/cascade_creation.py
index a5c38cd..cc84c70 100644
--- a/jpa_test/cascade_creation.py
+++ b/jpa_test/cascade_creation.py
@@ -76,7 +76,8 @@ def icc_matrixvector_for_node(cascades, node):
Returns M, w in matrix form where rows of M are i = t + k.T
Excludes all (t,k) after node infection time; w = 1_{infected}
"""
- #TODO: you need to remove the variable corresponding to the node you are solving for!!!!
+ #TODO: you need to remove the variable corresponding to the node
+ #you are solving for!!!!
if node is None:
return np.vstack(cascades), None
else:
diff --git a/jpa_test/make_plots.py b/jpa_test/make_plots.py
index ed7bb10..e3c0d3d 100644
--- a/jpa_test/make_plots.py
+++ b/jpa_test/make_plots.py
@@ -14,16 +14,18 @@ def plot_rip_numberofnodes(max_proba, n_min, n_max, p_init, n_cascades, K_max):
for n_nodes in x:
print n_nodes
G = cascade_creation.InfluenceGraph(max_proba=.3)
- G.erdos_init(n=n_nodes, p=.5) #TODO: handle different inits!
+ G.erdos_init(n=n_nodes, p=.1) #TODO: handle different inits!
cascades = cascade_creation.generate_cascades(G, p_init=p_init,
n_cascades=n_cascades)
M, __ = cascade_creation.icc_matrixvector_for_node(cascades, None)
M = cascade_creation.normalize_matrix(M)
- y.append(rip_condition.find_kth_rip_constants(M, 5))
+ y.append(rip_condition.find_kth_rip_constants(M, 4)) #
+
+ print y
plt.clf()
plt.plot(x, y)
- plt.show()
+ #plt.show()
return x, y
@@ -32,8 +34,8 @@ def test():
"""
unit test
"""
- plot_rip_numberofnodes(max_proba=.3, n_min=10, n_max=15,
- p_init=.3, n_cascades=10, K_max=5)
+ plot_rip_numberofnodes(max_proba=.3, n_min=30, n_max=30,
+ p_init=.01, n_cascades=100, K_max=4)
if __name__=="__main__":
test()
diff --git a/jpa_test/rip_condition.py b/jpa_test/rip_condition.py
index 7c1ce85..fccf9a4 100644
--- a/jpa_test/rip_condition.py
+++ b/jpa_test/rip_condition.py
@@ -10,11 +10,12 @@ def find_kth_rip_constants(M, k):
1 + A_1 = arg max |Mx|_2^2 s.t. |x|_2 = 1 and |x|_0 = k
1 - A_2 = arg min |Mx|_2^2 s.t. |x|_2 = 1 and |x|_0 = kx
"""
- delta = 10
+ delta = 0
+ print M.shape
for col_set in itertools.combinations(xrange(M.shape[1]), k):
M_kcol = M[:,list(col_set)]
delta_upper, delta_lower = upperlower_bound_rip(M_kcol)
- delta = min(delta, min(delta_upper, delta_lower))
+ delta = max(delta, max(delta_upper, delta_lower))
return delta