M. Fratescu
M. Fratescu

Reputation: 13

rnd from a local variable

I am trying to write a code in which the probability of a collaboration being successful increases the more similar the agents are. on each run, a local variable computes the difference between agents and creates a link between agents if that difference doesn't exceed a threshold. the agents are subsequently stored in 2 separate lists based on whether a link was created or not. now, i would like to create another list that contains a successful vs unsuccessful value for each agent with whom a link was created. the probability of that value being 'successful' increases the more similar agents are (the more their difference value approaches 0).

the closest i've come to implementing this is the rnd extension. however, it seems to me that rnd:weighted-one-of only takes agent sets or lists as input and i do not have a predefined list for the similarities of agents. it is the whole range of 0 (complete similarity) and 1 (dissimilarity) that i would like the local variable to be compared to. is this possible in the way i'm currently thinking about it?

let difference 0
let initiator one-of turtles
ask initiator [
  let potential one-of other turtles
  if random-float 1.0 <= [my-activation] of self [                ;; different probability 
   set difference [my-profile] of self - [my-profile] of potential]    ;; of initiating 
                                                                       ;; collab                                                                                            
ifelse difference <= threshold [                                   ;; if threshold is met
  create-link-with potential                                       ;; link is initiated
  set collaborators fput potential collaborators][        ;; the initiator adds the 
  set failures fput potential failures]                   ;; potential to their list of                                  
                                                          ;; either collaborators 

Upvotes: 0

Views: 69

Answers (1)

Steve Railsback
Steve Railsback

Reputation: 1736

I recommend considering logistic functions as a way to relate similarity to probability. A logistic function is a "s"-shaped function that ranges from 0 to 1 as some X value (e.g., similarity) varies over a wide range. You can define the logistic function by assuming, for example, what values of similarity produce probabilities of 10% and 90%.

There is a complete discussion of using and programming logistic functions in NetLogo models in chapter 16 of: Railsback and Grimm 2019, "Agent-based and Individual-based Modeling".

Upvotes: 1

Related Questions