# Caveman-Solaria

Model was written in NetLogo 5.1.0
•
Viewed 511 times
•
Downloaded 29 times
•
Run 0 times

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)

Info tab cannot be displayed because of an encoding error

## Comments and Questions

Please start the discussion about this model!
(You'll first need to log in.)

Click to Run Model

;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Setup Procedures ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;; to setup clear-all set-default-shape turtles "circle" create-initial-substrate reset-ticks end to create-initial-substrate create-turtles number_of_nodes ask turtles [ set color red facexy 0 0 set size 3 ] let n 0 while [n < number_of_nodes] [ make-edge turtle n turtle ((n + 1) mod count turtles) set n n + 1 ] layout-circle (sort turtles) max-pxcor - 5 end ;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Main Procedure ;;;; ;;;;;;;;;;;;;;;;;;;;;;;; to go let terminate False ;; 1 - fix a vertex i ;; ask iterate once over all turtles in random order ask turtles [ ;; 2 - for every other vertex j compute Rij according to equation: ;; 1 if mij >= k ;; (mij/k)^alfa * (1 - p) + p if k > mij > 0 ;; p if mij = 0 ;; where mij is the number of vertices that are adjacient both to i and j ;; with the additional constraint that Rij = 0 if i and j are already connected let Rij n-values (number_of_nodes)[0] let others [who] of other turtles foreach others [ ; if it is a neighbor of i we already set Rij to 0 if not link-neighbor? turtle ? [ ;; Get the number of vertices that are adjacent both to i and j ; neighbors of i let i_neighbors link-neighbors ; neigbors of j let j_neighbors [link-neighbors] of turtle ? let mij 0 foreach [who] of i_neighbors [ if member? ? ([who] of j_neighbors) [ set mij (mij + 1) ] ] ; ? variable referes to current item in others list. ; Since others list is a list of turtle IDs I can use ? as an index in Rij list. if mij >= k [ set Rij replace-item ? Rij 1 ] if mij < k and mij > 0 [ set Rij replace-item ? Rij ( (mij / k) ^ alfa * (1 - p) + p ) ] if mij = 0 [ set Rij replace-item ? Rij p ] ];; END_if ];; END_foreach ;; 3 - Sum Rij over all j, and normalize each to obtain variables Pij = Rij / Sum_l!=i Ril. ;; Then since Sum_j Pij = 1, we can interpret Pij as the probability that i will connect to j. ;; Furthermore, we can interpret Pij geometrically as follows: divide the unit interval (0,1) ;; into n - 1 half-open subintervals with length Pij for all j != i. let sum_of_Rij sum Rij let Pij map [? / ifelse-value (sum_of_Rij > 0) [sum_of_Rij] [1] ] Rij ;; 4 - A uniform random variable r is then generated on (0,1). ;; it must fall into one of the subintervals, corresponding to j* let j* (jstar others Pij) ;; 5 - Connect i to j* if j* != -1 [ make-edge turtle who turtle j* ] ;; Stop when reach this threshold if count links >= (k * number_of_nodes / 2) [ set terminate True stop ; exit ask turtles ] ];; END_ask turtles if terminate [ stop ] tick end to-report jstar [others Pij] let r random-float 1 while [ r = 0 ] [ set r random-float 1 ] ; random-float might includes 0, even though it is unlikely let partial-sum 0 foreach others [ set partial-sum partial-sum + (item ? Pij) if partial-sum > r ; it is the same as if r > partial-sum and r < (partial-sum + (item ? Pij)) [ report ? ] ] report -1 end ;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Link Procedures ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;; ;; connects the two turtles to make-edge [node1 node2] ask node1 [ create-link-with node2 [ set color blue ] ] end to relayout ; layout-spring turtle-set link-set spring-constant spring-length repulsion-constant layout-spring turtles links 0.2 25 5 end

There is only one version of this model, created about 10 years ago by Marcello Tomasini.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

Caveman-Solaria.png | preview | Preview for 'Caveman-Solaria' | about 10 years ago, by Marcello Tomasini | Download |

This model does not have any ancestors.

This model does not have any descendants.