I have a model with a preferential attachment network connecting one breed of agents. They should influence each other based on one property they own [trust?] and on their neighbors. Thus, if more neighbors have [trust? = true], they should also adopt this property. The code for influence is set as such and works in a normal setting:
to influence
; defines sexworkers-trust as the link to trusting sexworkers
let sexworkers-trust link-neighbors with [ trust? = true ]
; defines total-neighbors as the total link to neighbors
let total-neighbors link-neighbors
; if mistrusting sex workers are surrounded by more trusting neighbors, they are influenced and start trusting
if not trust? and random-float 1.0 < (neighbors-influence * (count sexworkers-trust / count total-neighbors ) ) [
set trust? true
set color green ]
end
At the moment, I also have an additional option where (if set on "on"), a certain number of sexworkers enter the world every 10 ticks. They are also added to the network. Now, somehow once this enter option is on, the simulation stops after a while with the error message "division by zero". Here below is my enter code, maybe there is a mistake there?
to enter
; creates 5 sex workers, randomly trusting/mistrusting
create-sexworkers 5 [
setxy random-xcor random-ycor
set trust? one-of [ true false ]
if trust? = TRUE [ set color green ]
if trust? = FALSE [ set color red ]
set birth-tick ticks ]
; asks trusting sex workers to create a link to one of the other trusting sex workers
ask sexworkers with [ trust? = true ]
[ create-link-with one-of other sexworkers with [ trust? = true ] ]
end
Also, normally trust? = true should be indicated by sex workers turning green, but somehow the enter code also doesn't do that correctly, they seem to not have corresponding colors to their properties. I might have to split this into two questions, but I think this is connected to the enter process that then in turn crashes the influence process.
Thank you so much!