diff --git a/Thesis/AntonioCrucianiExtracted.pdf b/Thesis/AntonioCrucianiExtracted.pdf deleted file mode 100755 index 8d7011d..0000000 Binary files a/Thesis/AntonioCrucianiExtracted.pdf and /dev/null differ diff --git a/Thesis/AntonioCruciani_Master's_Degree_Thesis(ITA).pdf b/Thesis/AntonioCruciani_Master's_Degree_Thesis(ITA).pdf deleted file mode 100644 index 5e8df0e..0000000 Binary files a/Thesis/AntonioCruciani_Master's_Degree_Thesis(ITA).pdf and /dev/null differ diff --git a/Thesis/readme.md b/Thesis/readme.md deleted file mode 100644 index ecdc515..0000000 --- a/Thesis/readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# README - -This folder contains my Master's Degree Thesis in which I proposed and analyzed the Edge Dynamic and the Vertex Dynamic models. - -At the moment **only the Italian version is available**, the English version will be soon diff --git a/configurations/EdgeDynamics/edge_dynamics_flooding_conf.ini b/configurations/EdgeDynamics/edge_dynamics_flooding_conf.ini new file mode 100644 index 0000000..4166a15 --- /dev/null +++ b/configurations/EdgeDynamics/edge_dynamics_flooding_conf.ini @@ -0,0 +1,39 @@ +[model] +graph = ED +nodes = [64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768] +degree = [2, 3, 4] +tolerance = [1.5, 2, 3] +edge_node_falling_probability = [ 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.06, 0.05, 0.02, 0.005, 0.002, 9e-05, 9e-06, 1e-07, 0.0] +nodes_poisson_rate = None + +[simulations] +flooding_protocol = True +simultaions_number = 100 +only_spectral_properties = False +offline_simulation = False + +[other_parameters] +gpu_optimization = False +epsilon = 0.005 +max_iterations = 100 + +[output_path] +outputpath = ./Outputs/EdgeDynamics + +[advanced] +min_nodes = None +max_nodes = None +step_nodes = None +min_degree = None +max_degree = None +step_degree = None +min_tolerance = None +max_tolerance = None +step_tolerance = None +min_edge_node_falling_probability = None +max_edge_node_falling_probability = None +step_edge_node_falling_probability = None +min_nodes_poisson_rate = None +max_nodes_poisson_rate = None +step_nodes_poisson_rate = None + diff --git a/configurations/EdgeDynamics/edge_dynamics_spectral_conf.ini b/configurations/EdgeDynamics/edge_dynamics_spectral_conf.ini new file mode 100644 index 0000000..3653e8e --- /dev/null +++ b/configurations/EdgeDynamics/edge_dynamics_spectral_conf.ini @@ -0,0 +1,39 @@ +[model] +graph = ED +nodes = [64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768] +degree = [2, 3, 4] +tolerance = [1.5, 2, 3] +edge_node_falling_probability = [1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.06, 0.05, 0.02, 0.005, 0.002, 9e-05, 9e-06, 1e-07, 0.0] +nodes_poisson_rate = None + +[simulations] +flooding_protocol = False +simultaions_number = 10 +only_spectral_properties = True +offline_simulation = False + +[other_parameters] +gpu_optimization = False +epsilon = 0.005 +max_iterations = 100 + +[output_path] +outputpath = ./Outputs/EdgeDynamics + +[advanced] +min_nodes = None +max_nodes = None +step_nodes = None +min_degree = None +max_degree = None +step_degree = None +min_tolerance = None +max_tolerance = None +step_tolerance = None +min_edge_node_falling_probability = None +max_edge_node_falling_probability = None +step_edge_node_falling_probability = None +min_nodes_poisson_rate = None +max_nodes_poisson_rate = None +step_nodes_poisson_rate = None + diff --git a/configurations/VertexDynamics/vertex_dynamics_flooding_conf.ini b/configurations/VertexDynamics/vertex_dynamics_flooding_conf.ini new file mode 100644 index 0000000..98057cc --- /dev/null +++ b/configurations/VertexDynamics/vertex_dynamics_flooding_conf.ini @@ -0,0 +1,39 @@ +[model] +graph = VD +nodes = [64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768] +degree = [2, 3, 4] +tolerance = [1.5, 2, 3] +edge_node_falling_probability = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.06, 0.05, 0.02, 0.005, 0.002] +nodes_poisson_rate = None + +[simulations] +flooding_protocol = True +simultaions_number = 100 +only_spectral_properties = False +offline_simulation = False + +[other_parameters] +gpu_optimization = False +epsilon = 0.005 +max_iterations = 100 + +[output_path] +outputpath = ./Outputs/VertexDynamics + +[advanced] +min_nodes = None +max_nodes = None +step_nodes = None +min_degree = None +max_degree = None +step_degree = None +min_tolerance = None +max_tolerance = None +step_tolerance = None +min_edge_node_falling_probability = None +max_edge_node_falling_probability = None +step_edge_node_falling_probability = None +min_nodes_poisson_rate = None +max_nodes_poisson_rate = None +step_nodes_poisson_rate = None + diff --git a/configurations/VertexDynamics/vertex_dynamics_spectral_conf.ini b/configurations/VertexDynamics/vertex_dynamics_spectral_conf.ini new file mode 100644 index 0000000..3581ae5 --- /dev/null +++ b/configurations/VertexDynamics/vertex_dynamics_spectral_conf.ini @@ -0,0 +1,39 @@ +[model] +graph = VD +nodes = [64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768] +degree = [2, 3, 4] +tolerance = [1.5, 2, 3] +edge_node_falling_probability = [ 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.06, 0.05, 0.02, 0.005, 0.002] +nodes_poisson_rate = None + +[simulations] +flooding_protocol = False +simultaions_number = 10 +only_spectral_properties = True +offline_simulation = False + +[other_parameters] +gpu_optimization = False +epsilon = 0.005 +max_iterations = 100 + +[output_path] +outputpath = ./Outputs/VertexDynamics + +[advanced] +min_nodes = None +max_nodes = None +step_nodes = None +min_degree = None +max_degree = None +step_degree = None +min_tolerance = None +max_tolerance = None +step_tolerance = None +min_edge_node_falling_probability = None +max_edge_node_falling_probability = None +step_edge_node_falling_probability = None +min_nodes_poisson_rate = None +max_nodes_poisson_rate = None +step_nodes_poisson_rate = None + diff --git a/img/Dynamic.png b/img/Dynamic.png deleted file mode 100644 index a6217ad..0000000 Binary files a/img/Dynamic.png and /dev/null differ diff --git a/img/EMG0307.gif b/img/EMG0307.gif deleted file mode 100644 index d9a7ce7..0000000 Binary files a/img/EMG0307.gif and /dev/null differ diff --git a/img/EMG0505.gif b/img/EMG0505.gif deleted file mode 100644 index bbb6d7e..0000000 Binary files a/img/EMG0505.gif and /dev/null differ diff --git a/img/EMG0802.gif b/img/EMG0802.gif deleted file mode 100644 index 95cd72c..0000000 Binary files a/img/EMG0802.gif and /dev/null differ diff --git a/img/EdgeDynamic.gif b/img/EdgeDynamic.gif deleted file mode 100644 index e997ff4..0000000 Binary files a/img/EdgeDynamic.gif and /dev/null differ diff --git a/img/EdgeDynamic.png b/img/EdgeDynamic.png deleted file mode 100644 index 54b0052..0000000 Binary files a/img/EdgeDynamic.png and /dev/null differ diff --git a/img/FullyDyn.png b/img/FullyDyn.png deleted file mode 100644 index 67ba760..0000000 Binary files a/img/FullyDyn.png and /dev/null differ diff --git a/img/RAES.gif b/img/RAES.gif deleted file mode 100644 index 2601438..0000000 Binary files a/img/RAES.gif and /dev/null differ diff --git a/img/RAES.png b/img/RAES.png deleted file mode 100644 index 34677a8..0000000 Binary files a/img/RAES.png and /dev/null differ diff --git a/img/TransitionMatrix.png b/img/TransitionMatrix.png deleted file mode 100644 index df61431..0000000 Binary files a/img/TransitionMatrix.png and /dev/null differ diff --git a/img/VertexDynamic.gif b/img/VertexDynamic.gif deleted file mode 100644 index f7e90ab..0000000 Binary files a/img/VertexDynamic.gif and /dev/null differ diff --git a/img/floodEdjedyn.gif b/img/floodEdjedyn.gif deleted file mode 100644 index 7dfec49..0000000 Binary files a/img/floodEdjedyn.gif and /dev/null differ diff --git a/img/queue.png b/img/queue.png deleted file mode 100644 index 7be882f..0000000 Binary files a/img/queue.png and /dev/null differ diff --git a/img/spectralconv.gif b/img/spectralconv.gif deleted file mode 100644 index e9d36dd..0000000 Binary files a/img/spectralconv.gif and /dev/null differ diff --git a/readme.md b/readme.md index 7e47882..55614fd 100644 --- a/readme.md +++ b/readme.md @@ -42,11 +42,9 @@ It is possible to define " external events " that causes the edge or node disapp ### P2P - **RAES** ( Request a link, then Accept if Enough Space ) proposed by Becchetti et al. -( [More details](https://arxiv.org/abs/1811.10316) ) that allow you to construct an Expander Graph in **O**(log n) rounds With High Probability. -- **Edge Dynamic** proposed by Antonio Cruciani ([More details (ITA)](./Thesis/AntonioCruciani_Master's_Degree_Thesis(ITA).pdf) [More details (ENG)](./Thesis/AntonioCrucianiExtracted.pdf)) that is a natural extension of RAES where there exists the probability **p** that, at each time step, each edge of the graph can fall. This is an infinite stochastic process that allow you to construct a good dynamic Expander Graph. -- **Vertex Dynamic** proposed by Antonio Cruciani ([More details (ITA)](./Thesis/AntonioCruciani_Master's_Degree_Thesis(ITA).pdf) [More details (ENG)](./Thesis/AntonioCrucianiExtracted.pdf)) that is a Dynamic Random Graph where at each time step there are new vertices that join the network and vertices that leave it. This is an infinite stochastic process that allow you to construct a good dynamic Expander Graph. -### Radio Networks -- **Edge Markovian** You can read about it at the following [link](https://dl.acm.org/doi/pdf/10.1145/1400751.1400781 ) in this model you have a fixed number of nodes and each edge is a Birth-Death Markov Chain. +( [More details](https://arxiv.org/abs/1811.10316) ) that allows you to define an Expander Graph in **O**(log n) rounds With High Probability. +- **Edge Dynamic** proposed by Antonio Cruciani and Francesco Pasquale ([More details](link_paper) that is a natural extension of RAES where there exists the probability **p** that, at each time step, each edge of the graph can fall. This is an infinite stochastic process that allow you to construct a good dynamic Expander Graph. +- **Vertex Dynamic** proposed by Antonio Cruciani and Francesco Pasquale ([More details](link_paper) that is a Dynamic Random Graph where at each time step there are new vertices that join the network and vertices that leave it. This is an infinite stochastic process that allow you to construct a good dynamic Expander Graph. ## How to define and execute a model Given the **config.ini** file set up the model that you want to simulate @@ -67,243 +65,39 @@ Modify the **.ini** file under the section: **[simulations]** * **only_spectral_properties** If **True** simulate the model saving only the Spectral Gaps at each round. * **offline_simulation** If **True** saves as a file the adjacency list of the Dynamic Graph before and after the execution of the distributed protocol. **WARNING:** It performs a high amount of file writings on the disk. -## Other parameters +### Other parameters Modify the **.ini** file under the section: **[other_parameters]** - -## RAES - -Dynamic Random Graph G(n,d,c) where: - -- **n** is the number of vertices -- **d** is the minimum required degree in the graph -- **c** is the tolerance (c*d = Max Degree in the graph) - - -RAES evolves over time with the following rules: - -RAESRG - -```python -from src.Graphs.Objects.MultipleEdge import DynamicGraph -# Initializing parameters -n = 30 -d = 3 -c = 1.5 -p = 0 -lamb = 1 -beta = 0.01 -G = DynamicGraph(n,d,c,lamb,beta,p,"Multiple") -# is regular return False if all vertices has d <= degree <= c*d, else return True -while(G.isregular()): - # Phase 1 - G.add_phase() - # Phase 2 - G.del_phase() -``` -Demo of the example, - -- **blue nodes** : d <= degree <= c*d -- **red nodes** : degree < d or degree > c*d -

-RAESRG -

- -## Edge-Dynamic -Dynamic Random Graph G(n,d,c,p) where: - -- **n** is the number of vertices -- **d** is the minimum required degree in the graph -- **c** is the tolerance (c*d = Max Degree in the graph) -- **p** is the falling proability of edges - -Edge Dynamic evolves over time with the following rules: - -RAESRG - -```python -from src.Graphs.Objects.MultipleEdge import DynamicGraph -# Initializing parameters -n = 30 -d = 3 -c = 1.5 -p = 0.1 -lamb = 1 -beta = 0.01 -G = DynamicGraph(n,d,c,lamb,beta,p,"Multiple") -t = 0 -while(t<500): - # Phase 1 - G.add_phase() - # Phase 2 - G.del_phase() - # Phase 3 - G.random_fall() - t+=1 -``` -Demo of the example, - -- **blue nodes** : d <= degree <= c*d -- **red nodes** : degree < d or degree > c*d -

-RAESRG -

- -## Vertex-Dynamic -Dynamic Random Graph G(lambda,q,d,c) where: - -- **lambda** is the intensity parameter of the Poisson Process -- **q** is the exit proability of Vertices -- **d** is the minimum required degree in the graph -- **c** is the tolerance (c*d = Max Degree in the graph) - -Vertex Dynamic evolves over time with the following rules: -Fdyn - -```python -from src.Graphs.Objects.MultipleEdge import DynamicGraph -# Initializing parameters -n = 0 -d = 3 -c = 1.5 -p = 0 -lamb = 1 -beta = 0.01 -G = DynamicGraph(n,d,c,lamb,beta,p,"Multiple") -t = 0 -while(t<500): - # Phase 1 - G.connect_to_network() - # Phase 2 - G.add_phase() - # Phase 3 - G.del_phase() - # Phase 4 - G.disconnect_from_network() - t+=1 -``` -Demo of the example, - -- **blue nodes** : d <= degree <= c*d -- **red nodes** : degree < d or degree > c*d -

-Vdyn -

- -## Edge-Markovian -Dynamic Random Graph G(n,p,q,E0) where: - -- **n** is the number of vertices -- **p** is the birth-rate of the edges -- **q** is the death-rate of the edges -- **E0** is the set of the edges at time 0 - -The Edge Markovian Random Graph evolves over time with the following rule: - -```python -from src.Graphs.Objects.MultipleEdge import DynamicGraph -# Initializing parameters -n = 32 -p = 0.5 -q = 0.5 -G = DynamicGraph(n,model = "EdgeMarkovian",starting_edge_list = [],edge_birth_rate = p,edge_death_rate= q) -t = 0 -while(t<500): - G.edge_markovian() - t+=1 -``` - -Demo of the example, - -

-Vdyn -

- - - -## Distributed-Protocols -It is possible to simulate the Flooding Procol on the Dynamic Graph. You just have to instantiate the Flooding object of the DynamicGraph: - -```python -G.set_flooding() -``` -After this step you can choose the initiator u.a.r.: - -```python -G.flooding.set_initiator() -``` -And for the update step you have to use: - -```python -G.flooding.update_flooding(G) -``` -Demo of the flooding on the Edge Dynamic, - -- **black nodes** : Not informed -- **yellow nodes** : Informed -

-flood -

- -## Heuristic-Convergence -We propose an Heuristic to determine if the Edge Dynamic has converged. -Given the adjacency matrix **A** of the graph at a generic time step we define: -

-Tmat -

- -Where **D** is the diagonal **degree matrix** of the graph. Given the spectrum of **P** (ordered in descending order) we define the **spectral gap** as the difference between the first and the second eigenvalues of **P**. We know that if the spectral gap of the transition matrix **P** is small (near to 0) we have that the graph is not a good Expander Graph. Thanks to this measure we can understand a key property of the graph at each time step and we can define a convergence criterion as follows: -```if the spectral gap differs only by an epsilon for log n rounds we have that the graph is converged to a stationary configuration.``` - -To check this property we can define a queue (FIFO) of lenght log n and check if the last log n spectral gaps differs for an epsilon factor. - -

-queuem -

- -```python -from src.Graphs.Objects.MultipleEdge import DynamicGraph -from src.Graphs.Objects.Queue import Queue -from src.StastModules.SpectralAnalysis import get_spectral_gap_transition_matrix -# Initializing parameters -n = 64 -d = 3 -c = 1.5 -p = 0.1 -lamb = 1 -beta = 0.01 -epsilon = 0.05 -spectral_queue = Queue(mt.log(n,2)) -G = DynamicGraph(n,d,c,lamb,beta,p,"Multiple") -# G.get_converged() return True if the graph is converged, else return False -while(not(G.get_converged()): - # Phase 1 - G.add_phase() - # Phase 2 - G.del_phase() - # Phase 3 - G.random_fall() - Isinvertible, spectralGap, lambdaNGap = get_spectral_gap_transition_matrix(G.get_G()) - spectral_queue.add_element_to_queue(spectralGap) - if (spectral_queue.get_queue_lenght() == spectral_queue.get_max_lenght() and spectral_queue.get_converged() == False): - spectral_differences = [] - s_q = spectral_queue.get_queue() - for i in range(0, spectral_queue.get_queue_lenght() - 1): - spectral_differences.append(abs(s_q[i] - s_q[i + 1])) - terminate = True - for j in spectral_differences: - if (j > epsilon): - terminate = False - if(terminate): - spectral_queue.set_converged(terminate) - G.set_converged(True) -``` -Demo of the heuristic on the Edge Dynamic, - -- **black nodes** : Not Converged -- **yellow nodes** : Converged -

-convergence -

+* **gpu_optimization** If **True** utilizes your GPU to calculate the eigenvalues of the adjacency matrix of the dynamic graph at each round. **NOTE:** If you do not have cuda, switch branch to **CPU** in which this option is always **False** and there is no need to install cuda and cupy packages. +* **epsilon** Float value for the epsilon used by the convergence heuristic in the Edge Dynamic model. **NOTE:** the Edge Dynamic automatically estimate the epsilon value. +* **max_iterations** Int value for the maximum number of iteration of the models after their convergence (if you are not simulating the Offline version) or number of steps to perform (if you are simulating the Offline version). + +### Output path +Modify the **.ini** file under the section: **[output_path]** +* **output_path** Output path of the simulations + +### Advanced parameters +Modify the **.ini** file under the section: **[advanced]**. Commands for simulating the model on a range of values, every command follows the pattern **< min_param , max_param, step_param >** where: +* **min_param** is the minimum value +* **max_param** is the maximum value +* **step_param** is the constant increment from **min_param** to **max_param** + +For example, for: + * min_nodes = 10 + * max_nodes = 100 + * step_nodes = 20 + +the tool will simulate the model with the following number of nodes: [10,30,50,70,90] + +### Running the model +For executing the model use the command: + + Python main.py + +## Reproducing the experiments in the paper +In order to reproduce the experiments in the paper substitute the **config.ini** file with the ones in the appropriate folders **configurations/EdgeDynamics** or **configurations/VertexDynamics**. +* **Spectral properties** : model_spectral_conf.ini + +* **Flooding simulation** : model_flooding_simulation.ini ## License This is free software, if you want to use it please cite this work.