Skip to content

Commit

Permalink
Untested.
Browse files Browse the repository at this point in the history
All nets undirected.

Added parents.

Offspring proper is now:
offspring-link-neighbors with [ not member? self [ parents ] of myself ]
  • Loading branch information
mariopaolucci committed Jul 19, 2021
1 parent 09f7403 commit 3b6b455
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions PROTON-OC.nlogo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ breed [prisoners prisoner]
undirected-link-breed [household-links household-link] ; person <--> person
undirected-link-breed [partner-links partner-link] ; person <--> person
undirected-link-breed [sibling-links sibling-link] ; person <--> person
directed-link-breed [offspring-links offspring-link] ; person <--> person
undirected-link-breed [offspring-links offspring-link] ; person <--> person
undirected-link-breed [friendship-links friendship-link] ; person <--> person
undirected-link-breed [criminal-links criminal-link] ; person <--> person
undirected-link-breed [professional-links professional-link] ; person <--> person
Expand All @@ -32,6 +32,7 @@ persons-own [
oc-member?
cached-oc-embeddedness ; only calculated (if needed) when the `oc-embeddedness` reporter is called
partner ; the person's significant other
parents
retired?
number-of-children
facilitator?
Expand Down Expand Up @@ -60,8 +61,8 @@ prisoners-own [
propensity
oc-member?
cached-oc-embeddedness
oc-embeddedness-fresh?
partner ; the person's significant other
parents
retired?
number-of-children
facilitator?
Expand Down Expand Up @@ -497,7 +498,7 @@ to socialization-intervene
soc-add-more-friends targets
]
if social-support = "all" [ ; also give a job to the mothers
welfare-createjobs (turtle-set [ in-offspring-link-neighbors ] of targets) with [ not male? ]
welfare-createjobs (turtle-set [ parents ] of targets) with [ not male? ]
]
end

Expand Down Expand Up @@ -542,7 +543,7 @@ to welfare-intervene
if welfare-support = "job-child" [
set targets all-persons with [ age > 16 and age < 24
and not any? my-school-links
and any? in-offspring-link-neighbors with [ male? and oc-member? ]
and any? parents with [ male? and oc-member? ]
and my-job = nobody ]
]
]
Expand Down Expand Up @@ -592,7 +593,7 @@ to family-intervene
]
]
let kids-to-protect persons with [
age < 18 and age >= 12 and any? in-offspring-link-neighbors with [
age < 18 and age >= 12 and any? parents with [
male? and oc-member? and runresult the-condition
]
]
Expand All @@ -601,9 +602,10 @@ to family-intervene
set kids-intervention-counter kids-intervention-counter + 1
; notice that the intervention acts on ALL family members respecting the condition, causing double calls for families with double targets.
; gee but how comes that it increases with the nubmer of targets? We have to do better here
let father one-of in-offspring-link-neighbors with [ male? and oc-member? ]
let father one-of parents with [ male? and oc-member? ]
; this also removes household links, leaving the household in an incoherent state.
ask my-in-offspring-links with [ other-end = father ] [ die ]
ask my-offspring-links with [ other-end = father ] [ die ]
set parents parents with [ self != father ]
set removed-fatherships fput (list ((18 * ticks-per-year + birth-tick) - ticks) father self) removed-fatherships
; at this point bad dad is out and we help the remaining with the whole package
let family (turtle-set self family-link-neighbors)
Expand All @@ -627,7 +629,7 @@ to return-kids
if any? turtle-set father [
if [ age ] of last a >= 18 [
if (random-float 1) < 6 / (first a) [
ask last a [ create-offspring-link-from father ]
ask last a [ create-offspring-link-with father set parents (turtle-set parents father) ]
set removed-fatherships remove a removed-fatherships
]
]
Expand Down Expand Up @@ -781,10 +783,11 @@ to-report up-to-n-of-other-with [ n p ]
end

to setup-siblings
ask persons with [ any? out-offspring-link-neighbors ] [ ; simulates people who left the original household.
; we are setting this to people who has parents.
ask persons with [ any? parents ] [ ; simulates people who left the original household. ; is this a bug??
let num-siblings random-poisson 0.5 ;the number of links is N^3 agents, so let's keep this low
; at this stage links with other persons are only relatives inside households and friends.
let p [ t -> any? out-offspring-link-neighbors and not link-neighbor? myself and abs age - [ age ] of myself < 5 ]
let p [ t -> any? parents and not link-neighbor? myself and abs age - [ age ] of myself < 5 ]
let candidates up-to-n-of-other-with 50 p
; remove couples from candidates and their neighborhoods
let all-potential-siblings [ -> (turtle-set self candidates sibling-link-neighbors [ sibling-link-neighbors ] of candidates)]
Expand Down Expand Up @@ -860,6 +863,7 @@ to init-person-empty ; person command
set oc-member? false ; the seed OC network are initialised separately
set retired? false
set partner nobody
set parents no-turtles
set number-of-children 0
set my-job nobody
set facilitator? false
Expand Down Expand Up @@ -917,20 +921,20 @@ to init-baby ; person procedure
; we stop counting after 2 because probability stays the same
set number-of-children number-of-children + 1
set number-born number-born + 1
hatch-persons 1 [
let brothers offspring-link-neighbors with [ not member? self [ parents ] of myself ]
hatch-persons 1 [ ; myself being the mom
set wealth-level [ wealth-level ] of myself
set birth-tick ticks
init-person-empty
ask [ offspring-link-neighbors ] of myself [
create-sibling-links-with other [ offspring-link-neighbors ] of myself
]
create-sibling-links-with brothers
create-household-links-with (turtle-set myself [ household-link-neighbors ] of myself)
create-offspring-links-from (turtle-set myself [ partner-link-neighbors ] of myself)
let dad one-of in-offspring-link-neighbors with [ male? ]
set max-education-level ifelse-value (any? turtle-set dad) [
[ max-education-level ] of dad
][
[ max-education-level ] of myself
let dad one-of [ partner-link-neighbors ] of myself
set parents (turtle-set dad myself)
ifelse dad != nobody [
create-offspring-link-with dad
set max-education-level [ max-education-level ] of dad
] [
set max-education-level [ max-education-level ] of myself
]
]
end
Expand Down Expand Up @@ -1215,7 +1219,7 @@ to commit-crimes
ask my-links with [ other-end = originator ] [
increase-network-used
]
if any? in-offspring-link-neighbors with [ male? and oc-member? ] [
if any? parents with [ male? and oc-member? ] [
set number-offspring-recruited-this-tick number-offspring-recruited-this-tick + 1
]
if target-of-intervention [
Expand Down Expand Up @@ -1575,8 +1579,8 @@ to generate-households
ask item 1 hh-members [ set partner item 0 hh-members ]
let couple (turtle-set item 0 hh-members item 1 hh-members)
let offspring turtle-set but-first but-first hh-members
ask couple [ create-offspring-links-to offspring ]
ask offspring [ create-sibling-links-with other offspring ]
ask couple [ create-offspring-links-with offspring ]
ask offspring [ create-sibling-links-with other offspring set parents couple ]
]
set hh-members turtle-set hh-members
ask hh-members [ create-household-links-with other hh-members set wealth-level family-wealth-level ]
Expand Down

0 comments on commit 3b6b455

Please sign in to comment.